Skip to content

Conversation

@cknitt
Copy link
Member

@cknitt cknitt commented Jan 21, 2026

Currently, the JS files in

  • packages/@rescript/runtime/lib/es6
  • packages/@rescript/runtime/lib/js

all have the extension .js and not the specific extension for their module system.
Therefore, packages/@rescript/runtime/lib/js/package.json is needed to override the module system for the commonjs files.

This PR instead adds the specific file extension for each module system:

  • packages/@rescript/runtime/lib/es6/*.mjs
  • packages/@rescript/runtime/lib/js/*.cjs

This makes things clearer and allows us to get rid of the override.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 21, 2026

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@8207

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@8207

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@8207

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@8207

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@8207

@rescript/runtime

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@8207

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@8207

commit: debea41

@nojaf nojaf requested a review from Copilot January 21, 2026 09:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the ReScript runtime files to use explicit module system file extensions (.mjs for ES modules and .cjs for CommonJS) instead of the generic .js extension, eliminating the need for a package.json override in the CommonJS directory.

Changes:

  • Updated all import/require statements in runtime files to use the correct file extensions
  • Modified compiler logic to generate the appropriate file extensions for runtime modules
  • Removed runtime package specs configuration that was previously needed

Reviewed changes

Copilot reviewed 116 out of 587 changed files in this pull request and generated no comments.

File Description
packages/@rescript/runtime/lib/js/*.cjs Updated require statements to use .cjs extension instead of .js
packages/@rescript/runtime/lib/es6/*.mjs Updated import statements to use .mjs extension instead of .js
compiler/core/js_packages_info.ml Removed runtime package specs configuration and related comments
compiler/core/js_name_of_module_id.ml Added logic to determine runtime file extensions based on module system

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cknitt cknitt requested review from cristianoc, nojaf and zth January 21, 2026 10:20
@cknitt cknitt merged commit d4a533b into rescript-lang:master Jan 21, 2026
26 checks passed
@cknitt cknitt deleted the runtime-cjs-mjs branch January 21, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants