Skip to content

Commit 85bff2c

Browse files
committed
bundle: add name CLI option and use it
1 parent 97b578f commit 85bff2c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@
149149
"build:all": "npm run clean:build && npm run build:wasm:release && npm run bundle && npm run bundle:min && npm run build",
150150
"build:wasm:debug": "mkdir -p dist && cd ./src/parsers/manifest/dash/wasm-parser && cargo build --target wasm32-unknown-unknown && cp target/wasm32-unknown-unknown/debug/mpd_node_parser.wasm ../../../../../dist/mpd-parser.wasm",
151151
"build:wasm:release": "bash ./scripts/build_wasm_release.sh",
152-
"bundle": "node ./scripts/run_bundler.mjs src/index.ts --production-mode --globals -o dist/rx-player.js",
153-
"bundle:min": "node ./scripts/run_bundler.mjs src/index.ts --production-mode --globals -o dist/rx-player.min.js --minify",
152+
"bundle": "node ./scripts/run_bundler.mjs src/index.ts --production-mode --globals --name \"RxPlayer default bundle\" -o dist/rx-player.js",
153+
"bundle:min": "node ./scripts/run_bundler.mjs src/index.ts --production-mode --globals --name \"RxPlayer minified bundle\" -o dist/rx-player.min.js --minify",
154154
"certificate": "bash ./scripts/generate_certificate",
155155
"check": "npm run check:types && npm run lint && npm run check:types:unit_tests",
156156
"check:all": "npm run check:types && npm run lint && npm run lint:demo && npm run lint:tests && npm run lint:scripts && npm run test:unit && npm run test:integration && npm run test:memory && node -r esm ./scripts/check_nodejs_import_compatibility.js",

scripts/run_bundler.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
148148
let globalScope = false;
149149
let outputFile = "";
150150
let silent = false;
151+
let name;
151152

152153
if (args[0] === "-h" || args[0] === "--help") {
153154
displayHelp();
@@ -187,6 +188,19 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
187188
silent = true;
188189
break;
189190

191+
case "-n":
192+
case "--name":
193+
{
194+
argOffset++;
195+
name = args[argOffset];
196+
if (name === undefined) {
197+
console.error("ERROR: no name provided\n");
198+
displayHelp();
199+
process.exit(1);
200+
}
201+
}
202+
break;
203+
190204
case "-o":
191205
case "--output":
192206
{
@@ -231,6 +245,7 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
231245
globalScope,
232246
silent,
233247
outfile: outputFile,
248+
name,
234249
}).catch((err) => {
235250
console.error(`ERROR: ${err}\n`);
236251
process.exit(1);
@@ -257,6 +272,7 @@ Available options:
257272
-m, --minify Minify the built bundle.
258273
-p, --production-mode Build all files in production mode (less runtime checks, mostly).
259274
-g, --globals Add the RxPlayer to the global scope.
275+
-n, --name Optional "name" to refer to your bundle. Will be used for in log output outputs.
260276
-s, --silent Don't log to stdout/stderr when bundling.
261277
-w, --watch Re-build each time any of the files depended on changed.`,
262278
);

0 commit comments

Comments
 (0)