Skip to content

Commit

Permalink
vx: treat locally installed as externals
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Dec 12, 2021
1 parent 1384c08 commit dbea7ac
Show file tree
Hide file tree
Showing 4 changed files with 363 additions and 284 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"@typescript-eslint/parser": "^4.24.0",
"eslint": "^7.26.0",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-import": "^2.23.3",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jest": "^23.20.0",
"faker": "^5.5.3",
"husky": "^7.0.0",
Expand Down
25 changes: 22 additions & 3 deletions vx/config/rollup/rollup.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ function cleanupConfig(configs) {
return []
.concat(...configs)
.filter(Boolean)
.map(({ input, output, plugins }) => ({ input, output, plugins }));
.map(({ input, output, plugins, external }) => ({
external,
input,
output,
plugins,
}));
}

function genBaseConfig({
Expand All @@ -68,6 +73,12 @@ function genBaseConfig({
}) {
return {
env,
// This turns the installed "internal" dependencies into external dependencies
external: [
...Object.keys(packageJson()?.dependencies ?? {}),
moduleName === usePackage() ? null : usePackage(),
].filter(Boolean),

input: getInputFile(moduleName),
output: genOutput({ env, moduleName, namespace }),
plugins: getPlugins({ env, moduleName, namespace, packageName }),
Expand Down Expand Up @@ -97,15 +108,23 @@ function genOutput({
];

function outputByFormat(format) {
// creates "globals" from the installed internal packages
const globals = Object.keys(packageJson()?.dependencies ?? {}).reduce(
(g, c) => Object.assign(g, { [c]: c }),
{
...(moduleName !== usePackage() && { [usePackage()]: usePackage() }),
}
);
return {
...base,
format,
file: vxPath.packageDist(
usePackage(),
format,
namespace,
joinTruthy([moduleName, env, 'js'], '.')
),
format,
globals,
};
}
}
Expand Down Expand Up @@ -143,7 +162,7 @@ function getPlugins({
// module instead of embedding of the code.

// Remove installed local packages paths list
for (const dep in packageJson().dependencies) {
for (const dep in packageJson()?.dependencies ?? {}) {
if (packageNames.names[dep]) {
delete clonedConfig.paths[dep];
}
Expand Down
4 changes: 2 additions & 2 deletions vx/scripts/release/genDiffData.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { TAG_NEXT, TAG_DEV } = require('./releaseKeywords');

const logger = require('vx/logger');
const {
isStableBranch,
isIntegrationBranch,
isReleaseBranch,
isNextBranch,
} = require('vx/util/taggedBranch');
Expand Down Expand Up @@ -49,7 +49,7 @@ function pickTagId(nextVersion) {
return `${nextVersion}-${TAG_NEXT}-${commitHash}`;
}

if (isStableBranch) {
if (isIntegrationBranch) {
return `${nextVersion}-${TAG_DEV}-${commitHash}`;
}

Expand Down

0 comments on commit dbea7ac

Please sign in to comment.