Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(node-resolve): improve doc related to mainFields #138

Merged
merged 5 commits into from Jan 4, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions packages/node-resolve/README.md
Expand Up @@ -47,40 +47,44 @@ Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#comma
### `mainFields`

Type: `Array[...String]`<br>
Default: `['module', 'main']`
Default: `['module', 'main']`<br>
Valid values: `['browser', 'jsnext', 'module', 'main']`

The fields to scan in a package.json to determine the entry point if this list contains "browser", overrides specified in "pkg.browser" will be used
The fields to scan in a package.json to determine the entry point. Order of fields is significant, first found field would become the resolved entry point. If this list contains "browser", overrides specified in `pkg.browser` will be used.
StreetStrider marked this conversation as resolved.
Show resolved Hide resolved

### `module`

Type: `Boolean`<br>
Default: `true`

DEPRECATED: use "mainFields" instead
Use "module" field for ES6 module if possible

Use `pkg.module` field for ES6 module if possible. This option takes precedence over both "jsnext" and "main" in the list if such are present.
StreetStrider marked this conversation as resolved.
Show resolved Hide resolved

### `jsnext`

Type: `Boolean`<br>
Default: `false`

DEPRECATED: use "mainFields" instead
Use "jsnext:main" if possible, legacy field pointing to ES6 module in third-party libraries, deprecated in favor of "pkg.module", see: https://github.com/rollup/rollup/wiki/pkg.module

Use `pkg['jsnext:main']` if possible, legacy field pointing to ES6 module in third-party libraries, deprecated in favor of `pkg.module`, see: https://github.com/rollup/rollup/wiki/pkg.module. This option takes precedence over "main" in the list if such is present.
StreetStrider marked this conversation as resolved.
Show resolved Hide resolved

### `main`

Type: `Boolean`<br>
Default: `true`

DEPRECATED: use "mainFields" instead
Use "main" field or index.js, even if it's not an ES6 module (needs to be converted from CommonJS to ES6) – see https://github.com/rollup/rollup-plugin-commonjs

Use `pkg.main` field or index.js, even if it's not an ES6 module (needs to be converted from CommonJS to ES6), see https://github.com/rollup/rollup-plugin-commonjs.
StreetStrider marked this conversation as resolved.
Show resolved Hide resolved

### `browser`

Type: `Boolean`<br>
Default: `false`

Some package.json files have a "browser" field which specifies alternative files to load for people bundling for the browser. If that's you, either use this option or add "browser" to the "mainFields" option, otherwise pkg.browser will be ignored
Some package.json files have a `pkg.browser` field which specifies alternative files to load for people bundling for the browser. If that's you, either use this option or add "browser" to the "mainFields" option, otherwise `pkg.browser` will be ignored. This option takes precedence over any other in "mainFields" if such are present.
StreetStrider marked this conversation as resolved.
Show resolved Hide resolved

### `extensions`

Expand Down