next.js
41ed440b - TURBOPACK: typescript transform support verbatimModuleSyntax (#90907)

Commit
11 days ago
TURBOPACK: typescript transform support verbatimModuleSyntax (#90907) 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: - https://github.com/utooland/utoo/pull/2653 - https://github.com/utooland/utoo/pull/2655 And Rspack also enable `verbatimModuleSyntax` to true by default under 2.0: https://github.com/web-infra-dev/rspack/discussions/9270#discussioncomment-13429924
Author
Parents
Loading