Skip to content

Commit

Permalink
vx: support installing of local packages
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Nov 20, 2021
1 parent 7baedf2 commit 38a54ae
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- release
- integration
- integration-*
- next
- next-*

jobs:
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
"arrowParens": "avoid",
"singleQuote": true
},
"vx": {
"main": "vest"
},
"vx": {},
"workspaces": [
"packages/*",
"./vx/"
Expand Down
3 changes: 3 additions & 0 deletions packages/n4s/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"test": "vx test",
"release": "vx release"
},
"dependencies": {
"context": "next"
},
"module": "./dist/es/n4s.production.js",
"exports": {
"./compose": {
Expand Down
2 changes: 1 addition & 1 deletion packages/n4s/types/n4s.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,4 @@ type TEnforceMethods = TModifiers & {
context: () => TEnforceContext;
extend: (customRules: TRule) => void;
};
export { enforce as default };
export { enforce };
4 changes: 4 additions & 0 deletions packages/vest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"bugs": {
"url": "https://github.com/ealush/vest.git/issues"
},
"dependencies": {
"n4s": "next",
"context": "next"
},
"homepage": "https://vestjs.dev/",
"exports": {
"./classnames": {
Expand Down
33 changes: 18 additions & 15 deletions vx/config/rollup/rollup.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const fs = require('fs');

const compiler = require('@ampproject/rollup-plugin-closure-compiler');
const replace = require('@rollup/plugin-replace');
const _ = require('lodash');
const { terser } = require('rollup-plugin-terser');
const ts = require('rollup-plugin-ts');

Expand All @@ -15,6 +16,7 @@ const addModulePackageJson = require('./plugins/addModulePackageJson');
const handleExports = require('./plugins/handleExports');

const opts = require('vx/opts');
const packageNames = require('vx/packageNames');
const moduleAliases = require('vx/util/moduleAliases')();
const { usePackage } = require('vx/vxContext');
const vxPath = require('vx/vxPath');
Expand Down Expand Up @@ -124,25 +126,26 @@ function getPlugins({
}),
ts({
tsconfig: resolvedConfig => {
if (packageName === moduleName) {
return resolvedConfig;
}
const clonedConfig = _.cloneDeep(resolvedConfig);

// The changes made in this function allow using the already installed
// module instead of embedding of the code.

// Make the package itself an external in the exported modules
// so that it can be imported in the generated code.
// Remove installed local packages paths list
for (const dep in packageJson().dependencies) {
if (packageNames.names[dep]) {
delete clonedConfig.paths[dep];
}
}

const modified = {
...resolvedConfig,
paths: {
...resolvedConfig.paths,
},
};
if (packageName === moduleName) {
return clonedConfig;
}

// This makes the package itself an external module
// since there is no relative path to it
delete modified.paths[packageName];
// Removes current package from the paths list if in an "exported" module
delete clonedConfig.paths[packageName];

return modified;
return clonedConfig;
},
browserList: ['IE10'],
hook: {
Expand Down

0 comments on commit 38a54ae

Please sign in to comment.