-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Issue importing JSX file from dependency in node_modules #12172
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
Comments
Realised it could be helpful to describe the original case as well as the repro. We have a monorepo, and I was trying to follow the guidance at https://vitejs.dev/guide/dep-pre-bundling.html:
In our case I added the dep using Vite does appear to treat the linked dep as source code as described, but it seems to encounter an issue with this when the dep has jsx files. From the phrase "Vite automatically detects dependencies that are not resolved from node_modules and treats the linked dep as source code" I'm inferring that the intention is to support linked deps as if they were source code, in which case it seems like erroring on jsx is unintended behaviour. And though I've looked through the docs and not found an obvious vite config opt that could solve this, but very happy to be pointed to one if it exists. Edit: For our use case, its seems a possible workaround for this issue is to alias the dep in alias: {
'my-dep': path_to_dep,
}, Noting this as although it doesn't address this issue directly it allows for the same result in this one case. |
Hey @bhallstein I have the same issue when I trying to import a node_module |
Currently Vite only supports JS/TS files for dep optimizer. You could use |
Thanks for the reply @sapphi-red. |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
Trying to import a dependency from node_modules that has a jsx file. Vite complains that the file does not have the "jsx" extension, though it in fact does.
Tried adding to vite config, does not fix:
Currently using
@vitejs/plugin-react-swc
for transpilation.Reproduction
https://github.com/bhallstein/vite-jsx-in-node-modules-issue
Steps to reproduce
Clone repo
npm install
git checkout .
-- re-adds the jsx-dep dep inside node_modulesnpx vite
This displays error message saying the imported rep needs the jsx extension — but the file already has this extension.
System Info
Used Package Manager
npm
Logs
Validations
The text was updated successfully, but these errors were encountered: