From 7fb4f08224be2f7a3f283393cc4c8b6ebfe5c549 Mon Sep 17 00:00:00 2001 From: Aleksandar Benic Date: Mon, 22 Oct 2018 21:18:43 +0000 Subject: [PATCH] feat(sourcemaps): support for ts sourcemaps and invert sourcemap flag (#227) Closes #216. --- src/index.js | 12 ++++++++++-- src/prog.js | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 6a9ff1e..de9de11 100644 --- a/src/index.js +++ b/src/index.js @@ -86,6 +86,10 @@ export default async function microbundle(options) { options.name = options.name || options.pkg.amdName || safeVariableName(options.pkg.name); + if (options.sourcemap !== false) { + options.sourcemap = true; + } + const jsOrTs = async filename => resolve( cwd, @@ -345,7 +349,11 @@ function createConfig(options, entry, format, writeMeta) { typescript: require('typescript'), cacheRoot: `./.rts2_cache_${format}`, tsconfigDefaults: { - compilerOptions: { declaration: true, jsx: options.jsx }, + compilerOptions: { + sourceMap: options.sourcemap, + declaration: true, + jsx: options.jsx, + }, }, }), !useTypescript && flow({ all: true, pretty: true }), @@ -452,7 +460,7 @@ function createConfig(options, entry, format, writeMeta) { legacy: true, freeze: false, esModule: false, - sourcemap: options.sourcemap !== false, + sourcemap: options.sourcemap, treeshake: { propertyReadSideEffects: false, }, diff --git a/src/prog.js b/src/prog.js index ea17d0d..a3cd745 100644 --- a/src/prog.js +++ b/src/prog.js @@ -27,6 +27,7 @@ export default handler => { .option('--name', 'Specify name exposed in UMD builds') .option('--cwd', 'Use an alternative working directory', '.') .option('--sourcemap', 'Generate source map', true) + .example("microbundle --no-sourcemap # don't generate sourcemaps") .option('--raw', 'Show raw byte size', false) .option( '--jsx',