🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@rollup/plugin-node-resolve

Package Overview
Dependencies
Maintainers
4
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rollup/plugin-node-resolve - npm Package Compare versions

Comparing version

to
6.1.0

20

CHANGELOG.md

@@ -1,3 +0,19 @@

# @rollup/plugin-node-resolve Change Log
# @rollup/plugin-node-resolve ChangeLog
## v6.1.0
_2020-01-04_
### Bugfixes
- fix: allow deduplicating custom module dirs (#101)
### Features
- feat: add rootDir option (#98)
### Updates
- docs: improve doc related to mainFields (#138)
## 6.0.0

@@ -7,3 +23,3 @@

- **Breaking:** Minimum compatible Rollup version is 1.2.0
- **Breaking:** Minimum compatible Rollup version is 1.20.0
- **Breaking:** Minimum supported Node version is 8.0.0

@@ -10,0 +26,0 @@ - Published as @rollup/plugin-node-resolve

10

dist/index.es.js

@@ -1,2 +0,2 @@

import { dirname, join, resolve, normalize, sep, extname } from 'path';
import { dirname, resolve, normalize, sep, extname } from 'path';
import fs, { realpathSync } from 'fs';

@@ -169,2 +169,3 @@ import builtinList from 'builtin-modules';

const customResolveOptions = options.customResolveOptions || {};
const rootDir = options.rootDir || process.cwd();
const jail = options.jail;

@@ -314,9 +315,4 @@ const only = Array.isArray(options.only) ? options.only.map(o => o instanceof RegExp ? o : new RegExp(`^${String(o).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&')}$`)) : null;

if (/\0/.test(importee)) return null;
const basedir = importer ? dirname(importer) : process.cwd();
const basedir = !importer || shouldDedupe(importee) ? rootDir : dirname(importer); // https://github.com/defunctzombie/package-browser-field-spec
if (shouldDedupe(importee)) {
importee = join(process.cwd(), 'node_modules', importee);
} // https://github.com/defunctzombie/package-browser-field-spec
const browser = browserMapCache.get(importer);

@@ -323,0 +319,0 @@

@@ -174,2 +174,3 @@ 'use strict';

const customResolveOptions = options.customResolveOptions || {};
const rootDir = options.rootDir || process.cwd();
const jail = options.jail;

@@ -319,9 +320,4 @@ const only = Array.isArray(options.only) ? options.only.map(o => o instanceof RegExp ? o : new RegExp(`^${String(o).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&')}$`)) : null;

if (/\0/.test(importee)) return null;
const basedir = importer ? path.dirname(importer) : process.cwd();
const basedir = !importer || shouldDedupe(importee) ? rootDir : path.dirname(importer); // https://github.com/defunctzombie/package-browser-field-spec
if (shouldDedupe(importee)) {
importee = path.join(process.cwd(), 'node_modules', importee);
} // https://github.com/defunctzombie/package-browser-field-spec
const browser = browserMapCache.get(importer);

@@ -328,0 +324,0 @@

{
"name": "@rollup/plugin-node-resolve",
"version": "6.0.0",
"version": "6.1.0",
"publishConfig": {

@@ -11,3 +11,3 @@ "access": "public"

"author": "Rich Harris <richard.a.harris@gmail.com>",
"homepage": "https://github.com/rollup/plugins/packages/node-resolve/#readme",
"homepage": "https://github.com/rollup/plugins/tree/master/packages/node-resolve/#readme",
"bugs": "https://github.com/rollup/plugins/issues",

@@ -21,3 +21,3 @@ "main": "dist/index.js",

"ci:coverage": "nyc pnpm run test && nyc report --reporter=text-lcov > coverage.lcov",
"ci:lint": "pnpm run build && pnpm run lint && pnpm run security",
"ci:lint": "pnpm run build && pnpm run lint",
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",

@@ -33,3 +33,2 @@ "ci:test": "pnpm run test -- --verbose && pnpm run test:ts",

"pretest": "pnpm run build",
"security": "echo 'pnpm needs `npm audit` support'",
"test": "ava",

@@ -80,5 +79,4 @@ "test:ts": "tsc types/index.d.ts test/types.ts --noEmit"

},
"jsnext:main": "dist/index.es.js",
"module": "dist/index.es.js",
"types": "types/index.d.ts"
}

@@ -49,31 +49,26 @@ [npm]: https://img.shields.io/npm/v/@rollup/plugin-node-resolve

Type: `Array[String]`<br>
Default: `['module', 'main']`
Type: `Array[...String]`<br>
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
Specifies the properties to scan within a `package.json`, used to determine the bundle entry point. The order of property names is significant, as the first-found property is used as the resolved entry point. If the array contains `'browser'`, key/values specified in the `package.json` `browser` property will be used.
### `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.
### `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.
### `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.
### `browser`

@@ -84,7 +79,7 @@

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
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 bundling for a browser environment. Alternatively, a value of `'browser'` can be added to the `mainFields` option. If `false`, any `"browser"` properties in package files will be ignored. This option takes precedence over `mainFields`.
### `extensions`
Type: `Array[String]`<br>
Type: `Array[...String]`<br>
Default: `['.mjs', '.js', '.json', '.node']`

@@ -110,3 +105,3 @@

Type: `Array[String|RegExp]`<br>
Type: `Array[...String|RegExp]`<br>
Default: `null`

@@ -125,3 +120,3 @@

Type: `Array[String]`<br>
Type: `Array[...String]`<br>
Default: `[]`

@@ -148,10 +143,22 @@

## Using with rollup-plugin-commonjs
### `rootDir`
Since most packages in your node_modules folder are probably legacy CommonJS rather than JavaScript modules, you may need to use [rollup-plugin-commonjs](https://github.com/rollup/rollup-plugin-commonjs):
Type: `String`<br>
Default: `process.cwd()`
Root directory to resolve modules from. Used when resolving entrypoint imports, and when resolving deduplicated modules. Useful when executing rollup in a package of a monorepository.
```
// Set the root directory to be the parent folder
rootDir: path.join(process.cwd(), '..')
```
## Using with @rollup/plugin-commonjs
Since most packages in your node_modules folder are probably legacy CommonJS rather than JavaScript modules, you may need to use [@rollup/plugin-commonjs](https://github.com/rollup/plugins/packages/commonjs):
```js
// rollup.config.js
import resolve from '@rollup/plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import commonjs from '@rollup/plugin-commonjs';

@@ -158,0 +165,0 @@ export default {

@@ -95,2 +95,10 @@ import { Plugin } from 'rollup';

customResolveOptions?: AsyncOpts;
/**
* Root directory to resolve modules from. Used when resolving entrypoint imports,
* and when resolving deduplicated modules. Useful when executing rollup in a package
* of a monorepository.
* @default process.cwd()
*/
rootDir?: string;
}

@@ -97,0 +105,0 @@