Skip to content

Commit

Permalink
docs(node-resolve): fix import statements in examples in README.md (#646
Browse files Browse the repository at this point in the history
)

Two of the import statements in examples in the README use the default export, which is incorrect (as demonstrated by the main example at the top of this file).

Co-authored-by: Andrew Powell <shellscape@users.noreply.github.com>
  • Loading branch information
ryami333 and shellscape committed Nov 28, 2020
1 parent 21c51e0 commit ba1fcf9
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/node-resolve/README.md
Expand Up @@ -166,7 +166,7 @@ Since most packages in your node_modules folder are probably legacy CommonJS rat

```js
// rollup.config.js
import resolve from '@rollup/plugin-node-resolve';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';

export default {
Expand All @@ -176,7 +176,7 @@ export default {
format: 'iife',
name: 'MyModule',
},
plugins: [resolve(), commonjs()],
plugins: [nodeResolve(), commonjs()],
};
```

Expand All @@ -186,7 +186,18 @@ By default this plugin will prefer built-ins over local modules, marking them as

See [`preferBuiltins`](#preferbuiltins).

Use a plugin like [rollup-plugin-node-polyfills](https://github.com/ionic-team/rollup-plugin-node-polyfills) to provide stubbed versions of built-ins, and set `preferBuiltins` to `false`.
To provide stubbed versions of Node built-ins, yse a plugin like [rollup-plugin-node-polyfills](https://github.com/ionic-team/rollup-plugin-node-polyfills) or use [`builtin-modules`](https://github.com/sindresorhus/builtin-modules) with `external`, and set `preferBuiltins` to `false`. e.g.

```js
import { nodeResolve } from '@rollup/plugin-node-resolve';
import builtins from 'builtin-modules'
export default ({
input: ...,
plugins: [nodeResolve()],
external: builtins,
output: ...
})
```

## Resolving require statements

Expand Down

0 comments on commit ba1fcf9

Please sign in to comment.