Skip to content

feat: improve rendering node built-in module#20255

Merged
alexander-akait merged 6 commits intomainfrom
node-module-external
Jan 12, 2026
Merged

feat: improve rendering node built-in module#20255
alexander-akait merged 6 commits intomainfrom
node-module-external

Conversation

@hai-x
Copy link
Member

@hai-x hai-x commented Dec 18, 2025

Summary

What kind of change does this PR introduce?

Improve rendering built-in module when target to node and enable module output.

Did you add tests for your changes?

Yes

Does this PR introduce a breaking change?

No

If relevant, what needs to be documented once your changes are merged or what have you already documented?

No

@changeset-bot
Copy link

changeset-bot bot commented Dec 18, 2025

🦋 Changeset detected

Latest commit: 1cf8e8a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

expect(content).toContain("require(\"fs\");");
} else if (/(bundle1\.mjs|bundle3\.mjs|bundle6\.mjs)$/.test(__filename)) {
expect(content).toContain("from \"url\"");
expect(content).toContain("from \"module\"");
Copy link
Member Author

Choose a reason for hiding this comment

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

We no longer generate import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "node:module; __WEBPACK_EXTERNAL_createRequire("fs")" in this PR.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 18, 2025

This PR is packaged and the instant preview is available (5ac7bf6).

Install it locally:

  • npm
npm i -D webpack@https://pkg.pr.new/webpack@5ac7bf6
  • yarn
yarn add -D webpack@https://pkg.pr.new/webpack@5ac7bf6
  • pnpm
pnpm add -D webpack@https://pkg.pr.new/webpack@5ac7bf6

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 18, 2025

Merging this PR will not alter performance

✅ 72 untouched benchmarks


Comparing node-module-external (1cf8e8a) with main (fd55587)

Open in CodSpeed

@@ -0,0 +1,10 @@
import fs from "fs";
Copy link
Member

Choose a reason for hiding this comment

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

Let's add a test case where we import all Node.js modules (just take them from NodeTargetPlugin and generate a module with require's) just to ensure we can replace require on import for all Node.js modules (It seems like there was a bug with this once, but I could be wrong, let's check it out.)

@hai-x hai-x force-pushed the node-module-external branch 2 times, most recently from cce0ecf to 356f9cb Compare December 27, 2025 20:56
@hai-x hai-x force-pushed the node-module-external branch from 356f9cb to e71315e Compare December 28, 2025 04:34
@alexander-akait alexander-akait merged commit 5ac7bf6 into main Jan 12, 2026
51 of 52 checks passed
@alexander-akait alexander-akait deleted the node-module-external branch January 12, 2026 18:23
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