Packager - Fix absolute imports on Windows - #12530
Closed
janicduplessis wants to merge 4 commits into
Closed
janicduplessis wants to merge 4 commits into
janicduplessis wants to merge 4 commits into
Conversation
Contributor
Author
|
cc @cpojer |
Contributor
Author
|
@jeanlauliac Could you have a look at this? |
Contributor
|
@jeanlauliac has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
Looks good, it should land today. Thank you! |
jeanlauliac
requested review from
jeanlauliac
and removed request for
jeanlauliac
March 1, 2017 15:12
facebook-github-bot
pushed a commit
to react/metro
that referenced
this pull request
Mar 1, 2017
Summary:
Absolute imports on Windows were broken, I'm not 100% sure when this happens but when I tested Exponent on Windows which uses `rn-cli.config.js` with
```js
getTransformOptions() {
return {
reactNativePath: path.resolve('./node_modules/react-native'),
reactPath: path.resolve('./node_modules/react'),
};
}
```
it seemed to use absolute paths for these modules.
I also tested absolute paths in node repl and it does work for absolute paths of different formats. `C:/root/test.js`, `/root/test.js`, `C:\root\test.js` all do resolve properly to the same module.
To fix this I resolve the absolute path using `path.resolve` on Windows. Noop on other platforms to avoid the overhead since it's not necessary.
**Test plan**
- Tested that it fixed the bug I had when running Exponent on Windows.
- Updated the absolute path test to use forward slashes since this is what happens in practice when using `getTransformOptions`. We can't test all cases on linux since adding the drive letter au
Closes react/react-native#12530
Differential Revision: D4634699
Pulled By: jeanlauliac
fbshipit-source-id: 0cf6528069b79cba2e0f79f48f5a524d59b7091e
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Absolute imports on Windows were broken, I'm not 100% sure when this happens but when I tested Exponent on Windows which uses
rn-cli.config.jswithit seemed to use absolute paths for these modules.
I also tested absolute paths in node repl and it does work for absolute paths of different formats.
C:/root/test.js,/root/test.js,C:\root\test.jsall do resolve properly to the same module.To fix this I resolve the absolute path using
path.resolveon Windows. Noop on other platforms to avoid the overhead since it's not necessary.Test plan
getTransformOptions. We can't test all cases on linux since adding the drive letter automatically doesn't work.