mirror of
https://github.com/developit/microbundle.git
synced 2026-01-25 14:06:50 +00:00
Add --generate-types option (#589)
This commit is contained in:
parent
fdafaf7a4a
commit
25b2b62d24
@ -364,6 +364,7 @@ function createConfig(options, entry, format, writeMeta) {
|
||||
: () => resolve(options.cwd, 'mangle.json');
|
||||
|
||||
const useTypescript = extname(entry) === '.ts' || extname(entry) === '.tsx';
|
||||
const emitDeclaration = !!(options.generateTypes || pkg.types || pkg.typings);
|
||||
|
||||
const escapeStringExternals = ext =>
|
||||
ext instanceof RegExp ? ext.source : escapeStringRegexp(ext);
|
||||
@ -476,7 +477,7 @@ function createConfig(options, entry, format, writeMeta) {
|
||||
map: null,
|
||||
}),
|
||||
},
|
||||
useTypescript &&
|
||||
(useTypescript || emitDeclaration) &&
|
||||
typescript({
|
||||
typescript: require(resolveFrom.silent(
|
||||
options.cwd,
|
||||
@ -488,6 +489,8 @@ function createConfig(options, entry, format, writeMeta) {
|
||||
compilerOptions: {
|
||||
sourceMap: options.sourcemap,
|
||||
declaration: true,
|
||||
allowJs: true,
|
||||
emitDeclarationOnly: options.generateTypes && !useTypescript,
|
||||
declarationDir: getDeclarationDir({ options, pkg }),
|
||||
jsx: 'preserve',
|
||||
jsxFactory:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user