-
Notifications
You must be signed in to change notification settings - Fork 106
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
Local dependencies #98
Conversation
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zant seems strange but I'll try to check it tomorrow and update you here!
) => { | ||
const [context] = isoworker.createContext(localDeps) |
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.
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-beta https://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.