pyodide: npm package should not include .ts files
š Bug
I just did an npm i pyodide wanting to use this as part of a projec for packaging AWS Lambda packages to support the Python Lambda Functions. Iāve been testing out pyodide and brython to see which one makes more sense. I am really liking pyodide. Up to now Iāve been including the file from a cdn and itās gone fine. However, the package on npm includes all of the typescript files.
An npm package should include type definitions (.d.ts) files for typescript and javascript users for type definitions. The rest of the code, however, should all be javascript. When you publish .ts files I have to now configure whatever build system Iām using (webpack) to support typescript and to explicitly hand transpiling the code. This is not the common way to distribute a package on npm.
In addition there is no main file defined in package.json. I am unsure what the main file is that I should include in order to get the full source.
To Reproduce
npm i pyodide
Expected behavior
When I installed this I expected:
- Javascript file or files
- A single file defined as the main so that my requires or imports know what file to use when I request pyodide
- The asm.js file for executing the pyodide application compiled with emscripten
- The compiled python wasm that will be executed
I believe all of these files should be included. This will make integration into other packages much easier.
Environment
- Pyodide Version 0.20.0
Additional context
I am happy to work on this if you agree. Hopefully I didnāt misinterpret the point of the package on npm.
I have recently been using esbuild which is written in go and distributes a wasm for bundling. That code is successfully on the develop branch of cdk-web https://github.com/3p3r/cdk-web/tree/develop. I am comparing my experience dealing with the package distributed on npm for esbuild-wasm vs. my experience with pyodide.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 24 (21 by maintainers)
Yeah, I agree that we are publishing the wrong stuff. It should be a simple fix: instead of publishing our Javascript source directory which is useless, we should publish the built files. Nobody here knows how to use node all that much so we havenāt fixed it.
And remember what you are doing here is installing Python using
npm i. Normal Python is about 24mb. So hopefully people shouldnāt be too surprised about this.I believe what you want is to use exports in the package.json to define what file to use depending on the module definition (common vs. esm).
https://www.the-guild.dev/blog/support-nodejs-esm
#package.json
The module and exports are not official sections yet. However, node looks at the exports field since v12 LTS. Module is used for bundlers like webpack - maybe rollup also looks at modules but Iām not as familiar with it.
Okay, so roughly
cp package.json $DIST_DIR && cd $DIST_DIR && npm publish?Also, our distribution is very large (200mb) but only 15mb is needed to run the interpreter and the rest are packages. It might be good to eventually add some way to split things up a bit so people donāt have to download so much stuff if they wonāt use it.