-
Notifications
You must be signed in to change notification settings - Fork 471
Respect NODE_PATH when resolving modules #3701
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
Conversation
This allows the usage of NODE_PATH(https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders) when `bsb` is resolving modules
|
Not sure why the new test case if failing. I've got it working locally with: |
|
This seems nice to have, will it replace the support of |
|
@bobzhang I'll remove the I can make this work locally with these commands(I'm using a Mac):
There might be some issues with how I set up the new test case but I can't seem to find the issue. Any ideas? |
|
@purkhusid you can ping me on discord. step 6 can be replaced by |
jscomp/bsb/bsb_pkg.ml
Outdated
| let node_path = | ||
| match Sys.getenv "NODE_PATH" with | ||
| | node_path -> | ||
| Str.split (Str.regexp ";") node_path |
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.
let's stick to Ext_string instead.
The delimiter seems to be platform specific, ';' on *nix, something different on windows
| | resolved_dir -> resolved_dir // Bsb_pkg_types.to_string pkg | ||
| | exception Not_found -> | ||
| Bsb_exception.package_not_found ~pkg ~json:None | ||
|
|
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.
checkout Ext_list.find_opt
|
|
||
| let node_path_delimiter = | ||
| if Sys.os_type = "Win32" then | ||
| ';' |
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 Sys.win32
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.
I see a CI failure, do you have such failure locally
|
@bobzhang Yeah, it's still failing in CI but works locally. but it seems like it's not using the |
It seems you forgot to check in changes to |
|
it seems removing npm_config_prefix triggered some unexpected effect, will fix it |
|
merged in master via #3708 , thanks |
|
Awesome, thanks! |
This PR allows the usage of NODE_PATH(https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders) in the
bsbmodule resolution.The exact usecase for me is to enable the usage of
bsbwithin the Bazel NodeJS rules.The node_modules folder is located in a non-standard directory and this allows me to add that directory to the
bsbmodule resolution.