Skip to content

Commit

Permalink
docs: compress flag (#940)
Browse files Browse the repository at this point in the history
* docs: Add info on --compress default value

* docs: Update CLI help menu --compress info

* docs: Adding changeset
  • Loading branch information
rschristian authored Apr 20, 2022
1 parent b51b855 commit c4532cc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/big-cameras-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'microbundle': patch
---

Adds information about `--compress` flag's default value w/ different targets
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions src/prog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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', '.')
Expand Down

0 comments on commit c4532cc

Please sign in to comment.