Skip to content

Commit

Permalink
feat(node-resolve): Add default export
Browse files Browse the repository at this point in the history
BREAKING CHANGES: Change the TypeScript options interface name
  • Loading branch information
NotWoods committed May 1, 2020
1 parent 96e0900 commit ce8fed8
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 19 deletions.
6 changes: 3 additions & 3 deletions packages/alias/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ Example:
```javascript
// rollup.config.js
import alias from '@rollup/plugin-alias';
import resolve from '@rollup/plugin-node-resolve';
import { nodeResolve } from '@rollup/plugin-node-resolve';

const customResolver = resolve({
const customResolver = nodeResolve({
extensions: ['.mjs', '.js', '.jsx', '.json', '.sass', '.scss']
});
const projectRootDir = path.resolve(__dirname);
Expand All @@ -160,7 +160,7 @@ export default {
],
customResolver
}),
resolve()
nodeResolve()
]
};
```
Expand Down
4 changes: 2 additions & 2 deletions packages/auto-install/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/

```js
import auto from '@rollup/plugin-auto-install';
import resolve from '@rollup/plugin-node-resolve';
import { nodeResolve } from '@rollup/plugin-node-resolve';

export default {
input: 'src/index.js',
output: {
dir: 'output',
format: 'cjs'
},
plugins: [auto(), resolve()]
plugins: [auto(), nodeResolve()]
};
```

Expand Down
4 changes: 2 additions & 2 deletions packages/commonjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Since most CommonJS packages you are importing are probably dependencies in `nod

```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 @@ -129,7 +129,7 @@ export default {
format: 'iife',
name: 'MyModule'
},
plugins: [resolve(), commonjs()]
plugins: [nodeResolve(), commonjs()]
};
```

Expand Down
12 changes: 6 additions & 6 deletions packages/node-resolve/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ npm install @rollup/plugin-node-resolve --save-dev
Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:

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

export default {
input: 'src/index.js',
output: {
dir: 'output',
format: 'cjs'
},
plugins: [resolve()]
plugins: [nodeResolve()]
};
```

Expand Down Expand Up @@ -156,7 +156,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 @@ -166,7 +166,7 @@ export default {
format: 'iife',
name: 'MyModule'
},
plugins: [resolve(), commonjs()]
plugins: [nodeResolve(), commonjs()]
};
```

Expand All @@ -177,11 +177,11 @@ This plugin won't resolve any builtins (e.g. `fs`). If you need to resolve built
If you want to silence warnings about builtins, you can add the list of builtins to the `externals` option; like so:

```js
import resolve from '@rollup/plugin-node-resolve';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import builtins from 'builtin-modules'
export default ({
input: ...,
plugins: [resolve()],
plugins: [nodeResolve()],
external: builtins,
output: ...
})
Expand Down
6 changes: 4 additions & 2 deletions packages/node-resolve/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const defaults = {
};
export const DEFAULTS = deepFreeze(deepMerge({}, defaults));

export const nodeResolve = (opts = {}) => {
export function nodeResolve(opts = {}) {
const options = Object.assign({}, defaults, opts);
const { customResolveOptions, extensions, jail } = options;
const warnings = [];
Expand Down Expand Up @@ -258,4 +258,6 @@ export const nodeResolve = (opts = {}) => {
return idToPackageInfo.get(id);
}
};
};
}

export default nodeResolve;
5 changes: 3 additions & 2 deletions packages/node-resolve/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const DEFAULTS: {
resolveOnly: [];
};

export interface Options {
export interface RollupNodeResolveOptions {
/**
* If `true`, instructs the plugin to use the `"browser"` property in `package.json`
* files to specify alternative files to load for bundling. This is useful when
Expand Down Expand Up @@ -88,4 +88,5 @@ export interface Options {
/**
* Locate modules using the Node resolution algorithm, for using third party modules in node_modules
*/
export const nodeResolve: (options?: Options) => Plugin;
export function nodeResolve(options?: RollupNodeResolveOptions): Plugin;
export default nodeResolve;
4 changes: 2 additions & 2 deletions packages/sucrase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/

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

export default {
input: 'src/index.ts',
Expand All @@ -38,7 +38,7 @@ export default {
format: 'cjs'
},
plugins: [
resolve({
nodeResolve({
extensions: ['.js', '.ts']
}),
sucrase({
Expand Down

0 comments on commit ce8fed8

Please sign in to comment.