Skip to content

feat(core)!: enable createRequire parser by default - #1814

Open
elecmonkey wants to merge 3 commits into
mainfrom
elecmonkey/create-require
Open

feat(core)!: enable createRequire parser by default#1814
elecmonkey wants to merge 3 commits into
mainfrom
elecmonkey/create-require

Conversation

@elecmonkey

@elecmonkey elecmonkey commented Jul 30, 2026

Copy link
Copy Markdown
Member

Summary

Enable Rspack's createRequire parser by default so Rslib can statically analyze and bundle createRequire() calls.

The ESM and CJS outputs in the tests/integration/shims/cjs case remain correct and preserve the expected module semantics.

Breaking Change

Static dependencies loaded through createRequire() are now bundled instead of being preserved for runtime resolution. Set tools.rspack.module.parser.javascript.createRequire to false to restore the previous behavior.

Output Changes

For static createRequire() calls, the dependency is bundled and the call is replaced with __webpack_require__().

In the shims integration case:

  • ESM output bundles the CommonJS dependency and adds a shared Rspack runtime chunk.
  • CJS output embeds the CommonJS module and scopes "use strict" to the ESM module factory instead of the entire chunk, preserving the original non-strict CommonJS semantics.
  • Dynamic chunks and runtime behavior remain unchanged.

Related Links

Copilot AI review requested due to automatic review settings July 30, 2026 08:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@elecmonkey
elecmonkey marked this pull request as draft July 30, 2026 08:21
Comment thread tests/integration/shims/index.test.ts
@elecmonkey
elecmonkey marked this pull request as ready for review July 30, 2026 16:33
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.

3 participants