-
Notifications
You must be signed in to change notification settings - Fork 284
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
npm packaging for node and web #657
base: main
Are you sure you want to change the base?
Conversation
Update build script to build both Update package.json Add basic test of node variant of npm package.
Node one broke
going to try out something different
src moved under web/ to make it cleaner build does less moving of files, mostly just moves the wasm-pack into dist for node and web
run via npm run test -w web
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to add these back - but did the limbo version of these tests even work? I could not get them to run even before I made changes. Easily could've been a skill issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is here to test the npm package as its packaged.
Thanks a lot! I have a few questions/issues: Single vs multiple package Doesn't this in web/package.json:
now mean that
then adding in
and running:
Issues with the package itself Also you'll notice that this doesn't quite work since the web package json has this configuration:
There's also vite-plugin-wasm-pack that could obviate the need for a separate script and you could just build the entire web package using EDIT: I quickly tested this and it should work, but it requires some changes to the vite config. e.g.
We should aim so that it creates a single js bundle for the main thread and a single bundle for the worker thread, I think. (or two bundles if the worker requires another worker, but generally the module should import each other hierarchically)
By making
assuming that is going to be the main entrypoint of our program, and we don't want to have the main entrypoint be a higher level interface that doesn't require postMessage and so on. Other notes We should probably consider such a higher level interface, I think. We can start with this, but eventually we'd probably like to have something like:
not meant as an exact api design, but just abstract the webworker communication out. A couple of other side notes for the future:
|
Ok! I'll take a look at at addressing those comments. FYI it will probably be Tuesday before I get back around to this. |
Add web support to npm package.
Still a WIP need to do some cleanup still
I assumed it is better to keep the server code and web code together in the same package (bigger download number). It took quite a bit of experimentation but the ultimate experience is
node - commonjs
web - module
Like I said this took a lot of experimentation on my part as this is my first time trying to create an npm package let alone that mixes commonjs and modules.
The structure is an npm workspace with two sub packages (web and node).
The output of wasm-pack gets put in <web/node>dist
JS code moves into <web/node>src/
Tests move under web/test
The npm package looks like (you can see I need to cleanup some of the stuff that gets included).
resolves #624