Skip to content

Commit

Permalink
vx: vx_allow_resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Jun 5, 2023
1 parent b427da2 commit 9e93f7c
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/anyone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
}
3 changes: 2 additions & 1 deletion packages/context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
}
3 changes: 2 additions & 1 deletion packages/n4s/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
}
3 changes: 2 additions & 1 deletion packages/vast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
"./*": "./*"
},
"unpkg": "./dist/umd/vast.production.js",
"jsdelivr": "./dist/umd/vast.production.js"
"jsdelivr": "./dist/umd/vast.production.js",
"vxAllowResolve": []
}
3 changes: 2 additions & 1 deletion packages/vest-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
},
"./package.json": "./package.json",
"./*": "./*"
}
},
"vxAllowResolve": []
}
3 changes: 2 additions & 1 deletion packages/vest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,6 @@
},
"./package.json": "./package.json",
"./*": "./*"
}
},
"vxAllowResolve": []
}
3 changes: 2 additions & 1 deletion packages/vestjs-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@
},
"./package.json": "./package.json",
"./*": "./*"
}
},
"vxAllowResolve": []
}
6 changes: 6 additions & 0 deletions vx/config/rollup/getPlugins.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -21,6 +22,11 @@ module.exports = function getPlugins({
namespace = undefined,
} = {}) {
const plugins = [
nodeResolve({
resolveOnly: dep => {
return packageJson.getVxAllowResolve(packageName, dep);
},
}),
replace({
preventAssignment: true,
values: {
Expand Down
9 changes: 8 additions & 1 deletion vx/config/rollup/plugins/handleExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions vx/opts.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ module.exports = {
CJS: 'cjs',
ES: 'es',
},
vx_config: {
VX_ALLOW_RESOLVE: 'vxAllowResolve',
},
};
1 change: 1 addition & 0 deletions vx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions vx/util/packageJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
50 changes: 50 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3555,6 +3555,25 @@ __metadata:
languageName: node
linkType: hard

"@rollup/plugin-node-resolve@npm:^15.1.0":
version: 15.1.0
resolution: "@rollup/plugin-node-resolve@npm:15.1.0"
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
peerDependencies:
rollup: ^2.78.0||^3.0.0
peerDependenciesMeta:
rollup:
optional: true
checksum: 83617cdbb90cb780251e8b16dc1671e35bde90b8d4d30e008aefe706b5b643057f6299bdd3226b2a30bf5e4f807a880169de3faa47b9f2ba38d39f294f85f951
languageName: node
linkType: hard

"@rollup/plugin-replace@npm:^5.0.2":
version: 5.0.2
resolution: "@rollup/plugin-replace@npm:5.0.2"
Expand Down Expand Up @@ -4351,6 +4370,13 @@ __metadata:
languageName: node
linkType: hard

"@types/resolve@npm:1.20.2":
version: 1.20.2
resolution: "@types/resolve@npm:1.20.2"
checksum: 61c2cad2499ffc8eab36e3b773945d337d848d3ac6b7b0a87c805ba814bc838ef2f262fc0f109bfd8d2e0898ff8bd80ad1025f9ff64f1f71d3d4294c9f14e5f6
languageName: node
linkType: hard

"@types/responselike@npm:^1.0.0":
version: 1.0.0
resolution: "@types/responselike@npm:1.0.0"
Expand Down Expand Up @@ -5744,6 +5770,13 @@ __metadata:
languageName: node
linkType: hard

"builtin-modules@npm:^3.3.0":
version: 3.3.0
resolution: "builtin-modules@npm:3.3.0"
checksum: db021755d7ed8be048f25668fe2117620861ef6703ea2c65ed2779c9e3636d5c3b82325bd912244293959ff3ae303afa3471f6a15bf5060c103e4cc3a839749d
languageName: node
linkType: hard

"bytes@npm:3.0.0":
version: 3.0.0
resolution: "bytes@npm:3.0.0"
Expand Down Expand Up @@ -9424,6 +9457,15 @@ __metadata:
languageName: node
linkType: hard

"is-builtin-module@npm:^3.2.1":
version: 3.2.1
resolution: "is-builtin-module@npm:3.2.1"
dependencies:
builtin-modules: ^3.3.0
checksum: e8f0ffc19a98240bda9c7ada84d846486365af88d14616e737d280d378695c8c448a621dcafc8332dbf0fcd0a17b0763b845400709963fa9151ddffece90ae88
languageName: node
linkType: hard

"is-callable@npm:^1.1.3, is-callable@npm:^1.1.4, is-callable@npm:^1.2.7":
version: 1.2.7
resolution: "is-callable@npm:1.2.7"
Expand Down Expand Up @@ -9553,6 +9595,13 @@ __metadata:
languageName: node
linkType: hard

"is-module@npm:^1.0.0":
version: 1.0.0
resolution: "is-module@npm:1.0.0"
checksum: 8cd5390730c7976fb4e8546dd0b38865ee6f7bacfa08dfbb2cc07219606755f0b01709d9361e01f13009bbbd8099fa2927a8ed665118a6105d66e40f1b838c3f
languageName: node
linkType: hard

"is-negative-zero@npm:^2.0.2":
version: 2.0.2
resolution: "is-negative-zero@npm:2.0.2"
Expand Down Expand Up @@ -15121,6 +15170,7 @@ __metadata:
resolution: "vx@workspace:vx"
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
Expand Down

2 comments on commit 9e93f7c

@vercel
Copy link

@vercel vercel bot commented on 9e93f7c Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vest-next – ./website

vest-next.vercel.app
vest-next-ealush.vercel.app
vest-website.vercel.app
vest-next-git-latest-ealush.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 9e93f7c Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vest – ./website

vest-ealush.vercel.app
vest-git-latest-ealush.vercel.app
vest.vercel.app
www.vestjs.dev
vestjs.dev

Please sign in to comment.