0.2.0 - Mid migration

This commit is contained in:
Daniel Mason 2022-04-25 14:47:15 +12:00
parent 139e6a915e
commit 7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions

270
web/node_modules/@rollup/plugin-node-resolve/CHANGELOG.md generated vendored Executable file
View file

@ -0,0 +1,270 @@
# @rollup/plugin-node-resolve ChangeLog
## v7.1.3
_2020-04-12_
### Bugfixes
- fix: resolve symlinked entry point properly (#291)
## v7.1.2
_2020-04-12_
### Updates
- docs: fix url (#289)
## v7.1.1
_2020-02-03_
### Bugfixes
- fix: main fields regression (#196)
## v7.1.0
_2020-02-01_
### Updates
- refactor: clean codebase and fix external warnings (#155)
## v7.0.0
_2020-01-07_
### Breaking Changes
- feat: dedupe by package name (#99)
## 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
_2019-11-25_
- **Breaking:** Minimum compatible Rollup version is 1.20.0
- **Breaking:** Minimum supported Node version is 8.0.0
- Published as @rollup/plugin-node-resolve
## 5.2.1 (unreleased)
- add missing MIT license file ([#233](https://github.com/rollup/rollup-plugin-node-resolve/pull/233) by @kenjiO)
- Fix incorrect example of config ([#239](https://github.com/rollup/rollup-plugin-node-resolve/pull/240) by @myshov)
- Fix typo in readme ([#240](https://github.com/rollup/rollup-plugin-node-resolve/pull/240) by @LinusU)
## 5.2.0 (2019-06-29)
- dedupe accepts a function ([#225](https://github.com/rollup/rollup-plugin-node-resolve/pull/225) by @manucorporat)
## 5.1.1 (2019-06-29)
- Move Rollup version check to buildStart hook to avoid issues ([#232](https://github.com/rollup/rollup-plugin-node-resolve/pull/232) by @lukastaegert)
## 5.1.0 (2019-06-22)
- Fix path fragment inputs ([#229](https://github.com/rollup/rollup-plugin-node-resolve/pull/229) by @bterlson)
## 5.0.4 (2019-06-22)
- Treat sideEffects array as inclusion list ([#227](https://github.com/rollup/rollup-plugin-node-resolve/pull/227) by @mikeharder)
## 5.0.3 (2019-06-16)
- Make empty.js a virtual module ([#224](https://github.com/rollup/rollup-plugin-node-resolve/pull/224) by @manucorporat)
## 5.0.2 (2019-06-13)
- Support resolve 1.11.1, add built-in test ([#223](https://github.com/rollup/rollup-plugin-node-resolve/pull/223) by @bterlson)
## 5.0.1 (2019-05-31)
- Update to resolve@1.11.0 for better performance ([#220](https://github.com/rollup/rollup-plugin-node-resolve/pull/220) by @keithamus)
## 5.0.0 (2019-05-15)
- Replace bublé with babel, update dependencies ([#216](https://github.com/rollup/rollup-plugin-node-resolve/pull/216) by @mecurc)
- Handle module side-effects ([#219](https://github.com/rollup/rollup-plugin-node-resolve/pull/219) by @lukastaegert)
### Breaking Changes
- Requires at least rollup@1.11.0 to work (v1.12.0 for module side-effects to be respected)
- If used with rollup-plugin-commonjs, it should be at least v10.0.0
## 4.2.4 (2019-05-11)
- Add note on builtins to Readme ([#215](https://github.com/rollup/rollup-plugin-node-resolve/pull/215) by @keithamus)
- Add issue templates ([#217](https://github.com/rollup/rollup-plugin-node-resolve/pull/217) by @mecurc)
- Improve performance by caching `isDir` ([#218](https://github.com/rollup/rollup-plugin-node-resolve/pull/218) by @keithamus)
## 4.2.3 (2019-04-11)
- Fix ordering of jsnext:main when using the jsnext option ([#209](https://github.com/rollup/rollup-plugin-node-resolve/pull/209) by @lukastaegert)
## 4.2.2 (2019-04-10)
- Fix TypeScript typings (rename and export Options interface) ([#206](https://github.com/rollup/rollup-plugin-node-resolve/pull/206) by @Kocal)
- Fix mainfields typing ([#207](https://github.com/rollup/rollup-plugin-node-resolve/pull/207) by @nicolashenry)
## 4.2.1 (2019-04-06)
- Respect setting the deprecated fields "module", "main", and "jsnext" ([#204](https://github.com/rollup/rollup-plugin-node-resolve/pull/204) by @nick-woodward)
## 4.2.0 (2019-04-06)
- Add new mainfields option ([#182](https://github.com/rollup/rollup-plugin-node-resolve/pull/182) by @keithamus)
- Added dedupe option to prevent bundling the same package multiple times ([#201](https://github.com/rollup/rollup-plugin-node-resolve/pull/182) by @sormy)
## 4.1.0 (2019-04-05)
- Add TypeScript typings ([#189](https://github.com/rollup/rollup-plugin-node-resolve/pull/189) by @NotWoods)
- Update dependencies ([#202](https://github.com/rollup/rollup-plugin-node-resolve/pull/202) by @lukastaegert)
## 4.0.1 (2019-02-22)
- Fix issue when external modules are specified in `package.browser` ([#143](https://github.com/rollup/rollup-plugin-node-resolve/pull/143) by @keithamus)
- Fix `package.browser` mapping issue when `false` is specified ([#183](https://github.com/rollup/rollup-plugin-node-resolve/pull/183) by @allex)
## 4.0.0 (2018-12-09)
This release will support rollup@1.0
### Features
- Resolve modules used to define manual chunks ([#185](https://github.com/rollup/rollup-plugin-node-resolve/pull/185) by @mcshaman)
- Update dependencies and plugin hook usage ([#187](https://github.com/rollup/rollup-plugin-node-resolve/pull/187) by @lukastaegert)
## 3.4.0 (2018-09-04)
This release now supports `.mjs` files by default
### Features
- feat: Support .mjs files by default (https://github.com/rollup/rollup-plugin-node-resolve/pull/151, by @leebyron)
## 3.3.0 (2018-03-17)
This release adds the `only` option
### New Features
- feat: add `only` option (#83; @arantes555)
### Docs
- docs: correct description of `jail` option (#120; @GeorgeTaveras1231)
## 3.2.0 (2018-03-07)
This release caches reading/statting of files, to improve speed.
### Performance Improvements
- perf: cache file stats/reads (#126; @keithamus)
## 3.0.4 (unreleased)
- Update lockfile [#137](https://github.com/rollup/rollup-plugin-node-resolve/issues/137)
- Update rollup dependency [#138](https://github.com/rollup/rollup-plugin-node-resolve/issues/138)
- Enable installation from Github [#142](https://github.com/rollup/rollup-plugin-node-resolve/issues/142)
## 3.0.3
- Fix [#130](https://github.com/rollup/rollup-plugin-node-resolve/issues/130) and [#131](https://github.com/rollup/rollup-plugin-node-resolve/issues/131)
## 3.0.2
- Ensure `pkg.browser` is an object if necessary ([#129](https://github.com/rollup/rollup-plugin-node-resolve/pull/129))
## 3.0.1
- Remove `browser-resolve` dependency ([#127](https://github.com/rollup/rollup-plugin-node-resolve/pull/127))
## 3.0.0
- [BREAKING] Remove `options.skip` ([#90](https://github.com/rollup/rollup-plugin-node-resolve/pull/90))
- Add `modulesOnly` option ([#96](https://github.com/rollup/rollup-plugin-node-resolve/pull/96))
## 2.1.1
- Prevent `jail` from breaking builds on Windows ([#93](https://github.com/rollup/rollup-plugin-node-resolve/issues/93))
## 2.1.0
- Add `jail` option ([#53](https://github.com/rollup/rollup-plugin-node-resolve/pull/53))
- Add `customResolveOptions` option ([#79](https://github.com/rollup/rollup-plugin-node-resolve/pull/79))
- Support symlinked packages ([#82](https://github.com/rollup/rollup-plugin-node-resolve/pull/82))
## 2.0.0
- Add support `module` field in package.json as an official alternative to jsnext
## 1.7.3
- Error messages are more descriptive ([#50](https://github.com/rollup/rollup-plugin-node-resolve/issues/50))
## 1.7.2
- Allow entry point paths beginning with ./
## 1.7.1
- Return a `name`
## 1.7.0
- Allow relative IDs to be external ([#32](https://github.com/rollup/rollup-plugin-node-resolve/pull/32))
## 1.6.0
- Skip IDs containing null character
## 1.5.0
- Prefer built-in options, but allow opting out ([#28](https://github.com/rollup/rollup-plugin-node-resolve/pull/28))
## 1.4.0
- Pass `options.extensions` through to `node-resolve`
## 1.3.0
- `skip: true` skips all packages that don't satisfy the `main` or `jsnext` options ([#16](https://github.com/rollup/rollup-plugin-node-resolve/pull/16))
## 1.2.1
- Support scoped packages in `skip` option ([#15](https://github.com/rollup/rollup-plugin-node-resolve/issues/15))
## 1.2.0
- Support `browser` field ([#8](https://github.com/rollup/rollup-plugin-node-resolve/issues/8))
- Get tests to pass on Windows
## 1.1.0
- Use node-resolve to handle various corner cases
## 1.0.0
- Add ES6 build, use Rollup 0.20.0
## 0.1.0
- First release

21
web/node_modules/@rollup/plugin-node-resolve/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

194
web/node_modules/@rollup/plugin-node-resolve/README.md generated vendored Executable file
View file

@ -0,0 +1,194 @@
[npm]: https://img.shields.io/npm/v/@rollup/plugin-node-resolve
[npm-url]: https://www.npmjs.com/package/@rollup/plugin-node-resolve
[size]: https://packagephobia.now.sh/badge?p=@rollup/plugin-node-resolve
[size-url]: https://packagephobia.now.sh/result?p=@rollup/plugin-node-resolve
[![npm][npm]][npm-url]
[![size][size]][size-url]
[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)
# @rollup/plugin-node-resolve
🍣 A Rollup plugin which locates modules using the [Node resolution algorithm](https://nodejs.org/api/modules.html#modules_all_together), for using third party modules in `node_modules`
## Requirements
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v8.0.0+) and Rollup v1.20.0+.
## Install
Using npm:
```console
npm install @rollup/plugin-node-resolve --save-dev
```
## Usage
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';
export default {
input: 'src/index.js',
output: {
dir: 'output',
format: 'cjs'
},
plugins: [resolve()]
};
```
Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api).
## Options
### `browser`
Type: `Boolean`<br>
Default: `false`
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`.
### `customResolveOptions`
Type: `Object`<br>
Default: `null`
An `Object` that specifies additional options that should be passed through to [`resolve`](https://www.npmjs.com/package/resolve).
```
customResolveOptions: {
moduleDirectory: 'js_modules'
}
```
### `dedupe`
Type: `Array[...String]`<br>
Default: `[]`
An `Array` of modules names, which instructs the plugin to force resolving for the specified modules to the root `node_modules`. Helps to prevent bundling the same package multiple times if package is imported from dependencies.
```js
dedupe: ['my-package', '@namespace/my-package'];
```
This will deduplicate bare imports such as:
```js
import 'my-package';
import '@namespace/my-package';
```
And it will deduplicate deep imports such as:
```js
import 'my-package/foo.js';
import '@namespace/my-package/bar.js';
```
### `extensions`
Type: `Array[...String]`<br>
Default: `['.mjs', '.js', '.json', '.node']`
Specifies the extensions of files that the plugin will operate on.
### `jail`
Type: `String`<br>
Default: `'/'`
Locks the module search within specified path (e.g. chroot). Modules defined outside this path will be marked as external.
### `mainFields`
Type: `Array[...String]`<br>
Default: `['module', 'main']`<br>
Valid values: `['browser', 'jsnext', 'module', 'main']`
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.
### `only`
DEPRECATED: use "resolveOnly" instead
### `preferBuiltins`
Type: `Boolean`<br>
Default: `true`
If `true`, the plugin will prefer built-in modules (e.g. `fs`, `path`). If `false`, the plugin will look for locally installed modules of the same name.
### `modulesOnly`
Type: `Boolean`<br>
Default: `false`
If `true`, inspect resolved files to assert that they are ES2015 modules.
### `resolveOnly`
Type: `Array[...String|RegExp]`<br>
Default: `null`
An `Array` which instructs the plugin to limit module resolution to those whose names match patterns in the array. _Note: Modules not matching any patterns will be marked as external._
Example: `resolveOnly: ['batman', /^@batcave\/.*$/]`
### `rootDir`
Type: `String`<br>
Default: `process.cwd()`
Specifies the root directory from which to resolve modules. Typically used when resolving entry-point imports, and when resolving deduplicated modules. Useful when executing rollup in a package of a mono-repository.
```
// 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/tree/master/packages/commonjs):
```js
// rollup.config.js
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
export default {
input: 'main.js',
output: {
file: 'bundle.js',
format: 'iife',
name: 'MyModule'
},
plugins: [resolve(), commonjs()]
};
```
## Resolving Built-Ins (like `fs`)
This plugin won't resolve any builtins (e.g. `fs`). If you need to resolve builtins you can install local modules and set `preferBuiltins` to `false`, or install a plugin like [rollup-plugin-node-polyfills](https://github.com/ionic-team/rollup-plugin-node-polyfills) which provides stubbed versions of these methods.
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 builtins from 'builtin-modules'
export default ({
input: ...,
plugins: [resolve()],
external: builtins,
output: ...
})
```
## Meta
[CONTRIBUTING](/.github/CONTRIBUTING.md)
[LICENSE (MIT)](/LICENSE)

View file

@ -0,0 +1,585 @@
import { dirname, resolve, extname, normalize, sep } from 'path';
import builtinList from 'builtin-modules';
import isModule from 'is-module';
import fs, { realpathSync } from 'fs';
import { promisify } from 'util';
import { createFilter } from '@rollup/pluginutils';
import resolveModule from 'resolve';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
const exists = promisify(fs.exists);
const readFile = promisify(fs.readFile);
const realpath = promisify(fs.realpath);
const stat = promisify(fs.stat);
const onError = error => {
if (error.code === 'ENOENT') {
return false;
}
throw error;
};
const makeCache = fn => {
const cache = new Map();
const wrapped =
/*#__PURE__*/
function () {
var _ref = _asyncToGenerator(function* (param, done) {
if (cache.has(param) === false) {
cache.set(param, fn(param).catch(err => {
cache.delete(param);
throw err;
}));
}
try {
const result = cache.get(param);
const value = yield result;
return done(null, value);
} catch (error) {
return done(error);
}
});
return function wrapped(_x, _x2) {
return _ref.apply(this, arguments);
};
}();
wrapped.clear = () => cache.clear();
return wrapped;
};
const isDirCached = makeCache(
/*#__PURE__*/
function () {
var _ref2 = _asyncToGenerator(function* (file) {
try {
const stats = yield stat(file);
return stats.isDirectory();
} catch (error) {
return onError(error);
}
});
return function (_x3) {
return _ref2.apply(this, arguments);
};
}());
const isFileCached = makeCache(
/*#__PURE__*/
function () {
var _ref3 = _asyncToGenerator(function* (file) {
try {
const stats = yield stat(file);
return stats.isFile();
} catch (error) {
return onError(error);
}
});
return function (_x4) {
return _ref3.apply(this, arguments);
};
}());
const readCachedFile = makeCache(readFile);
const resolveId = promisify(resolveModule); // returns the imported package name for bare module imports
function getPackageName(id) {
if (id.startsWith('.') || id.startsWith('/')) {
return null;
}
const split = id.split('/'); // @my-scope/my-package/foo.js -> @my-scope/my-package
// @my-scope/my-package -> @my-scope/my-package
if (split[0][0] === '@') {
return `${split[0]}/${split[1]}`;
} // my-package/foo.js -> my-package
// my-package -> my-package
return split[0];
}
function getMainFields(options) {
let mainFields;
if (options.mainFields) {
mainFields = options.mainFields;
} else {
mainFields = ['module', 'main'];
}
if (options.browser && mainFields.indexOf('browser') === -1) {
return ['browser'].concat(mainFields);
}
if (!mainFields.length) {
throw new Error('Please ensure at least one `mainFields` value is specified');
}
return mainFields;
}
function getPackageInfo(options) {
const cache = options.cache,
extensions = options.extensions,
pkg = options.pkg,
mainFields = options.mainFields,
preserveSymlinks = options.preserveSymlinks,
useBrowserOverrides = options.useBrowserOverrides;
let pkgPath = options.pkgPath;
if (cache.has(pkgPath)) {
return cache.get(pkgPath);
} // browserify/resolve doesn't realpath paths returned in its packageFilter callback
if (!preserveSymlinks) {
pkgPath = realpathSync(pkgPath);
}
const pkgRoot = dirname(pkgPath);
const packageInfo = {
// copy as we are about to munge the `main` field of `pkg`.
packageJson: Object.assign({}, pkg),
// path to package.json file
packageJsonPath: pkgPath,
// directory containing the package.json
root: pkgRoot,
// which main field was used during resolution of this module (main, module, or browser)
resolvedMainField: 'main',
// whether the browser map was used to resolve the entry point to this module
browserMappedMain: false,
// the entry point of the module with respect to the selected main field and any
// relevant browser mappings.
resolvedEntryPoint: ''
};
let overriddenMain = false;
for (let i = 0; i < mainFields.length; i++) {
const field = mainFields[i];
if (typeof pkg[field] === 'string') {
pkg.main = pkg[field];
packageInfo.resolvedMainField = field;
overriddenMain = true;
break;
}
}
const internalPackageInfo = {
cachedPkg: pkg,
hasModuleSideEffects: () => null,
hasPackageEntry: overriddenMain !== false || mainFields.indexOf('main') !== -1,
packageBrowserField: useBrowserOverrides && typeof pkg.browser === 'object' && Object.keys(pkg.browser).reduce((browser, key) => {
let resolved = pkg.browser[key];
if (resolved && resolved[0] === '.') {
resolved = resolve(pkgRoot, resolved);
}
/* eslint-disable no-param-reassign */
browser[key] = resolved;
if (key[0] === '.') {
const absoluteKey = resolve(pkgRoot, key);
browser[absoluteKey] = resolved;
if (!extname(key)) {
extensions.reduce((subBrowser, ext) => {
subBrowser[absoluteKey + ext] = subBrowser[key];
return subBrowser;
}, browser);
}
}
return browser;
}, {}),
packageInfo
};
const browserMap = internalPackageInfo.packageBrowserField;
if (useBrowserOverrides && typeof pkg.browser === 'object' && // eslint-disable-next-line no-prototype-builtins
browserMap.hasOwnProperty(pkg.main)) {
packageInfo.resolvedEntryPoint = browserMap[pkg.main];
packageInfo.browserMappedMain = true;
} else {
// index.node is technically a valid default entrypoint as well...
packageInfo.resolvedEntryPoint = resolve(pkgRoot, pkg.main || 'index.js');
packageInfo.browserMappedMain = false;
}
const packageSideEffects = pkg.sideEffects;
if (typeof packageSideEffects === 'boolean') {
internalPackageInfo.hasModuleSideEffects = () => packageSideEffects;
} else if (Array.isArray(packageSideEffects)) {
internalPackageInfo.hasModuleSideEffects = createFilter(packageSideEffects, null, {
resolve: pkgRoot
});
}
cache.set(pkgPath, internalPackageInfo);
return internalPackageInfo;
}
function normalizeInput(input) {
if (Array.isArray(input)) {
return input;
} else if (typeof input === 'object') {
return Object.values(input);
} // otherwise it's a string
return input;
} // Resolve module specifiers in order. Promise resolves to the first module that resolves
// successfully, or the error that resulted from the last attempted module resolution.
function resolveImportSpecifiers(importSpecifierList, resolveOptions) {
let promise = Promise.resolve();
for (let i = 0; i < importSpecifierList.length; i++) {
promise = promise.then(value => {
// if we've already resolved to something, just return it.
if (value) {
return value;
}
return resolveId(importSpecifierList[i], resolveOptions).then(result => {
if (!resolveOptions.preserveSymlinks) {
result = realpathSync(result);
}
return result;
});
});
if (i < importSpecifierList.length - 1) {
// swallow MODULE_NOT_FOUND errors from all but the last resolution
promise = promise.catch(error => {
if (error.code !== 'MODULE_NOT_FOUND') {
throw error;
}
});
}
}
return promise;
}
const builtins = new Set(builtinList);
const ES6_BROWSER_EMPTY = '\0node-resolve:empty.js';
const nullFn = () => null;
const defaults = {
customResolveOptions: {},
dedupe: [],
// It's important that .mjs is listed before .js so that Rollup will interpret npm modules
// which deploy both ESM .mjs and CommonJS .js files as ESM.
extensions: ['.mjs', '.js', '.json', '.node'],
resolveOnly: []
};
function nodeResolve(opts = {}) {
const options = Object.assign({}, defaults, opts);
const customResolveOptions = options.customResolveOptions,
extensions = options.extensions,
jail = options.jail;
const warnings = [];
const packageInfoCache = new Map();
const idToPackageInfo = new Map();
const mainFields = getMainFields(options);
const useBrowserOverrides = mainFields.indexOf('browser') !== -1;
const isPreferBuiltinsSet = options.preferBuiltins === true || options.preferBuiltins === false;
const preferBuiltins = isPreferBuiltinsSet ? options.preferBuiltins : true;
const rootDir = options.rootDir || process.cwd();
let dedupe = options.dedupe;
let rollupOptions;
if (options.only) {
warnings.push('node-resolve: The `only` options is deprecated, please use `resolveOnly`');
options.resolveOnly = options.only;
}
if (typeof dedupe !== 'function') {
dedupe = importee => options.dedupe.includes(importee) || options.dedupe.includes(getPackageName(importee));
}
const resolveOnly = options.resolveOnly.map(pattern => {
if (pattern instanceof RegExp) {
return pattern;
}
const normalized = pattern.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
return new RegExp(`^${normalized}$`);
});
const browserMapCache = new Map();
let preserveSymlinks;
return {
name: 'node-resolve',
buildStart(options) {
rollupOptions = options;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = warnings[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
const warning = _step.value;
this.warn(warning);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
preserveSymlinks = options.preserveSymlinks;
},
generateBundle() {
readCachedFile.clear();
isFileCached.clear();
isDirCached.clear();
},
resolveId(importee, importer) {
var _this = this;
return _asyncToGenerator(function* () {
if (importee === ES6_BROWSER_EMPTY) {
return importee;
} // ignore IDs with null character, these belong to other plugins
if (/\0/.test(importee)) return null;
const basedir = !importer || dedupe(importee) ? rootDir : dirname(importer); // https://github.com/defunctzombie/package-browser-field-spec
const browser = browserMapCache.get(importer);
if (useBrowserOverrides && browser) {
const resolvedImportee = resolve(basedir, importee);
if (browser[importee] === false || browser[resolvedImportee] === false) {
return ES6_BROWSER_EMPTY;
}
const browserImportee = browser[importee] || browser[resolvedImportee] || browser[`${resolvedImportee}.js`] || browser[`${resolvedImportee}.json`];
if (browserImportee) {
importee = browserImportee;
}
}
const parts = importee.split(/[/\\]/);
let id = parts.shift();
if (id[0] === '@' && parts.length > 0) {
// scoped packages
id += `/${parts.shift()}`;
} else if (id[0] === '.') {
// an import relative to the parent dir of the importer
id = resolve(basedir, importee);
}
const input = normalizeInput(rollupOptions.input);
if (resolveOnly.length && !resolveOnly.some(pattern => pattern.test(id))) {
if (input.includes(id)) {
return null;
}
return false;
}
let hasModuleSideEffects = nullFn;
let hasPackageEntry = true;
let packageBrowserField = false;
let packageInfo;
const filter = (pkg, pkgPath) => {
const info = getPackageInfo({
cache: packageInfoCache,
extensions,
pkg,
pkgPath,
mainFields,
preserveSymlinks,
useBrowserOverrides
});
packageInfo = info.packageInfo;
hasModuleSideEffects = info.hasModuleSideEffects;
hasPackageEntry = info.hasPackageEntry;
packageBrowserField = info.packageBrowserField;
return info.cachedPkg;
};
let resolveOptions = {
basedir,
packageFilter: filter,
readFile: readCachedFile,
isFile: isFileCached,
isDirectory: isDirCached,
extensions
};
if (preserveSymlinks !== undefined) {
resolveOptions.preserveSymlinks = preserveSymlinks;
}
const importSpecifierList = [];
if (importer === undefined && !importee[0].match(/^\.?\.?\//)) {
// For module graph roots (i.e. when importer is undefined), we
// need to handle 'path fragments` like `foo/bar` that are commonly
// found in rollup config files. If importee doesn't look like a
// relative or absolute path, we make it relative and attempt to
// resolve it. If we don't find anything, we try resolving it as we
// got it.
importSpecifierList.push(`./${importee}`);
}
const importeeIsBuiltin = builtins.has(importee);
if (importeeIsBuiltin && (!preferBuiltins || !isPreferBuiltinsSet)) {
// The `resolve` library will not resolve packages with the same
// name as a node built-in module. If we're resolving something
// that's a builtin, and we don't prefer to find built-ins, we
// first try to look up a local module with that name. If we don't
// find anything, we resolve the builtin which just returns back
// the built-in's name.
importSpecifierList.push(`${importee}/`);
}
importSpecifierList.push(importee);
resolveOptions = Object.assign(resolveOptions, customResolveOptions);
try {
let resolved = yield resolveImportSpecifiers(importSpecifierList, resolveOptions);
if (resolved && packageBrowserField) {
if (Object.prototype.hasOwnProperty.call(packageBrowserField, resolved)) {
if (!packageBrowserField[resolved]) {
browserMapCache.set(resolved, packageBrowserField);
return ES6_BROWSER_EMPTY;
}
resolved = packageBrowserField[resolved];
}
browserMapCache.set(resolved, packageBrowserField);
}
if (hasPackageEntry && !preserveSymlinks && resolved) {
const fileExists = yield exists(resolved);
if (fileExists) {
resolved = yield realpath(resolved);
}
}
idToPackageInfo.set(resolved, packageInfo);
if (hasPackageEntry) {
if (builtins.has(resolved) && preferBuiltins && isPreferBuiltinsSet) {
return null;
} else if (importeeIsBuiltin && preferBuiltins) {
if (!isPreferBuiltinsSet) {
_this.warn(`preferring built-in module '${importee}' over local alternative at '${resolved}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning`);
}
return null;
} else if (jail && resolved.indexOf(normalize(jail.trim(sep))) !== 0) {
return null;
}
}
if (resolved && options.modulesOnly) {
const code = yield readFile(resolved, 'utf-8');
if (isModule(code)) {
return {
id: resolved,
moduleSideEffects: hasModuleSideEffects(resolved)
};
}
return null;
}
const result = {
id: resolved,
moduleSideEffects: hasModuleSideEffects(resolved)
};
return result;
} catch (error) {
return null;
}
})();
},
load(importee) {
if (importee === ES6_BROWSER_EMPTY) {
return 'export default {};';
}
return null;
},
getPackageInfoForId(id) {
return idToPackageInfo.get(id);
}
};
}
export default nodeResolve;

View file

@ -0,0 +1,590 @@
'use strict';
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var path = require('path');
var builtinList = _interopDefault(require('builtin-modules'));
var isModule = _interopDefault(require('is-module'));
var fs = require('fs');
var fs__default = _interopDefault(fs);
var util = require('util');
var pluginutils = require('@rollup/pluginutils');
var resolveModule = _interopDefault(require('resolve'));
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
const exists = util.promisify(fs__default.exists);
const readFile = util.promisify(fs__default.readFile);
const realpath = util.promisify(fs__default.realpath);
const stat = util.promisify(fs__default.stat);
const onError = error => {
if (error.code === 'ENOENT') {
return false;
}
throw error;
};
const makeCache = fn => {
const cache = new Map();
const wrapped =
/*#__PURE__*/
function () {
var _ref = _asyncToGenerator(function* (param, done) {
if (cache.has(param) === false) {
cache.set(param, fn(param).catch(err => {
cache.delete(param);
throw err;
}));
}
try {
const result = cache.get(param);
const value = yield result;
return done(null, value);
} catch (error) {
return done(error);
}
});
return function wrapped(_x, _x2) {
return _ref.apply(this, arguments);
};
}();
wrapped.clear = () => cache.clear();
return wrapped;
};
const isDirCached = makeCache(
/*#__PURE__*/
function () {
var _ref2 = _asyncToGenerator(function* (file) {
try {
const stats = yield stat(file);
return stats.isDirectory();
} catch (error) {
return onError(error);
}
});
return function (_x3) {
return _ref2.apply(this, arguments);
};
}());
const isFileCached = makeCache(
/*#__PURE__*/
function () {
var _ref3 = _asyncToGenerator(function* (file) {
try {
const stats = yield stat(file);
return stats.isFile();
} catch (error) {
return onError(error);
}
});
return function (_x4) {
return _ref3.apply(this, arguments);
};
}());
const readCachedFile = makeCache(readFile);
const resolveId = util.promisify(resolveModule); // returns the imported package name for bare module imports
function getPackageName(id) {
if (id.startsWith('.') || id.startsWith('/')) {
return null;
}
const split = id.split('/'); // @my-scope/my-package/foo.js -> @my-scope/my-package
// @my-scope/my-package -> @my-scope/my-package
if (split[0][0] === '@') {
return `${split[0]}/${split[1]}`;
} // my-package/foo.js -> my-package
// my-package -> my-package
return split[0];
}
function getMainFields(options) {
let mainFields;
if (options.mainFields) {
mainFields = options.mainFields;
} else {
mainFields = ['module', 'main'];
}
if (options.browser && mainFields.indexOf('browser') === -1) {
return ['browser'].concat(mainFields);
}
if (!mainFields.length) {
throw new Error('Please ensure at least one `mainFields` value is specified');
}
return mainFields;
}
function getPackageInfo(options) {
const cache = options.cache,
extensions = options.extensions,
pkg = options.pkg,
mainFields = options.mainFields,
preserveSymlinks = options.preserveSymlinks,
useBrowserOverrides = options.useBrowserOverrides;
let pkgPath = options.pkgPath;
if (cache.has(pkgPath)) {
return cache.get(pkgPath);
} // browserify/resolve doesn't realpath paths returned in its packageFilter callback
if (!preserveSymlinks) {
pkgPath = fs.realpathSync(pkgPath);
}
const pkgRoot = path.dirname(pkgPath);
const packageInfo = {
// copy as we are about to munge the `main` field of `pkg`.
packageJson: Object.assign({}, pkg),
// path to package.json file
packageJsonPath: pkgPath,
// directory containing the package.json
root: pkgRoot,
// which main field was used during resolution of this module (main, module, or browser)
resolvedMainField: 'main',
// whether the browser map was used to resolve the entry point to this module
browserMappedMain: false,
// the entry point of the module with respect to the selected main field and any
// relevant browser mappings.
resolvedEntryPoint: ''
};
let overriddenMain = false;
for (let i = 0; i < mainFields.length; i++) {
const field = mainFields[i];
if (typeof pkg[field] === 'string') {
pkg.main = pkg[field];
packageInfo.resolvedMainField = field;
overriddenMain = true;
break;
}
}
const internalPackageInfo = {
cachedPkg: pkg,
hasModuleSideEffects: () => null,
hasPackageEntry: overriddenMain !== false || mainFields.indexOf('main') !== -1,
packageBrowserField: useBrowserOverrides && typeof pkg.browser === 'object' && Object.keys(pkg.browser).reduce((browser, key) => {
let resolved = pkg.browser[key];
if (resolved && resolved[0] === '.') {
resolved = path.resolve(pkgRoot, resolved);
}
/* eslint-disable no-param-reassign */
browser[key] = resolved;
if (key[0] === '.') {
const absoluteKey = path.resolve(pkgRoot, key);
browser[absoluteKey] = resolved;
if (!path.extname(key)) {
extensions.reduce((subBrowser, ext) => {
subBrowser[absoluteKey + ext] = subBrowser[key];
return subBrowser;
}, browser);
}
}
return browser;
}, {}),
packageInfo
};
const browserMap = internalPackageInfo.packageBrowserField;
if (useBrowserOverrides && typeof pkg.browser === 'object' && // eslint-disable-next-line no-prototype-builtins
browserMap.hasOwnProperty(pkg.main)) {
packageInfo.resolvedEntryPoint = browserMap[pkg.main];
packageInfo.browserMappedMain = true;
} else {
// index.node is technically a valid default entrypoint as well...
packageInfo.resolvedEntryPoint = path.resolve(pkgRoot, pkg.main || 'index.js');
packageInfo.browserMappedMain = false;
}
const packageSideEffects = pkg.sideEffects;
if (typeof packageSideEffects === 'boolean') {
internalPackageInfo.hasModuleSideEffects = () => packageSideEffects;
} else if (Array.isArray(packageSideEffects)) {
internalPackageInfo.hasModuleSideEffects = pluginutils.createFilter(packageSideEffects, null, {
resolve: pkgRoot
});
}
cache.set(pkgPath, internalPackageInfo);
return internalPackageInfo;
}
function normalizeInput(input) {
if (Array.isArray(input)) {
return input;
} else if (typeof input === 'object') {
return Object.values(input);
} // otherwise it's a string
return input;
} // Resolve module specifiers in order. Promise resolves to the first module that resolves
// successfully, or the error that resulted from the last attempted module resolution.
function resolveImportSpecifiers(importSpecifierList, resolveOptions) {
let promise = Promise.resolve();
for (let i = 0; i < importSpecifierList.length; i++) {
promise = promise.then(value => {
// if we've already resolved to something, just return it.
if (value) {
return value;
}
return resolveId(importSpecifierList[i], resolveOptions).then(result => {
if (!resolveOptions.preserveSymlinks) {
result = fs.realpathSync(result);
}
return result;
});
});
if (i < importSpecifierList.length - 1) {
// swallow MODULE_NOT_FOUND errors from all but the last resolution
promise = promise.catch(error => {
if (error.code !== 'MODULE_NOT_FOUND') {
throw error;
}
});
}
}
return promise;
}
const builtins = new Set(builtinList);
const ES6_BROWSER_EMPTY = '\0node-resolve:empty.js';
const nullFn = () => null;
const defaults = {
customResolveOptions: {},
dedupe: [],
// It's important that .mjs is listed before .js so that Rollup will interpret npm modules
// which deploy both ESM .mjs and CommonJS .js files as ESM.
extensions: ['.mjs', '.js', '.json', '.node'],
resolveOnly: []
};
function nodeResolve(opts = {}) {
const options = Object.assign({}, defaults, opts);
const customResolveOptions = options.customResolveOptions,
extensions = options.extensions,
jail = options.jail;
const warnings = [];
const packageInfoCache = new Map();
const idToPackageInfo = new Map();
const mainFields = getMainFields(options);
const useBrowserOverrides = mainFields.indexOf('browser') !== -1;
const isPreferBuiltinsSet = options.preferBuiltins === true || options.preferBuiltins === false;
const preferBuiltins = isPreferBuiltinsSet ? options.preferBuiltins : true;
const rootDir = options.rootDir || process.cwd();
let dedupe = options.dedupe;
let rollupOptions;
if (options.only) {
warnings.push('node-resolve: The `only` options is deprecated, please use `resolveOnly`');
options.resolveOnly = options.only;
}
if (typeof dedupe !== 'function') {
dedupe = importee => options.dedupe.includes(importee) || options.dedupe.includes(getPackageName(importee));
}
const resolveOnly = options.resolveOnly.map(pattern => {
if (pattern instanceof RegExp) {
return pattern;
}
const normalized = pattern.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
return new RegExp(`^${normalized}$`);
});
const browserMapCache = new Map();
let preserveSymlinks;
return {
name: 'node-resolve',
buildStart(options) {
rollupOptions = options;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = warnings[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
const warning = _step.value;
this.warn(warning);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
preserveSymlinks = options.preserveSymlinks;
},
generateBundle() {
readCachedFile.clear();
isFileCached.clear();
isDirCached.clear();
},
resolveId(importee, importer) {
var _this = this;
return _asyncToGenerator(function* () {
if (importee === ES6_BROWSER_EMPTY) {
return importee;
} // ignore IDs with null character, these belong to other plugins
if (/\0/.test(importee)) return null;
const basedir = !importer || dedupe(importee) ? rootDir : path.dirname(importer); // https://github.com/defunctzombie/package-browser-field-spec
const browser = browserMapCache.get(importer);
if (useBrowserOverrides && browser) {
const resolvedImportee = path.resolve(basedir, importee);
if (browser[importee] === false || browser[resolvedImportee] === false) {
return ES6_BROWSER_EMPTY;
}
const browserImportee = browser[importee] || browser[resolvedImportee] || browser[`${resolvedImportee}.js`] || browser[`${resolvedImportee}.json`];
if (browserImportee) {
importee = browserImportee;
}
}
const parts = importee.split(/[/\\]/);
let id = parts.shift();
if (id[0] === '@' && parts.length > 0) {
// scoped packages
id += `/${parts.shift()}`;
} else if (id[0] === '.') {
// an import relative to the parent dir of the importer
id = path.resolve(basedir, importee);
}
const input = normalizeInput(rollupOptions.input);
if (resolveOnly.length && !resolveOnly.some(pattern => pattern.test(id))) {
if (input.includes(id)) {
return null;
}
return false;
}
let hasModuleSideEffects = nullFn;
let hasPackageEntry = true;
let packageBrowserField = false;
let packageInfo;
const filter = (pkg, pkgPath) => {
const info = getPackageInfo({
cache: packageInfoCache,
extensions,
pkg,
pkgPath,
mainFields,
preserveSymlinks,
useBrowserOverrides
});
packageInfo = info.packageInfo;
hasModuleSideEffects = info.hasModuleSideEffects;
hasPackageEntry = info.hasPackageEntry;
packageBrowserField = info.packageBrowserField;
return info.cachedPkg;
};
let resolveOptions = {
basedir,
packageFilter: filter,
readFile: readCachedFile,
isFile: isFileCached,
isDirectory: isDirCached,
extensions
};
if (preserveSymlinks !== undefined) {
resolveOptions.preserveSymlinks = preserveSymlinks;
}
const importSpecifierList = [];
if (importer === undefined && !importee[0].match(/^\.?\.?\//)) {
// For module graph roots (i.e. when importer is undefined), we
// need to handle 'path fragments` like `foo/bar` that are commonly
// found in rollup config files. If importee doesn't look like a
// relative or absolute path, we make it relative and attempt to
// resolve it. If we don't find anything, we try resolving it as we
// got it.
importSpecifierList.push(`./${importee}`);
}
const importeeIsBuiltin = builtins.has(importee);
if (importeeIsBuiltin && (!preferBuiltins || !isPreferBuiltinsSet)) {
// The `resolve` library will not resolve packages with the same
// name as a node built-in module. If we're resolving something
// that's a builtin, and we don't prefer to find built-ins, we
// first try to look up a local module with that name. If we don't
// find anything, we resolve the builtin which just returns back
// the built-in's name.
importSpecifierList.push(`${importee}/`);
}
importSpecifierList.push(importee);
resolveOptions = Object.assign(resolveOptions, customResolveOptions);
try {
let resolved = yield resolveImportSpecifiers(importSpecifierList, resolveOptions);
if (resolved && packageBrowserField) {
if (Object.prototype.hasOwnProperty.call(packageBrowserField, resolved)) {
if (!packageBrowserField[resolved]) {
browserMapCache.set(resolved, packageBrowserField);
return ES6_BROWSER_EMPTY;
}
resolved = packageBrowserField[resolved];
}
browserMapCache.set(resolved, packageBrowserField);
}
if (hasPackageEntry && !preserveSymlinks && resolved) {
const fileExists = yield exists(resolved);
if (fileExists) {
resolved = yield realpath(resolved);
}
}
idToPackageInfo.set(resolved, packageInfo);
if (hasPackageEntry) {
if (builtins.has(resolved) && preferBuiltins && isPreferBuiltinsSet) {
return null;
} else if (importeeIsBuiltin && preferBuiltins) {
if (!isPreferBuiltinsSet) {
_this.warn(`preferring built-in module '${importee}' over local alternative at '${resolved}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning`);
}
return null;
} else if (jail && resolved.indexOf(path.normalize(jail.trim(path.sep))) !== 0) {
return null;
}
}
if (resolved && options.modulesOnly) {
const code = yield readFile(resolved, 'utf-8');
if (isModule(code)) {
return {
id: resolved,
moduleSideEffects: hasModuleSideEffects(resolved)
};
}
return null;
}
const result = {
id: resolved,
moduleSideEffects: hasModuleSideEffects(resolved)
};
return result;
} catch (error) {
return null;
}
})();
},
load(importee) {
if (importee === ES6_BROWSER_EMPTY) {
return 'export default {};';
}
return null;
},
getPackageInfoForId(id) {
return idToPackageInfo.get(id);
}
};
}
module.exports = nodeResolve;

View file

@ -0,0 +1,78 @@
{
"name": "@rollup/plugin-node-resolve",
"version": "7.1.3",
"publishConfig": {
"access": "public"
},
"description": "Locate and bundle third-party dependencies in node_modules",
"license": "MIT",
"repository": "rollup/plugins",
"author": "Rich Harris <richard.a.harris@gmail.com>",
"homepage": "https://github.com/rollup/plugins/tree/master/packages/node-resolve/#readme",
"bugs": "https://github.com/rollup/plugins/issues",
"main": "dist/index.js",
"engines": {
"node": ">= 8.0.0"
},
"scripts": {
"build": "rollup -c",
"ci:coverage": "nyc pnpm run test && nyc report --reporter=text-lcov > coverage.lcov",
"ci:lint": "pnpm run build && pnpm run lint",
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
"ci:test": "pnpm run test -- --verbose && pnpm run test:ts",
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
"lint:docs": "prettier --single-quote --write README.md",
"lint:js": "eslint --fix --cache src test types --ext .js,.ts",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"prebuild": "del-cli dist",
"prepare": "pnpm run build",
"prepublishOnly": "pnpm run lint && pnpm run test && pnpm run test:ts",
"pretest": "pnpm run build",
"test": "ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
"files": [
"dist",
"types",
"README.md",
"LICENSE"
],
"keywords": [
"rollup",
"plugin",
"es2015",
"npm",
"modules"
],
"peerDependencies": {
"rollup": "^1.20.0||^2.0.0"
},
"dependencies": {
"@rollup/pluginutils": "^3.0.8",
"@types/resolve": "0.0.8",
"builtin-modules": "^3.1.0",
"is-module": "^1.0.0",
"resolve": "^1.14.2"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@rollup/plugin-json": "^4.0.1",
"es5-ext": "^0.10.53",
"rollup": "^2.0.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.1.0",
"source-map": "^0.7.3",
"string-capitalize": "^1.0.1"
},
"ava": {
"files": [
"!**/fixtures/**",
"!**/helpers/**",
"!**/recipes/**",
"!**/types.ts"
]
},
"module": "dist/index.es.js",
"types": "types/index.d.ts"
}

View file

@ -0,0 +1,84 @@
import { Plugin } from 'rollup';
import { AsyncOpts } from 'resolve';
export interface Options {
/**
* 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`.
* @default false
*/
browser?: boolean;
/**
* An `Object` that specifies additional options that should be passed through to `node-resolve`.
*/
customResolveOptions?: AsyncOpts;
/**
* An `Array` of modules names, which instructs the plugin to force resolving for the
* specified modules to the root `node_modules`. Helps to prevent bundling the same
* package multiple times if package is imported from dependencies.
*/
dedupe?: string[] | ((importee: string) => boolean);
/**
* Specifies the extensions of files that the plugin will operate on.
* @default [ '.mjs', '.js', '.json', '.node' ]
*/
extensions?: readonly string[];
/**
* Locks the module search within specified path (e.g. chroot). Modules defined
* outside this path will be marked as external.
* @default '/'
*/
jail?: string;
/**
* Specifies the properties to scan within a `package.json`, used to determine the
* bundle entry point.
* @default ['module', 'main']
*/
mainFields?: readonly string[];
/**
* If `true`, inspect resolved files to assert that they are ES2015 modules.
* @default false
*/
modulesOnly?: boolean;
/**
* @deprecated use "resolveOnly" instead
* @default null
*/
only?: ReadonlyArray<string | RegExp> | null;
/**
* If `true`, the plugin will prefer built-in modules (e.g. `fs`, `path`). If `false`,
* the plugin will look for locally installed modules of the same name.
* @default true
*/
preferBuiltins?: boolean;
/**
* An `Array` which instructs the plugin to limit module resolution to those whose
* names match patterns in the array.
* @default []
*/
resolveOnly?: ReadonlyArray<string | RegExp> | null;
/**
* Specifies the root directory from which to resolve modules. Typically used when
* resolving entry-point imports, and when resolving deduplicated modules.
* @default process.cwd()
*/
rootDir?: string;
}
/**
* Locate modules using the Node resolution algorithm, for using third party modules in node_modules
*/
export default function nodeResolve(options?: Options): Plugin;