Repository navigation
Prevent JSX pragma detection in transform-typescript from leaking between files - #9798
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10640/ |
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
Since the currentJsxPragma variable is file-specific, I think that it sould be better to store it in the file object:
const PRAGMA_KEY = "@babel/plugin-transform-typescript/jsxPragma";
file.set(PRAGMA_KEY, jsxMatches[1]);
// ...
file.get(PRAGMA_KEY);|
@nicolo-ribaudo Thank you for the review, I'm quite new to the babel internals, I'll make the changes right now :) |
|
I've made the changes, and tested it on our application (it works fine) 🚀 I'm just wondering what is the signature of |
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
I'm just wondering what is the signature of file.get
It's the same as Map#get
Since with out current testing infrastructure it's not really possible to test transpilation of multiple files, I'm ok with this PR even if it is without tests.
|
Looks like this would fix #9549. |
This PR fixes a bug in support of JSX pragma in Typescript (introduced in #9095).
We've noticed this bug while building a large codebase with webpack+babel+typescript. Some files from our projects are using
/** @jsx h*/to use a custom function for JSX syntax; and some others are using the React syntax.We've noticed that our react imports were being removed by babel because the plugin instance was being reused by
babel-loaderand webpack; and it was causing an error :This PR resets the
jsxPragmabeing used to the initial value for each new file being processed.I can't add a unit test for this bug because it requires processing 2 files (one with
/** @jsx something */then one with the react syntax).I've tested a build of this PR and it correctly fixes the issue for us.