Skip to content

Commit 29a504f

Browse files
author
Stephan Septh Schreiber
committed
Update readme
1 parent 564f0f5 commit 29a504f

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

README.md

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ A Rollup plugin that automatically declares NodeJS built-in modules as `external
66

77
By default, Rollup doesn't know a thing about NodeJS, so using simple things like `import * as path from 'path'` in your code generates an `Unresolved dependencies` error. The solution here is twofold, depending on what you're building:
88
* If building a *standalone app*, e.g. for the browser, you'll need to use some kind of shim like those provided by [rollup-plugin-node-builtins](https://github.com/calvinmetcalf/rollup-plugin-node-builtins).
9-
* If building *an npm module or lib*, you'll need to tell Rollup that the `path` module is in fact `external`: this way, Rollup won't try to bundle the module in, but simply leave the `import` statement as is (or translate it to a `require()` call if bundling for CommonJS).
9+
* If building *an npm module or lib*, you'll need to tell Rollup that the `path` module is in fact `external`: this way, Rollup won't try to bundle the module in and rather leave the `import` statement as is (or translate it to a `require()` call if bundling for CommonJS).
1010

1111
However, this must be done for each and every NodeJS built-in: `path`, `os`, `fs`, etc., which can quicky become cumbersome when done manually. So the primary goal of this plugin is simply to automatically declare all NodeJS built-in modules as `external`.
1212

13-
This plugin will also allow you, should you need it, to declare your dependencies (as declared in your `package.json` file) as `external`. This may come in handy when building an [Electron](https://electronjs.org/) app, for example.
13+
This plugin will also allow you to declare your dependencies (as declared in your `package.json` file) as `external`. This may come in handy when building an [Electron](https://electronjs.org) app, for example.
1414

1515

1616
## Install
@@ -25,21 +25,36 @@ npm install --save-dev rollup-plugin-node-externals
2525
```js
2626
import externals from 'rollup-plugin-node-externals'
2727

28-
const packagePath = 'path/to/package.json' // Optional, useful in monorepos
29-
3028
export default {
3129
// ...
3230
plugins: [
3331
externals({
34-
packagePath, // The path to your package.json (default: process.cwd() which is usally the same dir where rollup.config.js stands)
35-
builtins: true, // make node builtins external (default: true)
36-
deps: true, // make pkg.dependencies external (default: false)
37-
devDeps: true, // make pkg.devDependencies external (default: true)
38-
peerDeps: true, // make pkg.peerDependencies external (default: true)
39-
optDeps: true, // make pkg.optionalDependencies external (default: true)
40-
exclude: [], // deps to exclude from externals (default: [])
41-
include: [], // deps to include in externals (default: [])
42-
except: [] // deprecated -- see below
32+
// The path to your package.json. Optional. Default: process.cwd() which is usally the same dir where rollup.config.js stands
33+
packagePath: 'path/to/package.json',
34+
35+
// Make node built-ins external. Optional. Default: true
36+
builtins: true,
37+
38+
// Make pkg.dependencies external. Optional. Default: false
39+
deps: false,
40+
41+
// Make pkg.peerDependencies external. Optional. Default: true
42+
peerDeps: true,
43+
44+
// Make pkg.optionalDependencies external. Optional. Default: true
45+
optDeps: true,
46+
47+
// Make pkg.devDependencies external. Optional. Default: true
48+
devDeps: true,
49+
50+
// Modules to exclude from externals. Optional. Default: none
51+
exclude: [],
52+
53+
// Modules to include in externals. Optional. Default: all
54+
include: [],
55+
56+
// Deprecated -- see below
57+
except: []
4358
})
4459
]
4560
}
@@ -53,7 +68,7 @@ import externals from 'rollup-plugin-node-externals'
5368
export default {
5469
// ...
5570
plugins: [
56-
externals(), // Bundle deps in; make Node builtins, devDeps, peerDeps and optDeps external
71+
externals(), // Bundle deps in; make Node built-ins, devDeps, peerDeps and optDeps external
5772
]
5873
}
5974
```

0 commit comments

Comments
 (0)