Skip to content

Commit 71e6434

Browse files
committed
fix: remove fallback
1 parent 4866c32 commit 71e6434

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/content/configuration/externals.mdx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -574,13 +574,23 @@ async function foo() {
574574

575575
Note that there will be an `import` or `import()` statement in the output bundle.
576576

577-
When a module is not imported via `import` or `import()`, webpack will determine which type of external to use as fallback based on the configuration of [`externalsPresets`](#externalspresets). When one of the previous `externalsPresets` type is enabled, the following `externalsPresets` type will no longer apply. The order is listed below.
577+
When a module is not imported via `import` or `import()`, webpack will use `"module"` externals type as fallback. If you want to use a different type of externals as fallback, you can specify it with a function in the `externals` option. For example:
578578

579-
- When `externalsPresets.web` is `true`, use `module`.
580-
- When `externalsPresets.webAsync` is `true`, use `import`.
581-
- When node.js related (`electron`, `electronMain`, `electronPreload`, `electronRenderer`, `node`, `nwjs`) externalsPresets is true, use `node-commonjs`.
582-
583-
When none of the above `externalsPresets` type is enabled or can be derived, webpack will use `commonjs` as the default type.
579+
```js
580+
module.exports = {
581+
externalsType: "module-import",
582+
externals: [
583+
function (
584+
{ request, dependencyType },
585+
callback
586+
) {
587+
if (dependencyType === "commonjs") {
588+
return callback(null, `node-commonjs ${request}`);
589+
}
590+
callback();
591+
},
592+
]
593+
```
584594
585595
### externalsType.node-commonjs
586596

0 commit comments

Comments
 (0)