You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the source code,
the React plugin will compile the code in node_modules that contains React.createElement(Such as React.createElement(AnyComponent)) to JSX tag(Such as <AnyComponent>) when the plugin option jsxRuntime was set to automatic(It is also the default value).
Then the JSX tag above will be compile again to the jsx function call(Such as /* @__PURE__ */ jsx(AnyComponent)) through Babel.
However, in some third-party libraries, the component naming does not follow the "Pascal Case" specification(Such as finalComponent at this link). In this case, the JSX component name will be treated as a native HTML element by Babel, that is, compiled into a string(jsx('finalComponent') instead of jsx(finalComponent)).
Therefore, I hope Vite provide configuration options to skip this behavior in my
specified libraries, or change the component name to "Pascal Case" before passing it to Babel.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
zengguirong
changed the title
[plugin-react] Reverse Compilation of "React.createElement" produce incorrect results
[plugin-react] Reverse compilation of "React.createElement" produce incorrect results
Oct 28, 2021
Describe the bug
According to the source code,
the React plugin will compile the code in
node_modules
that containsReact.createElement
(Such asReact.createElement(AnyComponent)
) to JSX tag(Such as<AnyComponent>
) when the plugin optionjsxRuntime
was set toautomatic
(It is also the default value).Then the JSX tag above will be compile again to the jsx function call(Such as
/* @__PURE__ */ jsx(AnyComponent)
) through Babel.However, in some third-party libraries, the component naming does not follow the "Pascal Case" specification(Such as
finalComponent
at this link). In this case, the JSX component name will be treated as a native HTML element by Babel, that is, compiled into a string(jsx('finalComponent')
instead ofjsx(finalComponent)
).Therefore, I hope Vite provide configuration options to skip this behavior in my
specified libraries, or change the component name to "Pascal Case" before passing it to Babel.
Reproduction
Repo: https://github.com/zengguirong/vite-react-report
Library source: https://github.com/alibaba/formily/blob/v2.0.0-rc.17/packages/react/src/components/ReactiveField.tsx#L48
Vite build file: https://github.com/zengguirong/vite-react-report/blob/main/dist/index.js#L9212
System Info
Used Package Manager
yarn
Logs
Validations
The text was updated successfully, but these errors were encountered: