Skip to content

Commit

Permalink
vx: run all formats at once (#909)
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Jul 20, 2022
1 parent 8284ce2 commit 5b93c8c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [16.x]
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -26,4 +26,4 @@ jobs:
uses: ArtiomTr/jest-coverage-report-action@v2
with:
skip-step: install
test-script: yarn test
test-script: yarn jest
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"prepare": "husky install",
"dev": "vx dev",
"website:start": "yarn workspace website start",
"website:build": "yarn workspace website build"
"website:build": "yarn workspace website build",
"jest": "jest"
},
"prettier": {
"arrowParens": "avoid",
Expand Down
9 changes: 8 additions & 1 deletion vx/config/rollup/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ const yargs = require('yargs/yargs');

const opts = require('vx/opts');

const format = yargs(process.argv).argv.format;
const format = [].concat(
yargs(process.argv).argv.format ?? [
opts.format.CJS,
opts.format.ES,
opts.format.UMD,
]
);

const disallowExternals = format === opts.format.UMD;

module.exports = {
Expand Down
24 changes: 5 additions & 19 deletions vx/config/rollup/rollup.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,9 @@ module.exports = cleanupConfig(
env => {
const packageName = usePackage();

const customConfigPath = vxPath.packageConfigPath(
packageName,
opts.fileNames.VX_BUILD
);

let customConfig;

if (fs.existsSync(customConfigPath)) {
customConfig = require(customConfigPath);
}

return [].concat(
genBaseConfig({ env, packageName }),
genExportsConfig(usePackage(), env),
customConfig?.({
getInputFile,
getPlugins: (options = {}) =>
getPlugins({ env, packageName, ...options }),
genOutput: (options = {}) => genOutput({ env, ...options }),
}) ?? []
genExportsConfig(usePackage(), env)
);
}
)
Expand Down Expand Up @@ -75,7 +58,9 @@ function genBaseConfig({
].filter(Boolean),

input: getInputFile(moduleName),
output: genOutput({ env, moduleName, namespace }),
output: format.map(format =>
genOutput({ env, format, moduleName, namespace })
),
plugins: getPlugins({ env, moduleName, namespace, packageName }),
};
}
Expand All @@ -90,6 +75,7 @@ function genOutput({
moduleName = usePackage(),
env,
namespace = undefined,
format,
} = {}) {
const base = {
exports: 'auto',
Expand Down
2 changes: 1 addition & 1 deletion vx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-ts": "^3.0.2",
"ts-jest": "^28.0.3",
"vest-utils": "^0.0.2",
"vest-utils": "0.0.2",
"yargs": "^17.5.1"
},
"name": "vx",
Expand Down
15 changes: 8 additions & 7 deletions vx/scripts/build/buildPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ function buildPackage(options = {}) {
process.env.VX_PACKAGE_NAME = name;
process.env.VX_BUILD_SINGLE = !!options.buildSingle;

let builds;
const format = [];

if (options.buildSingle) {
builds = [opts.format.CJS];
} else {
builds = [opts.format.ES, opts.format.UMD, opts.format.CJS];
format.push(opts.format.CJS);
}

builds.forEach(format => {
exec([`rollup -c`, vxPath.ROLLUP_CONFIG_PATH, `--format=${format}`]);
});
exec([
`rollup -c`,
vxPath.ROLLUP_CONFIG_PATH,
format.length && `--format=${format}`,
]);

delete process.env.VX_PACKAGE_NAME;
delete process.env.VX_BUILD_SINGLE;
}
Expand Down

1 comment on commit 5b93c8c

@vercel
Copy link

@vercel vercel bot commented on 5b93c8c Jul 20, 2022

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-git-latest-ealush.vercel.app
vest-website.vercel.app
vest-next.vercel.app
vest-next-ealush.vercel.app

Please sign in to comment.