From 845c6c587352f8aabf3b8c5d69375d965f699501 Mon Sep 17 00:00:00 2001 From: Cristian Bote Date: Mon, 5 Feb 2018 16:10:22 +0200 Subject: [PATCH 1/5] Added source-map option --- src/cli.js | 3 ++- src/index.js | 2 +- test/index.test.js | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cli.js b/src/cli.js index 95b04c0..88e67db 100644 --- a/src/cli.js +++ b/src/cli.js @@ -18,7 +18,8 @@ prog .option('--compress', 'Compress output using UglifyJS', true) .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', '.'); + .option('--cwd', 'Use an alternative working directory', '.') + .option('--source-map', 'Enable the source map', true); prog .command('build [...entries]', '', { default: true }) diff --git a/src/index.js b/src/index.js index 9db4b24..91ec9e8 100644 --- a/src/index.js +++ b/src/index.js @@ -310,7 +310,7 @@ function createConfig(options, entry, format, writeMeta) { strict: options.strict===true, legacy: true, freeze: false, - sourcemap: true, + sourcemap: options.sourcemap===true || options.sourceMap===true, treeshake: { propertyReadSideEffects: false }, diff --git a/test/index.test.js b/test/index.test.js index c5f5826..9fe2770 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -28,7 +28,8 @@ describe('fixtures', () => { it(fixtureDir, async () => { const output = await microbundle({ cwd: path.resolve(fixturePath), - formats: 'es,cjs,umd' + formats: 'es,cjs,umd', + sourceMap: true }); const printedDir = printTree([dirTree(fixturePath)]); From 9cd9a068514f4e6cde89d2ad810428b94cbf509b Mon Sep 17 00:00:00 2001 From: Cristian Bote Date: Mon, 5 Feb 2018 16:13:55 +0200 Subject: [PATCH 2/5] Ammend the test to reflect the defaults --- test/index.test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/index.test.js b/test/index.test.js index 9fe2770..c5f5826 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -28,8 +28,7 @@ describe('fixtures', () => { it(fixtureDir, async () => { const output = await microbundle({ cwd: path.resolve(fixturePath), - formats: 'es,cjs,umd', - sourceMap: true + formats: 'es,cjs,umd' }); const printedDir = printTree([dirTree(fixturePath)]); From 67b7c52054aacbad948f7c1d28b518e0fc7a877d Mon Sep 17 00:00:00 2001 From: Cristian Bote Date: Mon, 5 Feb 2018 16:43:04 +0200 Subject: [PATCH 3/5] Added better value checking --- src/cli.js | 2 +- src/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cli.js b/src/cli.js index 88e67db..2561ce2 100644 --- a/src/cli.js +++ b/src/cli.js @@ -19,7 +19,7 @@ prog .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', '.') - .option('--source-map', 'Enable the source map', true); + .option('--sourcemap', 'Generate source map', true); prog .command('build [...entries]', '', { default: true }) diff --git a/src/index.js b/src/index.js index 91ec9e8..5f3067c 100644 --- a/src/index.js +++ b/src/index.js @@ -310,7 +310,7 @@ function createConfig(options, entry, format, writeMeta) { strict: options.strict===true, legacy: true, freeze: false, - sourcemap: options.sourcemap===true || options.sourceMap===true, + sourcemap: options.sourcemap===true || options.sourcemap===undefined, treeshake: { propertyReadSideEffects: false }, From b4dcc27fe02a19d75576a7074b5966ca603810fa Mon Sep 17 00:00:00 2001 From: Cristian Bote Date: Tue, 6 Feb 2018 00:00:08 +0200 Subject: [PATCH 4/5] Drop the undefined check and just use the ! check --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 5f3067c..0a4c344 100644 --- a/src/index.js +++ b/src/index.js @@ -310,7 +310,7 @@ function createConfig(options, entry, format, writeMeta) { strict: options.strict===true, legacy: true, freeze: false, - sourcemap: options.sourcemap===true || options.sourcemap===undefined, + sourcemap: options.sourcemap!==false, treeshake: { propertyReadSideEffects: false }, From fdf9034f9e4b530f0373f0580567a744e4e9f303 Mon Sep 17 00:00:00 2001 From: Cristian Bote Date: Tue, 6 Feb 2018 00:07:37 +0200 Subject: [PATCH 5/5] Update readme with --sourcemap option --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6c04240..8bbc6ee 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ Just like `microbundle build`, but watches your source files and rebuilds on any --strict Enforce undefined global context and add "use strict" --name Specify name exposed in UMD builds --cwd Use an alternative working directory (default .) + --sourcemap Generate source map (default true) -h, --help Displays this message ```