test(pack): add verbatimModuleSyntax test case#2655
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a crucial test case to validate the interaction between TypeScript's Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds a test case for verbatimModuleSyntax and updates an existing test to use TypeScript. The changes are logical and contribute to better test coverage. I've found a few minor style issues that could improve code consistency. Specifically, some new files are missing a final newline, and there's an opportunity to use a self-closing tag for a React component.
test case is no need to review, just keep it |
In utoo case, we need to support react classic jsx transform(To
compitable with react 16 or above project).
We have a case like:
```ts
// index.ts
import React from 'react';
export const App = () => <div></div>;
```
Under the classic jsx transform, the jsx will be transformed as follows:
```ts
export const App = () => React.createElement("div", /***/);
```
But turbopack's jsx transform was behind typescript transform, so in the
stage of typescript transform, the import of react will be deleted by
the default config of swc typescript transform(which set
`verbatimmodulesyntax` as false by default):
https://swc.rs/docs/migrating-from-tsc#verbatimmodulesyntax-true
Then the output of classic jsx transform will get a runtime error like
`React was not found`.
For solve the problem, this pr just support a config
`verbatimModuleSyntax` for turbopack's typescript transform, it will not
remove user's React import under classic jsx transform.
We test the case under utoopack in the following pr:
- utooland/utoo#2653
- utooland/utoo#2655
And Rspack also enable `verbatimModuleSyntax` to true by default under
2.0:
web-infra-dev/rspack#9270 (comment)
Summary
Add a test case for verbatimModuleSyntax under typescript transform:
Here it's clear that when
verbatimModuleSyntaxis set to false, the React import has been removed, causing the classic JSX transform to not find the React dependency.The opposite test case shows that when the default value is true, React is preserved:
Thanks for @hardfist reminds:
web-infra-dev/rspack#9270 (comment)
Test Plan
Just a test case added for pr: #2653