Skip to content

Commit a280adb

Browse files
authored
docs(configuration): document resolve.fullySpecified (webpack#3981)
1 parent 010290d commit a280adb

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/content/configuration/module.mdx

+25
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,31 @@ module.exports = {
693693

694694
When creating a bundle with updated configuration, `console.log(footer)` will output 'overridden footer'.
695695

696+
### `resolve.fullySpecified`
697+
698+
`boolean = true`
699+
700+
When enabled, you should provide the file extension when `import`ing a module in `.mjs` files or any other `.js` files when their nearest parent `package.json` file contains a `"type"` field with a value of `"module"`, otherwise webpack would fail the compiling with a `Module not found` error. And webpack won't resolve directories with filenames defined in the [`resolve.mainFiles`](/configuration/resolve/#resolvemainfiles), you have to specify the filename yourself.
701+
702+
__webpack.config.js__
703+
704+
```js
705+
module.exports = {
706+
// ...
707+
module: {
708+
rules: [
709+
{
710+
test: /\.m?js/,
711+
resolve: {
712+
fullySpecified: false // disable the behaviour
713+
}
714+
}
715+
]
716+
}
717+
};
718+
```
719+
720+
W> `resolve.fullySpecified` doesn't affect requests from [mainFields](/configuration/resolve/#resolvemainfields), [aliasFields](/configuration/resolve/#resolvealiasfields) or [aliases](/configuration/resolve/#resolvealias).
696721

697722
## `Condition`
698723

0 commit comments

Comments
 (0)