[Packager] Allow imports that are relative to the project root #2035
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is related to #637.
From that issue to quote @JaapRood:
Browserify and webpack both let you use symlinks in the node_modules folder to reference modules. This is mainly useful for preventing
../../../../
requires.With a symlink setup from the project root setup like:
ln -s src/app node_modules/app
in any file in the project you can:
However, the packager can't resolve them:
Requiring unknown module "app".
@ide did some investigation and found that support for symlinks was most likely not going to happen for watchman facebook/watchman#105
To get around this in our app, we've been building a library and keeping it at the project root. With this pull request, we can then find these modules and our import statements are:
from anywhere in our project, not just at the root. This is similar to what
resolve.root
for those familiar with webpack allows.Thoughts? I know this isn't a solution to the symlinks problem but it helps alleviate the problem for some use cases and allows us to have clean import statements for our core internal modules.