You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5d3d043
Browse filesBrowse the repository at this point in the historyBrowse files
* feat: add externalsPresets.nodeModules preset
Externalize installed packages (requests resolving into a node_modules
directory) instead of bundling them, loading them via require()/import at
runtime. Opt-in only; relative/absolute and CSS/url requests are never
treated as package externals. Useful for server-side rendering builds.
* fix: keep package CSS/asset imports bundled under nodeModules preset
Only externalize a request that resolves to a runtime-loadable JS/JSON
file, so a package's stylesheet or asset imported from JS stays bundled
for webpack to process instead of being require()'d/import-ed at runtime.
Also refresh the ecmaVersion browserslist inline snapshots for the new
externalsPresets.nodeModules key.
* feat: add allowlist option to the nodeModules externals preset
Extend externalsPresets.nodeModules to accept `true | { allowlist }`,
where allowlist items are an exact request string, a RegExp, or a
(request) => boolean filter. Matching requests stay bundled while the
rest are externalized, matching webpack-node-externals' allowlist so the
preset is a drop-in built-in replacement.
* docs(changeset): recommend the nodeModules preset over webpack-node-externals
Point users at the built-in preset as the replacement for the
webpack-node-externals plugin, and add the ordering prefix the
changeset naming convention requires.
* fix: keep `#` subpath imports bundled under the nodeModules preset
A `#` specifier only resolves against the importing package's own
`imports` field, so it can never be emitted as an external request. A
bundled package's `#internal` import resolved into node_modules and was
externalized, making node throw MODULE_NOT_FOUND at runtime.
* docs(changeset): tighten the nodeModules preset entry to one sentence
* fix: keep aliased packages bundled under the nodeModules preset
The external keeps the original request, so a `resolve.alias` remapping a
bare request to a different package was externalized under its original
name and loaded the unaliased package at runtime. Externalize only when
the request resolves into the package it names.
* chore: reword a comment cspell rejects
Add the `externalsPresets.nodeModules` preset with an `allowlist` option to externalize installed packages, replacing the `webpack-node-externals` plugin.
* Treat node.js built-in modules like fs, path or vm as external and load them via require() when used.
1723
1723
*/
1724
1724
node?: boolean;
1725
+
/**
1726
+
* Treat installed packages (requests resolving into a 'node_modules' directory) as external and load them via require()/import at runtime instead of bundling them (useful for server-side rendering builds).
1727
+
*/
1728
+
nodeModules?:
1729
+
|boolean
1730
+
|{
1731
+
/**
1732
+
* Keep these requests bundled instead of externalizing them.
Copy file name to clipboardExpand all lines: schemas/WebpackOptions.json
+39Lines changed: 39 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1676,6 +1676,45 @@
1676
1676
"description": "Treat node.js built-in modules like fs, path or vm as external and load them via require() when used.",
1677
1677
"type": "boolean"
1678
1678
},
1679
+
"nodeModules": {
1680
+
"description": "Treat installed packages (requests resolving into a 'node_modules' directory) as external and load them via require()/import at runtime instead of bundling them (useful for server-side rendering builds).",
1681
+
"anyOf": [
1682
+
{
1683
+
"description": "Enable or disable externalizing installed packages.",
1684
+
"type": "boolean"
1685
+
},
1686
+
{
1687
+
"description": "Externalize installed packages with options.",
1688
+
"type": "object",
1689
+
"additionalProperties": false,
1690
+
"properties": {
1691
+
"allowlist": {
1692
+
"description": "Keep these requests bundled instead of externalizing them.",
1693
+
"type": "array",
1694
+
"items": {
1695
+
"description": "A request that should stay bundled.",
1696
+
"anyOf": [
1697
+
{
1698
+
"description": "Requests matching the RegExp stay bundled.",
1699
+
"instanceof": "RegExp",
1700
+
"tsType": "RegExp"
1701
+
},
1702
+
{
1703
+
"description": "An exact request that should stay bundled.",
1704
+
"type": "string"
1705
+
},
1706
+
{
1707
+
"description": "A function returning true for requests that should stay bundled.",
1708
+
"instanceof": "Function",
1709
+
"tsType": "((request: string) => boolean)"
1710
+
}
1711
+
]
1712
+
}
1713
+
}
1714
+
}
1715
+
}
1716
+
]
1717
+
},
1679
1718
"nwjs": {
1680
1719
"description": "Treat NW.js legacy nw.gui module as external and load it via require() when used.",
"description": "Clear all items provided in 'externalsPresets.nodeModules.allowlist' configuration. Keep these requests bundled instead of externalizing them.",
1289
+
"multiple": false,
1290
+
"path": "externalsPresets.nodeModules.allowlist",
1291
+
"type": "reset",
1292
+
},
1293
+
],
1294
+
"description": "Clear all items provided in 'externalsPresets.nodeModules.allowlist' configuration. Keep these requests bundled instead of externalizing them.",
0 commit comments