feat: improve rendering node built-in module#20255
Conversation
🦋 Changeset detectedLatest commit: 1cf8e8a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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\""); |
There was a problem hiding this comment.
We no longer generate import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "node:module; __WEBPACK_EXTERNAL_createRequire("fs")" in this PR.
|
This PR is packaged and the instant preview is available (5ac7bf6). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@5ac7bf6
yarn add -D webpack@https://pkg.pr.new/webpack@5ac7bf6
pnpm add -D webpack@https://pkg.pr.new/webpack@5ac7bf6 |
| @@ -0,0 +1,10 @@ | |||
| import fs from "fs"; | |||
There was a problem hiding this comment.
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.)
cce0ecf to
356f9cb
Compare
356f9cb to
e71315e
Compare
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