diff --git a/packages/anyone/package.json b/packages/anyone/package.json index 8f1194411..56480eb78 100644 --- a/packages/anyone/package.json +++ b/packages/anyone/package.json @@ -167,5 +167,6 @@ "url": "https://github.com/ealush/vest.git/issues" }, "unpkg": "./dist/umd/anyone.production.js", - "jsdelivr": "./dist/umd/anyone.production.js" + "jsdelivr": "./dist/umd/anyone.production.js", + "vxAllowResolve": [] } diff --git a/packages/context/package.json b/packages/context/package.json index 2b1cc196c..733045237 100644 --- a/packages/context/package.json +++ b/packages/context/package.json @@ -47,5 +47,6 @@ "url": "https://github.com/ealush/vest.git/issues" }, "unpkg": "./dist/umd/context.production.js", - "jsdelivr": "./dist/umd/context.production.js" + "jsdelivr": "./dist/umd/context.production.js", + "vxAllowResolve": [] } diff --git a/packages/n4s/package.json b/packages/n4s/package.json index 08978b070..e86c9cadc 100644 --- a/packages/n4s/package.json +++ b/packages/n4s/package.json @@ -144,5 +144,6 @@ "url": "https://github.com/ealush/vest.git/issues" }, "unpkg": "./dist/umd/n4s.production.js", - "jsdelivr": "./dist/umd/n4s.production.js" + "jsdelivr": "./dist/umd/n4s.production.js", + "vxAllowResolve": [] } diff --git a/packages/vast/package.json b/packages/vast/package.json index 99118586b..266bc3058 100644 --- a/packages/vast/package.json +++ b/packages/vast/package.json @@ -46,5 +46,6 @@ "./*": "./*" }, "unpkg": "./dist/umd/vast.production.js", - "jsdelivr": "./dist/umd/vast.production.js" + "jsdelivr": "./dist/umd/vast.production.js", + "vxAllowResolve": [] } diff --git a/packages/vest-utils/package.json b/packages/vest-utils/package.json index 8d98a6f94..ec18a6ad5 100644 --- a/packages/vest-utils/package.json +++ b/packages/vest-utils/package.json @@ -43,5 +43,6 @@ }, "./package.json": "./package.json", "./*": "./*" - } + }, + "vxAllowResolve": [] } diff --git a/packages/vest/package.json b/packages/vest/package.json index 179aa39d6..5b688da9e 100644 --- a/packages/vest/package.json +++ b/packages/vest/package.json @@ -227,5 +227,6 @@ }, "./package.json": "./package.json", "./*": "./*" - } + }, + "vxAllowResolve": [] } diff --git a/packages/vestjs-runtime/package.json b/packages/vestjs-runtime/package.json index 404b7c6e0..e57bb46a7 100644 --- a/packages/vestjs-runtime/package.json +++ b/packages/vestjs-runtime/package.json @@ -44,5 +44,6 @@ }, "./package.json": "./package.json", "./*": "./*" - } + }, + "vxAllowResolve": [] } diff --git a/vx/config/rollup/getPlugins.js b/vx/config/rollup/getPlugins.js index ada9a632f..dd5d4d104 100644 --- a/vx/config/rollup/getPlugins.js +++ b/vx/config/rollup/getPlugins.js @@ -1,4 +1,5 @@ // const compiler = require('@ampproject/rollup-plugin-closure-compiler'); +const { nodeResolve } = require('@rollup/plugin-node-resolve'); const replace = require('@rollup/plugin-replace'); const _ = require('lodash'); const { terser } = require('rollup-plugin-terser'); @@ -21,6 +22,11 @@ module.exports = function getPlugins({ namespace = undefined, } = {}) { const plugins = [ + nodeResolve({ + resolveOnly: dep => { + return packageJson.getVxAllowResolve(packageName, dep); + }, + }), replace({ preventAssignment: true, values: { diff --git a/vx/config/rollup/plugins/handleExports.js b/vx/config/rollup/plugins/handleExports.js index 015c5c702..2325e4c87 100644 --- a/vx/config/rollup/plugins/handleExports.js +++ b/vx/config/rollup/plugins/handleExports.js @@ -61,7 +61,14 @@ function writePackageJson(name, exportPath, { namespace } = {}) { let pkgJson = generatePackageJson(name, namespace); if (isMainExport(name)) { - pkgJson = { ...packageJson(name), ...pkgJson }; + const orig = packageJson(name); + + const preserve = { + [opts.vx_config.VX_ALLOW_RESOLVE]: + orig[opts.vx_config.VX_ALLOW_RESOLVE] ?? [], + }; + + pkgJson = { ...orig, ...pkgJson, ...preserve }; } fse.writeJSONSync( diff --git a/vx/opts.js b/vx/opts.js index 9e7241858..b45843dc3 100644 --- a/vx/opts.js +++ b/vx/opts.js @@ -36,4 +36,7 @@ module.exports = { CJS: 'cjs', ES: 'es', }, + vx_config: { + VX_ALLOW_RESOLVE: 'vxAllowResolve', + }, }; diff --git a/vx/package.json b/vx/package.json index 131449149..c9fe19dba 100644 --- a/vx/package.json +++ b/vx/package.json @@ -2,6 +2,7 @@ "bin": "./cli.js", "dependencies": { "@ampproject/rollup-plugin-closure-compiler": "^0.27.0", + "@rollup/plugin-node-resolve": "^15.1.0", "@rollup/plugin-replace": "^5.0.2", "context": "3.0.2", "date-fns": "^2.30.0", diff --git a/vx/util/packageJson.js b/vx/util/packageJson.js index 2f84f33d2..63a23a212 100644 --- a/vx/util/packageJson.js +++ b/vx/util/packageJson.js @@ -9,4 +9,9 @@ function packageJson(pkgName = usePackage()) { return JSON.parse(jsonString); } +function getVxAllowResolve(pkgName = usePackage(), dep) { + return (packageJson(pkgName).vxAllowResolve || []).includes(dep); +} + module.exports = packageJson; +module.exports.getVxAllowResolve = getVxAllowResolve;