From e88847e71ca090e5750ebac037ea5640525376b0 Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Wed, 14 Jul 2021 22:44:16 -0500 Subject: [PATCH 1/4] feat: Expands generateTypes flag to support TS entries --- src/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 47448a08..5b94c0aa 100644 --- a/src/index.js +++ b/src/index.js @@ -518,10 +518,12 @@ function createConfig(options, entry, format, writeMeta) { tsconfigDefaults: { compilerOptions: { sourceMap: options.sourcemap, - declaration: true, + declaration: emitDeclaration, allowJs: true, emitDeclarationOnly: options.generateTypes && !useTypescript, - declarationDir: getDeclarationDir({ options, pkg }), + ...(emitDeclaration && { + declarationDir: getDeclarationDir({ options, pkg }), + }), jsx: 'preserve', jsxFactory: // TypeScript fails to resolve Fragments when jsxFactory From 8fac54a8277ae178ac5793a96422b5128eafe34c Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Wed, 14 Jul 2021 23:38:55 -0500 Subject: [PATCH 2/4] fix: Returning previous .d.ts generation --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 5b94c0aa..e3314d9a 100644 --- a/src/index.js +++ b/src/index.js @@ -518,10 +518,10 @@ function createConfig(options, entry, format, writeMeta) { tsconfigDefaults: { compilerOptions: { sourceMap: options.sourcemap, - declaration: emitDeclaration, + declaration: options.generateTypes !== false, allowJs: true, emitDeclarationOnly: options.generateTypes && !useTypescript, - ...(emitDeclaration && { + ...(options.generateTypes !== false && { declarationDir: getDeclarationDir({ options, pkg }), }), jsx: 'preserve', From 51c7e85e26a654a9cae79b1263fd9fee1b9e7b0f Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Wed, 14 Jul 2021 23:39:29 -0500 Subject: [PATCH 3/4] test: Modifying `--generateTypes false` test for use on TS projects --- test/__snapshots__/index.test.js.snap | 3 ++- test/fixtures/ts-custom-declaration/package.json | 2 +- test/fixtures/ts-custom-declaration/src/{index.js => index.ts} | 0 3 files changed, 3 insertions(+), 2 deletions(-) rename test/fixtures/ts-custom-declaration/src/{index.js => index.ts} (100%) diff --git a/test/__snapshots__/index.test.js.snap b/test/__snapshots__/index.test.js.snap index e70c9176..3f5ad93e 100644 --- a/test/__snapshots__/index.test.js.snap +++ b/test/__snapshots__/index.test.js.snap @@ -2728,9 +2728,10 @@ ts-custom-declaration index.js.map index.umd.js index.umd.js.map + node_modules package.json src - index.js + index.ts tsconfig.json types index.d.ts diff --git a/test/fixtures/ts-custom-declaration/package.json b/test/fixtures/ts-custom-declaration/package.json index 2fd7573b..00a923ee 100644 --- a/test/fixtures/ts-custom-declaration/package.json +++ b/test/fixtures/ts-custom-declaration/package.json @@ -2,7 +2,7 @@ "name": "ts-custom-declarations", "main": "dist/index.js", "types": "types/index.d.ts", - "source": "src/index.js", + "source": "src/index.ts", "scripts": { "build": "microbundle --generateTypes false" } diff --git a/test/fixtures/ts-custom-declaration/src/index.js b/test/fixtures/ts-custom-declaration/src/index.ts similarity index 100% rename from test/fixtures/ts-custom-declaration/src/index.js rename to test/fixtures/ts-custom-declaration/src/index.ts From 26777482553c43969de63398f2b1c9600e7ffdc4 Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Wed, 14 Jul 2021 23:49:09 -0500 Subject: [PATCH 4/4] docs: Adding changeset --- .changeset/slimy-roses-explain.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/slimy-roses-explain.md diff --git a/.changeset/slimy-roses-explain.md b/.changeset/slimy-roses-explain.md new file mode 100644 index 00000000..0a4c75ae --- /dev/null +++ b/.changeset/slimy-roses-explain.md @@ -0,0 +1,5 @@ +--- +'microbundle': patch +--- + +Expands generateTypes flag to support libs with TS entrypoints