Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: Expands generateTypes flag to support TS entries #865

Merged
merged 4 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slimy-roses-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'microbundle': patch
---

Expands generateTypes flag to support libs with TS entrypoints
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,12 @@ function createConfig(options, entry, format, writeMeta) {
tsconfigDefaults: {
compilerOptions: {
sourceMap: options.sourcemap,
declaration: true,
declaration: options.generateTypes !== false,
allowJs: true,
emitDeclarationOnly: options.generateTypes && !useTypescript,
declarationDir: getDeclarationDir({ options, pkg }),
...(options.generateTypes !== false && {
declarationDir: getDeclarationDir({ options, pkg }),
}),
jsx: 'preserve',
jsxFactory:
// TypeScript fails to resolve Fragments when jsxFactory
Expand Down
3 changes: 2 additions & 1 deletion test/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2728,9 +2728,10 @@ ts-custom-declaration
index.js.map
index.umd.js
index.umd.js.map
node_modules
Copy link
Owner

@developit developit Jul 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to fix CI

Suggested change
node_modules

Copy link
Collaborator Author

@rschristian rschristian Jul 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clicked "Commit suggestion" too fast there. What was not working w/ the CI? Seemed to be passing w/out any issues?

When rpt2 is used, it creates some cache files in node_modules. As this test now uses a TS entry point, rpt2 will be used.

package.json
src
index.js
index.ts
tsconfig.json
types
index.d.ts
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/ts-custom-declaration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down