diff --git a/.api/public.d.ts b/.api/public.d.ts index e83602c..a61b672 100644 --- a/.api/public.d.ts +++ b/.api/public.d.ts @@ -14878,7 +14878,7 @@ declare module "@cocos/ccbuild" { /** * Locate modules using the Node resolution algorithm, for using third party modules in node_modules */ - export function nodeResolve(options?: __private.___node_modules_rollup_plugin_node_resolve_types_index__RollupNodeResolveOptions): Plugin; + export function nodeResolve(options?: __private.___node_modules_cocos_rollup_plugin_node_resolve_types_index__RollupNodeResolveOptions): Plugin; /** * Convert CommonJS modules to ES6, so they can be included in a Rollup bundle */ @@ -16397,7 +16397,7 @@ declare module "@cocos/ccbuild" { */ namedExports?: boolean; } - export interface ___node_modules_rollup_plugin_node_resolve_types_index__RollupNodeResolveOptions { + export interface ___node_modules_cocos_rollup_plugin_node_resolve_types_index__RollupNodeResolveOptions { /** * Additional 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. @@ -16460,9 +16460,11 @@ declare module "@cocos/ccbuild" { /** * 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. + * + * If a function is provided, it will be called to determine whether to prefer built-ins. * @default true */ - preferBuiltins?: boolean; + preferBuiltins?: boolean | ((module: string) => boolean); /** * An `Array` which instructs the plugin to limit module resolution to those whose * names match patterns in the array. diff --git a/modules/bundler/package.json b/modules/bundler/package.json index 3e72c16..f0bd5b6 100644 --- a/modules/bundler/package.json +++ b/modules/bundler/package.json @@ -23,7 +23,7 @@ "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-commonjs": "^26.0.1", "@rollup/plugin-json": "^6.1.0", - "@rollup/plugin-node-resolve": "^15.2.3", + "@cocos/rollup-plugin-node-resolve": "^15.3.0", "@rollup/plugin-virtual": "^3.0.2", "@rollup/plugin-typescript": "~11.1.6", "@rollup/plugin-terser": "^0.4.4", diff --git a/modules/bundler/src/rollup/plugins.ts b/modules/bundler/src/rollup/plugins.ts index a63c000..e102ff9 100644 --- a/modules/bundler/src/rollup/plugins.ts +++ b/modules/bundler/src/rollup/plugins.ts @@ -1,7 +1,7 @@ import * as babel from '@rollup/plugin-babel'; import json from '@rollup/plugin-json'; -import nodeResolve from '@rollup/plugin-node-resolve'; +import nodeResolve from '@cocos/rollup-plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; import virtual from '@rollup/plugin-virtual'; import terser from '@rollup/plugin-terser'; diff --git a/package-lock.json b/package-lock.json index 53f7031..2f2ffb8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cocos/ccbuild", - "version": "2.2.16", + "version": "2.2.17", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@cocos/ccbuild", - "version": "2.2.16", + "version": "2.2.17", "hasInstallScript": true, "license": "MIT", "workspaces": [ @@ -193,10 +193,10 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "@cocos/rollup-plugin-node-resolve": "^15.3.0", "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-commonjs": "^26.0.1", "@rollup/plugin-json": "^6.1.0", - "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "~11.1.6", "@rollup/plugin-virtual": "^3.0.2", @@ -2782,6 +2782,29 @@ "semver": "bin/semver.js" } }, + "node_modules/@cocos/rollup-plugin-node-resolve": { + "version": "15.3.0", + "resolved": "https://registry.npmmirror.com/@cocos/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-15.3.0.tgz", + "integrity": "sha512-7zHrG2WYNUPpytGGa6ohZlVnuU6VkbIZTpBY0x8qv1ikeS6WZuTCGtdeLWV0/8H+7Utd6nZoSHLnTSUDT2YALw==", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, "node_modules/@cocos/tfig": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/@cocos/tfig/-/tfig-3.3.3.tgz", @@ -3750,30 +3773,6 @@ } } }, - "node_modules/@rollup/plugin-node-resolve": { - "version": "15.2.3", - "resolved": "https://registry.npmmirror.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.2.3.tgz", - "integrity": "sha512-j/lym8nf5E21LwBT4Df1VD6hRO2L2iwUeUmP7litikRsVp1H6NWx20NEp0Y7su+7XGc476GnXXc4kFeZNGmaSQ==", - "dependencies": { - "@rollup/pluginutils": "^5.0.1", - "@types/resolve": "1.20.2", - "deepmerge": "^4.2.2", - "is-builtin-module": "^3.2.1", - "is-module": "^1.0.0", - "resolve": "^1.22.1" - }, - "engines": { - "node": ">=14.0.0" - }, - "peerDependencies": { - "rollup": "^2.78.0||^3.0.0||^4.0.0" - }, - "peerDependenciesMeta": { - "rollup": { - "optional": true - } - } - }, "node_modules/@rollup/plugin-replace": { "version": "5.0.7", "resolved": "https://registry.npmmirror.com/@rollup/plugin-replace/-/plugin-replace-5.0.7.tgz", @@ -4963,17 +4962,6 @@ "version": "1.1.2", "license": "MIT" }, - "node_modules/builtin-modules": { - "version": "3.3.0", - "resolved": "https://registry.npmmirror.com/builtin-modules/-/builtin-modules-3.3.0.tgz", - "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/call-bind": { "version": "1.0.2", "dev": true, @@ -6670,20 +6658,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-builtin-module": { - "version": "3.2.1", - "resolved": "https://registry.npmmirror.com/is-builtin-module/-/is-builtin-module-3.2.1.tgz", - "integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==", - "dependencies": { - "builtin-modules": "^3.3.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-callable": { "version": "1.2.7", "dev": true, diff --git a/package.json b/package.json index e041d5e..0073638 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cocos/ccbuild", - "version": "2.2.16", + "version": "2.2.17", "description": "The next generation of build tool for Cocos engine.", "main": "./lib/index.js", "types": "./lib/index.d.ts",