-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Cannot use npm package @vitejs/plugin-react-swc
#17213
Comments
I just tried it and can't reproduce the error you specified. However I get this error:
|
@brillout tangentially, @itsdouges and I are working on Vite resolver for Deno at https://github.com/itsdouges/vite_plugin_deno_resolve |
@vitejs/plugin-react-swc
@vitejs/plugin-react-swc
Hm, indeed, I can't reproduce anymore as well. I now get the same error than yours. I've updated the ticket & reproduction.
That's very nice... The, by far, number 1 problem vite-plugin-ssr users are getting is ESM/CJS problems (e.g. https://vite-plugin-ssr.com/invalid-esm and that's just a fraction of it). Node.js is deeply broken here and there isn't much vite(-plugin-ssr) can do about it. There is a big opportunity for Deno to make things right. FYI I'm working on a React framework and I'd love to make it use Deno by default. If we systematically fix all problems, I think we can build something truly magical. (I systematically fix all vite-plugin-ssr bugs and, to this day, it has zero known bugs.) |
How would you approach it? Internally in Deno we translate CJS code to ESM on the fly, but it's internal functionality that's currently not exposed in any way.
Sounds good, let me know if there's anything concrete we can help with here. |
I'd make Deno permissive. For example, a widespread problem is npm packages having invalid ESM imports, e.g. I'd make Deno permissive only for npm packages, while being more strict for user land and Deno packages. In order to foster a Deno ecosystem that is correct.
I think the number one goal for now is to fix the many problems users encounter because of Node.js. Together with Vite we have a unique opportunity to own the entire stack while fostering a diverse ecosystem (in contrast to other companies' tendency to control everything and being ecosystem-unfriendly), enabling folks to inovate like Svelte, Solid, Hydrogen/Preact, etc. Our "only" job being to offer basic tools that work very well. Vite is hitting a limit because there is no communication between the Vite team and the Node.js team (I'm not sure if the Node.js team is intersted in that to begin with). On my side, let me first show you a prototype of that React framework "Base". I think you'll like what you see. (Base is only a thin wrapper on top of vite-plugin-ssr, which means that improvements also benefits the entire Vite ecosystem.) Ideally I'll ship Base with Deno right away. We can then systematically polish Deno to fix problems, most notably the many ESM/CJS issues users are having today. FYI another pet peeve of mine is that errors can be swallowed. That's a no-go, exceptions should always emit a stack trace. (Although I'm not sure whether it's a V8 problem that Deno cannot work around.) I've always like Deno, because Deno cares, truly cares. |
I had the same problem when working React + Vite + Typescript + SWC templates.
|
@bartlomieju |
@bartlomieju using create-vite-extra with typescript-swc still emits error due to napi and Option mismatch. when i change react plugin to Panic backtrace
|
This stack trace looks like it will be fixed by #19154 |
Fixes for various `Attemped to access invalid request` bugs (#19058, #15427, #17213). We did not wait for both a drop event and a completion event before removing items from the slab table. This ensures that we do so. In addition, the slab methods are refactored out into `slab.rs` for maintainability.
Fixes for various `Attemped to access invalid request` bugs (#19058, #15427, #17213). We did not wait for both a drop event and a completion event before removing items from the slab table. This ensures that we do so. In addition, the slab methods are refactored out into `slab.rs` for maintainability.
Hi, I'm importing
I checked the fix PR above #19154 and it doesn't seem related to the napi mismatch crash. Did something else address this stack trace? I've tried the latest deno canary (e56695d) and it still has the napi crash. |
I think it was closed by mistake. @danopia could you provide full reproduction so I can try it myself too? I can probably fix this error for the next patch release in a few days. |
Sure, here's a minimal repro of #!/usr/bin/env -S deno run --allow-env --allow-read --allow-run --allow-ffi
import swc from "npm:@swc/core";
console.log(await swc.transform("export {}"));
|
Thanks, that's very useful. I traced the problem to the call to |
We've managed to track down the bug here. Will try to fix it tonight. |
I have the same problems when I tried deno deploy and react-swc template. |
This fix hasn't been released yet. I will be later tonight/tomorrow. |
Thank you for personally addressing this issue @bartlomieju ❤️ |
Reproduction: https://github.com/brillout/deno_vitejs-plugin-react-swc.
Thanks for your wonderful work on Deno. I'd love the Vite + Deno combo (and provide a vite-plugin-ssr Deno starter).
The text was updated successfully, but these errors were encountered: