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
Copy file name to clipboardExpand all lines: src/content/configuration/resolve.md
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,8 @@ contributors:
10
10
- tbroadley
11
11
- byzyk
12
12
- numb86
13
+
- jgravois
14
+
13
15
---
14
16
15
17
These options change how modules are resolved. webpack provides reasonable defaults, but it is possible to change the resolving in detail. Have a look at [Module Resolution](/concepts/module-resolution) for more explanation of how the resolver works.
@@ -220,17 +222,16 @@ module.exports = {
220
222
};
221
223
```
222
224
223
-
For example, the `package.json`of [D3](https://d3js.org/)contains these fields:
225
+
For example, consider an arbitrary library called `upstream` with a `package.json`that contains the following fields:
224
226
225
227
```json
226
228
{
227
-
"main": "build/d3.Node.js",
228
-
"browser": "build/d3.js",
229
+
"browser": "build/upstream.js",
229
230
"module": "index"
230
231
}
231
232
```
232
233
233
-
This means that when we `import * as D3 from "d3"` this will really resolve to the file in the `browser` property. The `browser` property takes precedence here because it's the first item in `mainFields`. Meanwhile, a Node.js application bundled by webpack will resolve by default to the file in the `module` field.
234
+
When we `import * as Upstream from "upstream"` this will actually resolve to the file in the `browser` property. The `browser` property takes precedence because it's the first item in `mainFields`. Meanwhile, a Node.js application bundled by webpack will first try to resolve using the file in the `module` field.
0 commit comments