create webpack plugin
See original GitHub issuewebpack plugin
I would appreciate it if someone else could help with this though. I’ve tried to write a webpack plugin several times but always run into the problem that I was unable to use webpack with Pyodide at all. Perhaps with @mneil’s example I would have an easier time, but the webpack plugin API is also very confusing. If it’s just a wrapper around CopyPlugin
then that probably isn’t too hard.
In @mneil’s example, he also patches pyodide.js
to remove the global assignment to loadPyodide
, but if you use pyodide.mjs
instead of pyodide.js
it doesn’t assign loadPyodide
to the global scope. We make pyodide.js
out of pyodide.umd.ts
which just adds the globalThis
assignment to pyodide.ts
:
https://github.com/pyodide/pyodide/blob/main/src/js/pyodide.umd.ts
Whereas pyodide.mjs
is made from pyodide.ts
directly. Though deleting that line is also an option if using webpack to load a module is not possible.
_Originally posted by @hoodmane in https://github.com/pyodide/pyodide/issues/3085#issuecomment-1241155294_
Issue Analytics
- State:
- Created a year ago
- Comments:17 (17 by maintainers)
OK, moved it to https://github.com/pyodide/pyodide-webpack-plugin. It would be nice to switch to this plugin in https://github.com/pyodide/pyodide-webpack-example. You also have write permissions there, but it would still be good to make changes via PRs for that example repo.
I’m closing this issue as resolved, thanks @mneil! For follow-up discussions, it would probably be better to open separate issues in https://github.com/pyodide/pyodide-webpack-plugin. I’ll see if Pyodide repo has any relevant issues for webpack and if so transfer them there 😃
@dlech thanks for starting this discussion. If you would like to collaborate on that plugin or test and provide feedback that would also be very welcome.
If you feel like you would be interested in maintaining it in the future I would be +1 for accepting it within the Pyodide org with you as its maintainer (if you are interested).
No matter where it would end up you should be able to do the release independently, I think. About npm release the only thing I’m not sure about is whether it would be better to publish it as
pyodide-webpack
or@pyodide/pyodide-webpack
or some other variation (e.g.@pyodide/webpack
). Not really sure about best practices with npm scopes.WDYT @hoodmane @ryanking13 ?