-
Notifications
You must be signed in to change notification settings - Fork 47k
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: support typescript namespace #22601
Conversation
Can you add a regression test? So, a test that fails without this change. |
Comparing: 996da67...2839452 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
@gaearon during my invastigation in source code of vite I noticed that in order to create code that is failing it do following things:
After first step there is still TS code. It is being compiled in second step. |
@ideffix I tried running your changes on the issue example and the ReferenceError still appears. I followed instructions from https://reactjs.org/docs/how-to-contribute.html to try your changes locally (npm). I might have done it wrongly, is this the right way to test your change locally? Writing a failing test and passing it confers highest confidence for the changes you did. From what I understand, Babel transpiles directly from TS to JS, so you shouldn't expect any remaining TS code in there (https://www.typescriptlang.org/docs/handbook/babel-with-typescript.html). esbuild is not related to this issue as far as I understand it, so we shouldn't need it in integration or unit tests. |
@owen-kosman in order to check this locally follow these steps:
About babel and TS - yes it transpiles TS code into JS but only if you add relevant plugins/presets. According to source code of vite it is using babel with react-refresh plugin but without TS plugins/presets so after this step there is still Typescript code which is being transpiled later in a process using So in order to reporduce this issue in integration test - I needed to transpile it in 2 steps:
If we merge this babel configs into one this error will not occur (it works as expected) so in my integration test I just reproduce steps that vite is doing. |
@ideffix hi, i think this bug is about the plugin doesn't understand typescript syntax, so its not related to transform typescript. no need for adding |
hi @irinakk , sure I would love to see your fix 😃 |
This was fixed in #22621. |
Summary
This PR is possible fix for #22413. It solves bug with
namespace
and vite. Related issue.How did you test this change?
I created a simple app like mentioned in #22413 and then I applied the same changes directly in
node_modules
of this app. This change is solving mentioned issue.