Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: generate declaration files #4

Merged
merged 15 commits into from
Apr 8, 2021
Merged

feat: generate declaration files #4

merged 15 commits into from
Apr 8, 2021

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented Mar 8, 2021

Reference: https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API#getting-the-dts-from-a-javascript-file

Note that generating .d.ts files will dramatically increase the time required to run mkdist (from order of 50-100ms to 7-10s 500ms).

TODO:

  • generates declarations for .vue files
  • generates declarations for .ts files
  • generates declarations for .js files
  • add cli option
  • use file cache rather than reading files from disk
  • enable by default

Closes #2

src/loaders/dts.ts Outdated Show resolved Hide resolved
src/loaders/dts.ts Outdated Show resolved Hide resolved
@danielroe
Copy link
Member Author

I've managed to improve performance but it's still 10x longer to emit types than just transpile the files. I can imagine enabling it when using siroc, but perhaps we leave disabled by default when running mkdist?

src/loaders/js.ts Outdated Show resolved Hide resolved
src/loaders/dts.ts Outdated Show resolved Hide resolved
@pi0
Copy link
Member

pi0 commented Mar 9, 2021

I've managed to improve performance but it's still 10x longer to emit types than just transpile the files. I can imagine enabling it when using siroc, but perhaps we leave disabled by default when running mkdist?

@danielroe I was going to benchmark as well. Yes disabling by default makes sense. We may be able to reuse same instance of typescript compiler across files and do it off-thread using a worker (for later)

@danielroe danielroe requested a review from pi0 April 7, 2021 22:38
@pi0
Copy link
Member

pi0 commented Apr 8, 2021

Typescript compiler is anyway slow but performance should be fixed by 421b200. It think it would be nice we add support for vue-dts-gen too (or a vue-demi wrapper)

pi0 added 2 commits April 8, 2021 10:47
extra-testing is evil! It makes harder to iterate
@pi0 pi0 changed the title feat: support generating .d.ts declaration files feat: generate declaration files Apr 8, 2021
@pi0 pi0 merged commit 4b54426 into main Apr 8, 2021
@pi0 pi0 deleted the 2-dts-generation branch April 8, 2021 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.d.ts generation
2 participants