Skip to content

Commit

Permalink
Build wrapper (#6239)
Browse files Browse the repository at this point in the history
* added build wrapper for better build customisation

* updated gitignore to ignore tree-* html files

* reverted tree changes (allow for multiple args at once)

* fixed arg propagation in build wrapper

* Updated comments in build.mjs

* cleaned up build script comments

* minor refactor in package json
  • Loading branch information
kpal81xd authored Apr 10, 2024
1 parent 156e659 commit 5d7f70e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.idea/
.vscode/
build
tree*.html
coverage
docs
examples/dist
Expand Down
38 changes: 38 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Build helper scripts
* Usage: node build.mjs [options] -- [rollup options]
*
* Options:
* target:<moduleFormat>:<buildType> - Specify the target module format and build type. Example: target:esm:release
* target:<moduleFormat> - Specify the target module format only. Example: target:esm
* target:<buildType> - Specify the build type only. Example: target:release
*
* treemap - Enable treemap build visualization.
* treenet - Enable treenet build visualization.
* treesun - Enable treesun build visualization.
*/

import { execSync } from 'child_process';

const args = process.argv.slice(2);

const ENV_START_MATCHES = [
'target',
'treemap',
'treenet',
'treesun'
];

const env = [];
for (let i = 0; i < args.length; i++) {
if (ENV_START_MATCHES.some(match => args[i].startsWith(match))) {
env.push(`--environment ${args[i]}`);
args.splice(i, 1);
i--;
continue;
}
}

const cmd = `rollup -c ${args.join(' ')} ${env.join(' ')}`;
console.log(cmd);
execSync(cmd, { stdio: 'inherit' });
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,29 +124,29 @@
"xhr2": "^0.2.1"
},
"scripts": {
"build": "rollup -c",
"build:release": "rollup -c --environment target:release",
"build:debug": "rollup -c --environment target:debug",
"build:profiler": "rollup -c --environment target:profiler",
"build:extras": "rollup -c --environment target:extras",
"build:types": "rollup -c --environment target:types",
"build:umd": "rollup -c --environment target:umd",
"build:esm": "rollup -c --environment target:esm",
"build:esm:release": "rollup -c --environment target:esm:release",
"build:esm:debug": "rollup -c --environment target:esm:debug",
"build:treemap": "npm run build:umd -- --environment treemap",
"build:treenet": "npm run build:umd -- --environment treenet",
"build:treesun": "npm run build:umd -- --environment treesun",
"build": "node build.mjs",
"build:release": "npm run build target:release",
"build:debug": "npm run build target:debug",
"build:profiler": "npm run build target:profiler",
"build:extras": "npm run build target:extras",
"build:types": "npm run build target:types",
"build:umd": "npm run build target:umd",
"build:esm": "npm run build target:esm",
"build:esm:release": "npm run build target:esm:release",
"build:esm:debug": "npm run build target:esm:debug",
"build:treemap": "npm run build target:umd treemap",
"build:treenet": "npm run build target:umd treenet",
"build:treesun": "npm run build target:umd treesun",
"build:sourcemaps": "npm run build -- -m",
"build:publish": "npm run build && npm run build:types && npm run publint",
"build:publish": "npm run build && npm run publint",
"watch": "npm run build -- -w",
"watch:release": "npm run build:release -- -w",
"watch:debug": "npm run build:debug -- -w",
"watch:profiler": "npm run build:profiler -- -w",
"watch:umd": "npm run build:umd -- -w",
"watch:esm": "npm run build:esm -- -w",
"watch:esm:release": "npm run build:esm:release -- -w",
"watch:esm:debug": "npm run build:esm:debug -- -w",
"watch:release": "npm run build target:release -- -w",
"watch:debug": "npm run build target:debug -- -w",
"watch:profiler": "npm run build target:profiler -- -w",
"watch:umd": "npm run build target:umd -- -w",
"watch:esm": "npm run build target:esm -- -w",
"watch:esm:release": "npm run build target:esm:release -- -w",
"watch:esm:debug": "npm run build target:esm:debug -- -w",
"docs": "typedoc",
"lint": "eslint --ext .js,.mjs extras scripts src test utils rollup.config.mjs",
"publint": "publint",
Expand Down

0 comments on commit 5d7f70e

Please sign in to comment.