Skip to content

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

⚠️ No Changeset found

Latest commit: e71315e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a 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 (e71315e).

Install it locally:

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

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 18, 2025

CodSpeed Performance Report

Merging #20255 will not alter performance

Comparing node-module-external (e71315e) with main (d2a124d)

Summary

✅ 72 untouched

@@ -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
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