Skip to content
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

[wasm] Fix "_scriptDir not defined" error when used in webworker #4528

Merged
merged 2 commits into from
Jan 14, 2021

Conversation

jinjingforever
Copy link
Collaborator

@jinjingforever jinjingforever commented Jan 13, 2021

I couldn't find a more elegant solution using the --pre-js approach.. Inspired by emscripten-core/emscripten#12832, I manually update the if check for _scriptDir to make it work for both non-webworker case (where _scriptDir is defined) and webworker case (where _scriptDir is not defined).

I also tried to use document.currentScript.src instead of undefined for _scriptDir, but document.currentScript.src will return the location of the user script instead of the original location where the tfjs npm package is imported.

Please let me know if you guys any better ideas.


This change is Reviewable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants