-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Add way to stop the module resolution at a specific directory #43368
Comments
Duplicate of #43192? |
@nodejs/modules |
I've seen this issue before. I think it's related, but not exactly a duplicate. My intent is not related to security at all - only to improve the development process. |
This is already possible via loaders: https://nodejs.org/api/esm.html#resolvespecifier-context-defaultresolve. I don’t think Node will likely support any other ways of customizing resolution, as there are too many potential preferences to consider. The |
Stop searching for package.json or node_modules when a node_ceiling file is found. Refs: nodejs#43192 Refs: nodejs#43368
@tmtron if an environment variable or command line argument meets your need, would a policy like the following do what you want, placed in the dist directory and loaded with
|
|
@arhart Thanks, that seems to work.
|
With policies now marked as deprecated, is there an alternative approach to achieving the above solution? |
What is the problem this feature will solve?
Currently the node resolution will traverse all the way up to the root of the file-system.
It would be great to have a way to stop the resolution at a specific directory.
There are different use-cases that could benefit from this
package.json
files at different levelspackage.json
file may wish to only use dependencies in this project to make sure, that no other dependencies are used by accidentdist
directory which may include a separatenode_modules
folder (with only the packages that are required for production).dist/node_modules
, node might find it in./node_modules
What is the feature you are proposing to solve the problem?
Not sure what the best way is. Here are some thoughts:
package.json
: e.g.resolutionRoot: true
Then nested packages could directly use this. And for the dist-use case, the build-process can create a
package.json
file in thedist
directorypackage.json
What alternatives have you considered?
Currently we copy the whole folder and subfolders to the root of the file-system and start the app from there: then the node-resolution will for sure not find additional
node_module
folders.Cons:
The text was updated successfully, but these errors were encountered: