{"versions":{"15.3.0":{"name":"@cocos/rollup-plugin-node-resolve","version":"15.3.0","publishConfig":{"access":"public"},"description":"Locate and bundle third-party dependencies in node_modules","license":"MIT","repository":{"url":"git+https://github.com/rollup/plugins.git","directory":"packages/node-resolve"},"author":{"name":"Rich Harris","email":"richard.a.harris@gmail.com"},"homepage":"https://github.com/rollup/plugins/tree/master/packages/node-resolve/#readme","bugs":{"url":"https://github.com/rollup/plugins/issues"},"main":"./dist/cjs/index.js","module":"./dist/es/index.js","exports":{"types":"./types/index.d.ts","import":"./dist/es/index.js","default":"./dist/cjs/index.js"},"engines":{"node":">=14.0.0"},"scripts":{"build":"rollup -c","ci:coverage":"nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov","ci:lint":"pnpm build && pnpm lint","ci:lint:commits":"commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}","ci:test":"pnpm test -- --verbose","prebuild":"del-cli dist","prepare":"if [ ! -d 'dist' ]; then pnpm build; fi","prepublishOnly":"pnpm build","prerelease":"pnpm build","pretest":"pnpm build","release":"pnpm --workspace-root package:release $(pwd)","test":"pnpm test:ts && ava","test:ts":"tsc types/index.d.ts test/types.ts --noEmit"},"keywords":["rollup","plugin","es2015","npm","modules"],"peerDependencies":{"rollup":"^2.78.0||^3.0.0||^4.0.0"},"peerDependenciesMeta":{"rollup":{"optional":true}},"dependencies":{"@rollup/pluginutils":"^5.0.1","@types/resolve":"1.20.2","deepmerge":"^4.2.2","is-module":"^1.0.0","resolve":"^1.22.1"},"devDependencies":{"@babel/core":"^7.19.1","@babel/preset-env":"^7.19.1","@babel/plugin-transform-typescript":"^7.10.5","@rollup/plugin-babel":"^6.0.0","@rollup/plugin-commonjs":"^28.0.0","@rollup/plugin-json":"^6.1.0","@rollup/plugin-typescript":"^12.1.1","@types/node":"^22.8.7","es5-ext":"^0.10.62","rollup":"^4.0.0","source-map":"^0.7.4","string-capitalize":"^1.0.1","tslib":"^2.8.1","del-cli":"^6.0.0","ava":"^6.2.0"},"types":"./types/index.d.ts","ava":{"workerThreads":false,"files":["!**/fixtures/**","!**/helpers/**","!**/recipes/**","!**/types.ts"]},"gitHead":"62588f934a767d4d7f35a4b36ed7ea3cf3210b65","_id":"@cocos/rollup-plugin-node-resolve@15.3.0","_nodeVersion":"18.17.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-7zHrG2WYNUPpytGGa6ohZlVnuU6VkbIZTpBY0x8qv1ikeS6WZuTCGtdeLWV0/8H+7Utd6nZoSHLnTSUDT2YALw==","shasum":"22a5bc0b0ba7ebe6611aaec57a61cb9efa6e3e24","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@cocos/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-15.3.0.tgz","fileCount":7,"unpackedSize":109086,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDq02nDQ/SMDPyZFfkR2KoVi2Jh44aYulODwjab6499NQIhAJKJEG7t9p37frTQxXrDAoc0ofnWAgsRgI8ONIfW4Zra"}],"size":27879},"_npmUser":{"name":"anonymous","email":"engine-deploy@cocos.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"engine-deploy@cocos.com"},{"name":"anonymous","email":"chinese1236@qq.com"},{"name":"anonymous","email":"shrinktofit@outlook.com"},{"name":"anonymous","email":"devhacker520@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rollup-plugin-node-resolve_15.3.0_1730708728051_0.46130954048508044"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-11-04T08:25:28.250Z","publish_time":1730708728250,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"15.3.0"},"name":"@cocos/rollup-plugin-node-resolve","time":{"created":"2024-11-04T08:34:47.422Z","modified":"2025-05-21T08:21:00.712Z","15.3.0":"2024-11-04T08:25:28.250Z"},"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']` conditions when resolving imports.\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\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)","users":{}}