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
Parcel, Rollup JS bundlers & Next.js(solved) have compatibility issues with Pyodide npm package (0.18.2) #1949
Comments
Thanks for checking this @grimmer0125 ! For rollup it's a bit surprising since we are using it internally as a bundler and it works OK there; maybe something is wrong in the way we setup the npm package. |
I've tested the other two front-end tools, Vite (OK) and Next.js(Fail). Vite (Rollup base):
Next.js (Webpack base):
1123 update:
-- For front-end developing, sum up:
I would say supporting those top popular ones might be enough. Nest.js is widely used by React developers and supporting it should be a big plus. But according to my experience, some npm packages fail to run on it or need to figure out how to run on it (e.g. add code to detect window/node environment), this is due to its SSR (Server Sider Rendering) design and make things much complicated. For study purposes, configing Maybe packaging everything as multiple npm packages (like #1477 ), e.g. |
I think the solution to this is provided in the docs external: ['fs/promises'] // <-- suppresses the warning Or does that not help? |
Can we leverage on the Fix in #1900 is webpack specific, I think this would be nicer solution? Related to this, webpack used to polyfill Node's core modules out of the box, which is no longer the case in webpack 5. And the recommendation from webpack for migrating from webpack 4 to 5 h reads:
|
@Louis-Tian thank you for the information. I'm trying to make a summary of the issues below.
I updated #1949 (comment) to include Next.js above runtime case and the original case/error is running in its server-side and it's a corner case, we can ignore it. Summary: we can figure out the remaining issues (in a short term)
ref: |
Hi @grimmer0125
Just to clarify, I think the problem is not that webpack or parcel are Node.js based. The problem lies with the way how those bundlers handle imports. An import can be either dynamic
Please note those parsers are static, they have no understanding of any runtime context. The problem rises when the build target is set to an non-nodejs environment. (i.e. web). In these cases, the parser reads lines like On top of the above. we also have an issue that is specific to dynamic import on this line pyodide/src/js/load-pyodide.js Line 66 in 25d7bb5
As noted in webpack documentation here. a full dynamic import is not possible. without the /* webpackIgnore: true */ you applied in #1900, this will throw error as well. This is significant because it means we need a special flag for every single bundling tool that we support and it simply won't work for tools without such flag (say Parcel as it is now). I agree with your comment on merge into the core package. Right now the loadScript function is used to import the pyodide.asm.js package at runtime, which is unnecessary, as they can be combined at build time, which completely eliminates this dynamic import problem.
|
Further to the thoughts above. Given that all of the offending lines are contained within the okay, it's not just the loadScript function, there is also |
Hi, I have roughly figured out the needed modification to use Pyodide npm on
|
Support seems to be perfectly fine... issue should probably be closed |
Thanks for looking into this @FossPrime. @mneil helped and fixed our
To work, Pyodide needs at least the following files:
We don't need Note also that webpack still doesn't work without using @mneil's pyodide-webpack-plugin. So we've made a lot of progress on this but there is still probably work to be done here? |
Is there any way to bundle Pyodide without needing to set the indexURL to the CDN? That's not even a solution that works for me because of #3550. I'm currently stuck loading things from a CDN and have had to give up on the NPM package entirely — perhaps things have broken or maybe I'm just being silly? Sorry for pestering and thanks for your help! |
I have the same request as @TheLostLambda |
They have the same issues as Webpack bundler, introduced in #1875 and #1900.
/* webpackIgnore: true */
await pyodide_pkg.loadPyodide
. Issue: Allow ESM imports from absolute urls parcel-bundler/parcel#4148. Unfortunately, there is nowebpackIgnore
equivalent usage in Parcel.They seem to be famous bundlers, except Webpack. I have not really used them before, and I notice these Pyodide npm package compatibility issues when I try to bundle my another side project numjs. Rollup may be OK since it may not be widely used in front-end developers like Parcel. For Parcel, I do not exactly know how many people use it. In my limited experience about this time experience on my project, it is a good tool.
I do not think this should definitely count as Pyodide issue, and they can count as Parcel/Rollup side issues. I open this issue is to leave a note for people.
The text was updated successfully, but these errors were encountered: