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: support ".ts" modules #32

Merged
merged 3 commits into from
Jun 7, 2019
Merged

feat: support ".ts" modules #32

merged 3 commits into from
Jun 7, 2019

Conversation

aleclarson
Copy link
Contributor

This compiles ".ts" modules into ".d.ts" modules in-memory and forwards them to Rollup.

This removes the need for intermediate files.

Fixes #31

This compiles ".ts" modules into ".d.ts" modules in-memory and forwards them to Rollup.

This removes the need for intermediate files.

Fixes Swatinem#31
Copy link
Owner

@Swatinem Swatinem left a comment

Choose a reason for hiding this comment

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

looks good in general.

The problem with createProgram is that it is an ahead-of-time operation, as is evident from the heavily increased runtime of the testsuite.

So in order not to regress performance in that case, it would be nice to:

  • prefer .d.ts over .tsx? files inside the resolveId, essentially restoring it to what it was before
  • lazily call createProgram inside of load when you hit a .tsx? file

I’m not quite sure though if calling createProgram lazily will pick up all the files / compilerOptions correctly (when you don’t start from the entry-point)

src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
Co-Authored-By: Arpad Borsos <arpad.borsos@googlemail.com>
@aleclarson
Copy link
Contributor Author

aleclarson commented Jun 6, 2019

lazily call createProgram inside of load when you hit a .tsx? file

Instead, I'm going to only use createProgram when the entry point is a .tsx? file :)

Using a .d.ts entry point means you're only using ambient declarations

Note: If you mix .ts and .d.ts entry points, they will all have ts.createProgram called on them. Just for simplicity's sake in the implementation.

@aleclarson
Copy link
Contributor Author

aleclarson commented Jun 6, 2019

The failing tests are now unrelated to this PR.

LGTM 👍

@Swatinem
Copy link
Owner

Swatinem commented Jun 6, 2019

The failing tests are now unrelated to this PR.

They are related, since you now return .ts instead of .d.ts from the resolveId hook.

I can take care of this tomorrow when I’m at my work machine.

@Swatinem Swatinem merged commit bc3cee0 into Swatinem:master Jun 7, 2019
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.

Support non-ambient ".ts" modules
2 participants