Local dependencies#98
Conversation
101arrowz
left a comment
There was a problem hiding this comment.
Mostly good, just a few minor tweaks would fix a few theoretical issues.
| @@ -1,3 +1,4 @@ | |||
| import isoworker from 'isoworker' | |||
There was a problem hiding this comment.
Since you're using just createContext, maybe importing only that function is better. No need to bundle the workerization code.
There was a problem hiding this comment.
This is a nice suggestion, but I tried it and I'm getting the following:
Can't import the named export 'createContext' from non EcmaScript module (only default export is available)
Are you familiar with that message?
There was a problem hiding this comment.
Hey @101arrowz, just saw your comment in the other discussion. This is the message I'm getting when changing it to a named export, do you have any ideas?
There was a problem hiding this comment.
Hmm, it should be exporting ES6 modules. There is a module field of package.json and there is an ESM build exported. Maybe try importing from fflate/browser or fflate/esm/browser.js.
There was a problem hiding this comment.
Can't quite make it work with our current setup, could it be something related to our build config? @alewin
There was a problem hiding this comment.
@zant seems strange but I'll try to check it tomorrow and update you here!
| transferable: TRANSFERABLE_TYPE, | ||
| localDeps: () => unknown[], | ||
| ) => { | ||
| const [context] = isoworker.createContext(localDeps) |
There was a problem hiding this comment.
createContext returns a few other things, including some transferables that should be sent over. You should assign the received values of the transeferables to the global environment.
|
Great work @zant 🥇 , and thanks @101arrowz for your great lib |
|
I have published a beta containing the changes in this PR npm i @koale/useworker@3.3.0-betahttps://www.npmjs.com/package/@koale/useworker/v/3.3.0-beta |
eb5fb36 to
38930a8
Compare
A new (and better) implementation of #77 thanks to @101arrowz and his cool lib isoworker.
Improvements over previous implementation:
This is how it looks:
I've updated the website and Readme with documentation regarding local deps, and also added some tests.