{"name":"@rollup/plugin-node-resolve","version":"16.0.0","keywords":["rollup","plugin","es2015","npm","modules"],"author":{"name":"Rich Harris","email":"richard.a.harris@gmail.com"},"license":"MIT","_id":"@rollup/plugin-node-resolve@16.0.0","maintainers":[{"name":"shellscape","email":"andrew@shellscape.org"},{"name":"rich_harris","email":"richard.a.harris@gmail.com"},{"name":"guybedford","email":"guybedford@gmail.com"},{"name":"lukastaegert","email":"lukas.taegert@tngtech.com"}],"homepage":"https://github.com/rollup/plugins/tree/master/packages/node-resolve/#readme","bugs":{"url":"https://github.com/rollup/plugins/issues"},"ava":{"files":["!**/fixtures/**","!**/helpers/**","!**/recipes/**","!**/types.ts"],"workerThreads":false},"dist":{"shasum":"b1a0594661f40d7b061d82136e847354ff85f211","tarball":"http://registry-npm.ywwl.com/@rollup/plugin-node-resolve/download/@rollup/plugin-node-resolve-16.0.0.tgz","fileCount":8,"integrity":"sha512-0FPvAeVUT/zdWoO0jnb/V5BlBsUSNfkIOtFHzMO4H9MOklrmQFY6FduVHKucNb/aTFxvnGhj4MNj/T1oNdDfNg==","signatures":[{"sig":"MEYCIQCsKkGseOfwhOpPEa3zT1qTeqya0KZDAYnpfYuz9snmFAIhALZYtAot9v2wKYlEVMj8rAGq01hFAUh3Xt4IODGGQevr","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":155678,"size":39046,"noattachment":false,"key":"/@rollup/plugin-node-resolve/-/@rollup/plugin-node-resolve-16.0.0.tgz"},"main":"./dist/cjs/index.js","_from":"file:rollup-plugin-node-resolve-16.0.0.tgz","types":"./types/index.d.ts","module":"./dist/es/index.js","engines":{"node":">=14.0.0"},"exports":{"types":"./types/index.d.ts","import":"./dist/es/index.js","default":"./dist/cjs/index.js"},"scripts":{"test":"pnpm test:ts && ava","build":"rollup -c","ci:lint":"pnpm build && pnpm lint","ci:test":"pnpm test -- --verbose","pretest":"pnpm build","release":"pnpm --workspace-root package:release $(pwd)","test:ts":"tsc types/index.d.ts test/types.ts --noEmit","prebuild":"del-cli dist","prerelease":"pnpm build","ci:coverage":"nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov","ci:lint:commits":"commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}"},"_npmUser":{"name":"shellscape","email":"andrew@shellscape.org"},"_resolved":"/tmp/37d94edb95081ef663b788525c266001/rollup-plugin-node-resolve-16.0.0.tgz","_integrity":"sha512-0FPvAeVUT/zdWoO0jnb/V5BlBsUSNfkIOtFHzMO4H9MOklrmQFY6FduVHKucNb/aTFxvnGhj4MNj/T1oNdDfNg==","repository":{"url":"git+https://github.com/rollup/plugins.git","directory":"packages/node-resolve"},"_npmVersion":"10.8.2","description":"Locate and bundle third-party dependencies in node_modules","directories":{},"_nodeVersion":"20.18.1","dependencies":{"resolve":"^1.22.1","deepmerge":"^4.2.2","is-module":"^1.0.0","@types/resolve":"1.20.2","@rollup/pluginutils":"^5.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"rollup":"^4.0.0-24","es5-ext":"^0.10.62","source-map":"^0.7.4","@babel/core":"^7.19.1","string-capitalize":"^1.0.1","@rollup/plugin-json":"^5.0.0","@rollup/plugin-babel":"^6.0.0","@rollup/plugin-commonjs":"^23.0.0","@babel/plugin-transform-typescript":"^7.10.5"},"peerDependencies":{"rollup":"^2.78.0||^3.0.0||^4.0.0"},"peerDependenciesMeta":{"rollup":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/plugin-node-resolve_16.0.0_1734279704686_0.388130717180867","host":"s3://npm-registry-packages-npm-production"},"readme":"[npm]: https://img.shields.io/npm/v/@rollup/plugin-node-resolve\n[npm-url]: https://www.npmjs.com/package/@rollup/plugin-node-resolve\n[size]: https://packagephobia.now.sh/badge?p=@rollup/plugin-node-resolve\n[size-url]: https://packagephobia.now.sh/result?p=@rollup/plugin-node-resolve\n\n[![npm][npm]][npm-url]\n[![size][size]][size-url]\n[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)\n\n# @rollup/plugin-node-resolve\n\n🍣 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`\n\n## Requirements\n\nThis plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v2.78.0+.\n\n## Install\n\nUsing npm:\n\n```console\nnpm install @rollup/plugin-node-resolve --save-dev\n```\n\n## Usage\n\nCreate a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:\n\n```js\nimport { nodeResolve } from '@rollup/plugin-node-resolve';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'output',\n    format: 'cjs'\n  },\n  plugins: [nodeResolve()]\n};\n```\n\nThen 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).\n\n## Package entrypoints\n\nThis plugin supports the package entrypoints feature from node js, specified in the `exports` or `imports` field of a package. Check the [official documentation](https://nodejs.org/api/packages.html#packages_package_entry_points) for more information on how this works. This is the default behavior. In the abscence of these fields, the fields in `mainFields` will be the ones to be used.\n\n## Options\n\n### `exportConditions`\n\nType: `Array[...String]`<br>\nDefault: `[]`\n\nAdditional conditions of the package.json exports field to match when resolving modules. By default, this plugin looks for the `['default', 'module', 'import', 'development|production']` conditions when resolving imports. If neither the `development` or `production` conditions are provided it will default to `production` - or `development` if `NODE_ENV` is set to a value other than `production`.\n\nWhen using `@rollup/plugin-commonjs` v16 or higher, this plugin will use the `['default', 'module', 'require']` conditions when resolving require statements.\n\nSetting this option will add extra conditions on top of the default conditions. See https://nodejs.org/api/packages.html#packages_conditional_exports for more information.\n\nIn order to get the [resolution behavior of Node.js](https://nodejs.org/api/packages.html#packages_conditional_exports), set this to `['node']`.\n\n### `browser`\n\nType: `Boolean`<br>\nDefault: `false`\n\nIf `true`, instructs the plugin to use the browser module resolutions in `package.json` and adds `'browser'` to `exportConditions` if it is not present so browser conditionals in `exports` are applied. If `false`, any browser properties in package files will be ignored. Alternatively, a value of `'browser'` can be added to both the `mainFields` and `exportConditions` options, however this option takes precedence over `mainFields`.\n\n> This option does not work when a package is using [package entrypoints](https://nodejs.org/api/packages.html#packages_package_entry_points)\n\n### `moduleDirectories`\n\nType: `Array[...String]`<br>\nDefault: `['node_modules']`\n\nA list of directory names in which to recursively look for modules.\n\n### `modulePaths`\n\nType: `Array[...String]`<br>\nDefault: `[]`\n\nA list of absolute paths to additional locations to search for modules. [This is analogous to setting the `NODE_PATH` environment variable for node](https://nodejs.org/api/modules.html#loading-from-the-global-folders).\n\n### `dedupe`\n\nType: `Array[...String]`<br>\nDefault: `[]`\n\nAn `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.\n\n```js\ndedupe: ['my-package', '@namespace/my-package'];\n```\n\nThis will deduplicate bare imports such as:\n\n```js\nimport 'my-package';\nimport '@namespace/my-package';\n```\n\nAnd it will deduplicate deep imports such as:\n\n```js\nimport 'my-package/foo.js';\nimport '@namespace/my-package/bar.js';\n```\n\n### `extensions`\n\nType: `Array[...String]`<br>\nDefault: `['.mjs', '.js', '.json', '.node']`\n\nSpecifies the extensions of files that the plugin will operate on.\n\n### `jail`\n\nType: `String`<br>\nDefault: `'/'`\n\nLocks the module search within specified path (e.g. chroot). Modules defined outside this path will be ignored by this plugin.\n\n### `mainFields`\n\nType: `Array[...String]`<br>\nDefault: `['module', 'main']`<br>\nValid values: `['browser', 'jsnext:main', 'module', 'main']`\n\nSpecifies 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.\n\n### `preferBuiltins`\n\nType: `Boolean | (module: string) => boolean`<br>\nDefault: `true` (with warnings if a builtin module is used over a local version. Set to `true` to disable warning.)\n\nIf `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.\n\nAlternatively, you may pass in a function that returns a boolean to confirm whether the plugin should prefer built-in modules. e.g.\n\n```js\npreferBuiltins: (module) => module !== 'punycode';\n```\n\nwill not treat `punycode` as a built-in module\n\n### `modulesOnly`\n\nType: `Boolean`<br>\nDefault: `false`\n\nIf `true`, inspect resolved files to assert that they are ES2015 modules.\n\n### `resolveOnly`\n\nType: `Array[...String|RegExp] | (module: string) => boolean`<br>\nDefault: `null`\n\nAn `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._\n\nAlternatively, you may pass in a function that returns a boolean to confirm whether the module should be included or not.\n\nExamples:\n\n- `resolveOnly: ['batman', /^@batcave\\/.*$/]`\n- `resolveOnly: module => !module.includes('joker')`\n\n### `rootDir`\n\nType: `String`<br>\nDefault: `process.cwd()`\n\nSpecifies 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.\n\n```\n// Set the root directory to be the parent folder\nrootDir: path.join(process.cwd(), '..')\n```\n\n### `ignoreSideEffectsForRoot`\n\nType: `Boolean`<br>\nDefault: `false`\n\nIf you use the `sideEffects` property in the package.json, by default this is respected for files in the root package. Set to `true` to ignore the `sideEffects` configuration for the root package.\n\n### `allowExportsFolderMapping`\n\nOlder Node versions supported exports mappings of folders like\n\n```json\n{\n  \"exports\": {\n    \"./foo/\": \"./dist/foo/\"\n  }\n}\n```\n\nThis was deprecated with Node 14 and removed in Node 17, instead it is recommended to use exports patterns like\n\n```json\n{\n  \"exports\": {\n    \"./foo/*\": \"./dist/foo/*\"\n  }\n}\n```\n\nBut for backwards compatibility this behavior is still supported by enabling the `allowExportsFolderMapping` (defaults to `true`).\nThe default value might change in a futur major release.\n\n## Preserving symlinks\n\nThis plugin honours the rollup [`preserveSymlinks`](https://rollupjs.org/guide/en/#preservesymlinks) option.\n\n## Using with @rollup/plugin-commonjs\n\nSince 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):\n\n```js\n// rollup.config.js\nimport { nodeResolve } from '@rollup/plugin-node-resolve';\nimport commonjs from '@rollup/plugin-commonjs';\n\nexport default {\n  input: 'main.js',\n  output: {\n    file: 'bundle.js',\n    format: 'iife',\n    name: 'MyModule'\n  },\n  plugins: [nodeResolve(), commonjs()]\n};\n```\n\n## Resolving Built-Ins (like `fs`)\n\nBy default this plugin will prefer built-ins over local modules, marking them as external.\n\nSee [`preferBuiltins`](#preferbuiltins).\n\nTo provide stubbed versions of Node built-ins, use a plugin like [rollup-plugin-node-polyfills](https://github.com/ionic-team/rollup-plugin-node-polyfills) and set `preferBuiltins` to `false`. e.g.\n\n```js\nimport { nodeResolve } from '@rollup/plugin-node-resolve';\nimport nodePolyfills from 'rollup-plugin-node-polyfills';\nexport default ({\n  input: ...,\n  plugins: [\n    nodePolyfills(),\n    nodeResolve({ preferBuiltins: false })\n  ],\n  external: builtins,\n  output: ...\n})\n```\n\n## Resolving Require Statements\n\nAccording to [NodeJS module resolution](https://nodejs.org/api/packages.html#packages_package_entry_points) `require` statements should resolve using the `require` condition in the package exports field, while es modules should use the `import` condition.\n\nThe node resolve plugin uses `import` by default, you can opt into using the `require` semantics by passing an extra option to the resolve function:\n\n```js\nthis.resolve(importee, importer, {\n  skipSelf: true,\n  custom: { 'node-resolve': { isRequire: true } }\n});\n```\n\n## Resolve Options\n\nAfter this plugin resolved an import id to its target file in `node_modules`, it will invoke `this.resolve` again with the resolved id. It will pass the following information in the resolve options:\n\n```js\nthis.resolve(resolved.id, importer, {\n  custom: {\n    'node-resolve': {\n      resolved, // the object with information from node.js resolve\n      importee // the original import id\n    }\n  }\n});\n```\n\nYour plugin can use the `importee` information to map an original import to its resolved file in `node_modules`, in a plugin hook such as `resolveId`.\n\nThe `resolved` object contains the resolved id, which is passed as the first parameter. It also has a property `moduleSideEffects`, which may contain the value from the npm `package.json` field `sideEffects` or `null`.\n\n## Meta\n\n[CONTRIBUTING](/.github/CONTRIBUTING.md)\n\n[LICENSE (MIT)](/LICENSE)\n","publish_time":1734279705286,"_cnpm_publish_time":1734279705286,"dist-tags":{"latest":"16.0.3"}}