Skip to content

Commit 331e064

Browse files
john gravoisEugeneHlushko
authored andcommitted
d3 doesn't include a pkg.browser field anymore (#2739)
1 parent 54b5b4c commit 331e064

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/content/configuration/resolve.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ contributors:
1010
- tbroadley
1111
- byzyk
1212
- numb86
13+
- jgravois
14+
1315
---
1416

1517
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 = {
220222
};
221223
```
222224

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:
224226

225227
```json
226228
{
227-
"main": "build/d3.Node.js",
228-
"browser": "build/d3.js",
229+
"browser": "build/upstream.js",
229230
"module": "index"
230231
}
231232
```
232233

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.
234235

235236

236237
### `resolve.mainFiles`

0 commit comments

Comments
 (0)