[RFC] Add npm library mode#855
Conversation
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
d0eb3d7 to
665953e
Compare
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
665953e to
ac1a14a
Compare
| } | ||
|
|
||
| // TODO: Refactor with original | ||
| class WorkerContextFromInstance { |
There was a problem hiding this comment.
WIP: I copied it from WorkerContext and patched. Is there clear way?
| [window.innerWidth, window.innerHeight], | ||
| {}, // localStorage | ||
| {}, // sessionStorage | ||
| ], |
There was a problem hiding this comment.
Maybe adding TransferrableKeys and some types like Initializer are better but at first makes it simple
ac1a14a to
42d51e8
Compare
|
|
|
We are closing this PR for now due to being inactive. Please feel free to reopen. |
This PR is proposal to add
npm library modebuild.API Proposal
It generates them.
worker-dom/dist/lib/main.mjs: exportattachWorker(element: HTMLElement, worker: Worker): voidworker-dom/dist/lib/worker.mjs: exportready: Promise<void>(DOM is ready to touch)Background
I think worker-dom can be general purpose library for frontend performance, but today's api does not fit webpack. Under using webpack, there are many ways to bundle worker code like
worker-pluginandworker-loader.This proposal provides seamless way with webpack.
Example
with
worker-plugin(https://github.com/GoogleChromeLabs/worker-plugin)See full code
demo/as-webpack-libWorking Demo
https://worker-dom-as-lib-example.netlify.app/
sample repository (use published
@mizchi/worker-dom)https://github.com/mizchi/worker-dom-webpack-example
https://wizardly-benz-02c23e.netlify.app/