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

Consider changing project direction #29

Closed
Swatinem opened this issue Jun 2, 2019 · 3 comments
Closed

Consider changing project direction #29

Swatinem opened this issue Jun 2, 2019 · 3 comments
Assignees

Comments

@Swatinem
Copy link
Owner

Swatinem commented Jun 2, 2019

I have been thinking a lot lately about TS project management in general and even started a small blog series on this topic. This, combined with some issues and requests for this projects made me rethink the project direction.

I would appreciate some feedback on these ideas.
CC @aleclarson @robhicks @timocov @octogonz

How it works now

The plugin currently uses the typescript createProgram and emit APIs to basically typecheck your whole code ahead of time, and emit declaration files for each source file.

This is:

  • not really good for performance
  • a huge pain to manage all the compilerOptions, and to use the ts API in general.
  • I’m sure I miss/supress some useful diagnostics along the way
  • It interferes badly with rollup watch Plugin interferes with Rollup watch #15

How I think it should work in the future

I think to move forward, its needed to take a step back. Let some other tool worry about compiling typescript, and focus only on bundling pre-generated .d.ts files, similar to how api-extractor works.

So it would use the typescript compiler as a parser only.

Pros

  • would follow do only one thing and do it well
  • would massively simplify the plugin itself
  • should improve performance slightly?
  • would work better with watch mode
  • would give users more freedom about how they want to compile their TS code (--incremental, etc), and about how they want to bundle their .js code.

Cons

  • would not be single-dependency / zero-config anymore
  • would require users to deal with .ts -> .js / .d.ts compilation themselves
  • watch mode would require two separate watchers (tsc --watch and rollup --watch?)
@Swatinem Swatinem self-assigned this Jun 2, 2019
@timocov
Copy link

timocov commented Jun 2, 2019

and focus only on bundling pre-generated .d.ts files

Wow, I've thought about it in case of dts-bundle-generator too 🙂. The last what I decide is check if all files in the compilation is declaration files, then do not compile them again and just use the current compilation. It should allow to set declaration file as input file (you can do it already) and improve performance as well.

would give users more freedom about how they want to compile their TS code (--incremental, etc), and about how they want to bundle their .js code.

It looks like there is a bug in the compiler (microsoft/TypeScript#31696) and it can broke a pipeline in some cases (yeah, it don't work for composite projects only for now).

watch mode would require two separate watchers (tsc --watch and rollup --watch?)

For me it's not a big problem. In current project I'm working on (https://github.com/tradingview/lightweight-charts) we don't use any plugin for rollup to work with TypeScript and compile it with tsc first and then bundle with rollup.

@aleclarson
Copy link
Contributor

I'm in favor of this new direction. I'll be using rollup-plugin-typescript2 instead, which has its own caching system and it works with watch mode more or less. Less work for you, too!

Swatinem added a commit that referenced this issue Jun 3, 2019
the plugin now only supports `.d.ts` files as inputs, #29
@Swatinem
Copy link
Owner Author

Swatinem commented Jun 3, 2019

just published 1.0.0-alpha.0 to next, which does this :-)

Also, I think I found a workaround for import * as X and all the other namespace related issues 🎉

I will try this version with one of my other projects, clean up the readme/docs a bit and then release it as 1.0.0 :-)

@timocov the @renovate-bot also pointed me to a recent regression in typescript related to exporting namespace declarations: microsoft/TypeScript#31676 maybe that is also relevant for you.

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

No branches or pull requests

3 participants