Skip to content

Commit 5ac7bf6

Browse files
authored
feat: improve rendering node built-in module for ES modules output
1 parent fd55587 commit 5ac7bf6

File tree

5 files changed

+474
-7
lines changed

5 files changed

+474
-7
lines changed

.changeset/twenty-humans-cough.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": minor
3+
---
4+
5+
Improve rendering node built-in modules for ECMA module output.

lib/WebpackOptionsApply.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,7 @@ class WebpackOptionsApply extends OptionsApply {
115115
// Some older versions of Node.js don't support all built-in modules via import, only via `require`,
116116
// but it seems like there shouldn't be a warning here since these versions are rarely used in real applications
117117
new NodeTargetPlugin(
118-
options.output.module &&
119-
compiler.platform.node === null &&
120-
compiler.platform.web === null
121-
? "module-import"
122-
: "node-commonjs"
118+
options.output.module ? "module-import" : "node-commonjs"
123119
).apply(compiler);
124120

125121
// Handle external CSS `@import` and `url()`

0 commit comments

Comments
 (0)