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

fix: unexpected skip of emit in TS compiler and double compilation of dynamic imports #6177

Merged
merged 11 commits into from
Jun 10, 2020

Conversation

bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Jun 8, 2020

Fixes #6082
Fixes #5982
Fixes #6057
Fixes #6144

Comment on lines 1170 to 1177
// If `checkJs` is off we still might be compiling entry point JavaScript file
// (if it has `.ts` imports), but it won't be emitted.
if (options.checkJs) {
assert(
emitResult.emitSkipped === false,
"Unexpected skip of the emit."
);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This assertion is only half a fix. @kitsonk I'm gonna need your advice here. Let me describe what's was going on pre-1.0.3 and what's going on past-1.0.3.

pre-1.0.3
If an entry point was a .js file that had .ts imports then TS compiler worker was spawned for each import.
All dependencies from the .ts import were transpiled and cached to disk (this led to situation were the same .ts file might have been transpiled and cached multiple times in a single run).

post-1.0.3
If an entry point is a .js file that has .ts imports then TS compiler worker is created once and starts compilation with the .js entry point. If checkJs setting is not passed then I have found that TS compiler doesn't check and emit .ts imports. I guess that makes sense, but... I do want to start TS compiler with .js entry point and I do want it to check and transpile only .ts source files. @kitsonk is there a compiler option we could use to make it behave that way?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess I'm talking about changing default value of allowJs to true...

Copy link
Contributor

Choose a reason for hiding this comment

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

I see about changing. I think this is related problem.
#6176

Will it be a restriction for JavaScript with TypeScript on Deno?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, yes, allowJs needs to be on in those situations. The problem with it being on all the time is that is goes and loads huge bits of JavaScript and parses them, even with checkJs false. So I think if the dep graph has some sort of ".js loading .ts" when we should turn it on, but only then... if that ".ts loading .js that only loads other .js" should be off.

@bartlomieju bartlomieju changed the title [WIP] fix: unexpected skip of emit in TS compiler fix: unexpected skip of emit in TS compiler Jun 9, 2020
@bartlomieju
Copy link
Member Author

@ry @kitsonk please review

@bartlomieju bartlomieju changed the title fix: unexpected skip of emit in TS compiler fix: unexpected skip of emit in TS compiler and double compilation of dynamic imports Jun 9, 2020
@bartlomieju bartlomieju requested a review from ry June 9, 2020 13:07
@bartlomieju bartlomieju added bug Something isn't working correctly cli related to cli/ dir labels Jun 9, 2020
Copy link
Contributor

@kitsonk kitsonk left a comment

Choose a reason for hiding this comment

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

Hard to totally grok in isolation, but looks like the right direction.

cli/global_state.rs Outdated Show resolved Hide resolved
cli/global_state.rs Outdated Show resolved Hide resolved
cli/global_state.rs Outdated Show resolved Hide resolved
cli/tsc.rs Show resolved Hide resolved
cli/global_state.rs Outdated Show resolved Hide resolved
cli/global_state.rs Outdated Show resolved Hide resolved
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly cli related to cli/ dir
Projects
None yet
4 participants