-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Fix _scriptDir for node.js + USE_PTHREADS + MODULARIZE #9875
Conversation
node.js doesn't have document.currentScript.src, so use __filename instead. Since you can have a module designed for both node and the web default to document.currentScript.src, but fall back to __filename if that fails.
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.
Thanks! Nice fix.
Please add a test for this.
I'm not really sure the best way to test this. The only node tests I can see is the one in |
Oh, But maybe I'm missing the difficulty in testing this - is it harder than cloning and modifying that test a little? |
Also _main is exported by default, so remove that.
OK, I think I got the test sorted. |
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.
Thanks! lgtm with that one final nit.
tests/test_other.py
Outdated
''' | ||
if not os.path.exists('subdir'): | ||
os.mkdir('subdir') | ||
with open(os.path.join('subdir', moduleLoader), 'w+', encoding='utf-8') as f: |
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.
there is a helper function for this, create_test_file(name, contents)
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.
Made the change, but I'm not sure what's going on with the tests. My test passed, but some other ones appear to have hung.
Yeah, weird about those tests... I can't seem to restart them. Looks safe to land though as all the other tests passed, landing! |
…re#9875) node.js doesn't have document.currentScript.src, so use __filename instead.
node.js doesn't have document.currentScript.src, so use __filename instead.
Since you can have a module designed for both node and the web default to document.currentScript.src, but fall back to __filename if that fails.