From c4532cc9ccd846e6bc8176414ddf2c0fc22af1f1 Mon Sep 17 00:00:00 2001 From: Ryan Christian <33403762+rschristian@users.noreply.github.com> Date: Wed, 20 Apr 2022 15:14:58 -0500 Subject: [PATCH] docs: compress flag (#940) * docs: Add info on --compress default value * docs: Update CLI help menu --compress info * docs: Adding changeset --- .changeset/big-cameras-attend.md | 5 +++++ README.md | 10 +++++----- src/prog.js | 8 ++++++-- 3 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 .changeset/big-cameras-attend.md diff --git a/.changeset/big-cameras-attend.md b/.changeset/big-cameras-attend.md new file mode 100644 index 00000000..ddfcd845 --- /dev/null +++ b/.changeset/big-cameras-attend.md @@ -0,0 +1,5 @@ +--- +'microbundle': patch +--- + +Adds information about `--compress` flag's default value w/ different targets diff --git a/README.md b/README.md index 26e074d8..bb68aead 100644 --- a/README.md +++ b/README.md @@ -328,19 +328,19 @@ Options --globals Specify globals dependencies, or 'none' --define Replace constants with hard-coded values (use @key=exp to replace an expression) --alias Map imports to different modules - --compress Compress output using Terser + --compress Compress output using Terser (default true when --target is web, false when --target is node) --strict Enforce undefined global context and add "use strict" --name Specify name exposed in UMD and IIFE builds --cwd Use an alternative working directory (default .) --sourcemap Generate source map (default true) --raw Show raw byte size (default false) - --jsx A custom JSX pragma like React.createElement (default: h) - --jsxFragment A custom JSX fragment pragma like React.Fragment (default: Fragment) + --jsx A custom JSX pragma like React.createElement (default h) + --jsxFragment A custom JSX fragment pragma like React.Fragment (default Fragment) --jsxImportSource Declares the module specifier to be used for importing jsx factory functions --tsconfig Specify the path to a custom tsconfig.json --generateTypes Whether or not to generate types, if `types` or `typings` is set in `package.json` then it will default to be `true` - --css Where to output CSS: "inline" or "external" (default: "external") - --css-modules Configures .css to be treated as modules (default: null) + --css Where to output CSS: "inline" or "external" (default "external") + --css-modules Configures .css to be treated as modules (default null) --workers Bundle module workers - see https://git.io/J3oSF (default false) -h, --help Displays this message diff --git a/src/prog.js b/src/prog.js index 6049501c..bbaf7444 100644 --- a/src/prog.js +++ b/src/prog.js @@ -13,7 +13,7 @@ export default handler => { opts.entries = toArray(str || opts.entry).concat(opts._); - if (opts.compress != null) { + if (typeof opts.compress !== 'undefined') { // Convert `--compress true/false/1/0` to booleans: if (typeof opts.compress !== 'boolean') { opts.compress = opts.compress !== 'false' && opts.compress !== '0'; @@ -51,7 +51,11 @@ export default handler => { .example('--define API_KEY=1234') .option('--alias', `Map imports to different modules`) .example('--alias react=preact') - .option('--compress', 'Compress output using Terser', null) + .option( + '--compress', + 'Compress output using Terser (default true when --target is web, false when --target is node)', + ) + .example('build --target web --no-compress') .option('--strict', 'Enforce undefined global context and add "use strict"') .option('--name', 'Specify name exposed in UMD builds') .option('--cwd', 'Use an alternative working directory', '.')