feat(sourcemaps): support for ts sourcemaps and invert sourcemap flag (#227)

Closes  #216.
This commit is contained in:
Aleksandar Benic 2018-10-22 21:18:43 +00:00 committed by Leah
parent 41553421b0
commit 7fb4f08224
2 changed files with 11 additions and 2 deletions

View File

@ -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,
},

View File

@ -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',