Skip to content
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 HMR on Windows #6678

Closed
wants to merge 2 commits into from
Closed

Conversation

janicduplessis
Copy link
Contributor

Tested HMR on Windows and found 2 small issues related to paths that made it not work. Now it works nicely :)

Test plan (required)
Tested HMR in UIExplorer on Windows.

const extensionStart = path.lastIndexOf('.');
let resource = path.substring(
matchingRoot.length,
extensionStart !== -1 ? extensionStart : undefined,
);

const extension = extensionStart !== -1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused variable

@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @martinbigio, @davidaurelio and @amasad to be potential reviewers.

@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Mar 27, 2016
@@ -18,6 +18,10 @@ module.exports = function(options, filename) {
var transform = filename
? './' + path.relative(path.dirname(filename), transformPath) // packager can't handle absolute paths
: hmrTransform;

// Fix the path to use '/' on Windows.
transform = transform.replace(/\\/g, '/');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the transform used to output require('./..\..\...') which of course didn't work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should check the path separator first,

if (path.sep === '\\') {
  transform = transform.replace(/\\/g, '/');
}

I think we should move this to a module normalizePath or something, and use it instead of duplicating the code.

@satya164
Copy link
Contributor

satya164 commented Apr 4, 2016

cc @martinbigio

@satya164
Copy link
Contributor

satya164 commented Apr 4, 2016

@janicduplessis can you make changes based on my comment?

@janicduplessis
Copy link
Contributor Author

@satya164 Oups I forgot to get back to you on this PR :)

I don't think we need to make it in a module it's actually pretty rare we need to change backslashes for forward slashes. It's only needed here since we derive a URL and a require path from a file path. I don't mind adding the extra check on path.sep, I just figured the overhead was negligible.

@facebook-github-bot
Copy link
Contributor

@janicduplessis updated the pull request.

@satya164
Copy link
Contributor

satya164 commented Apr 5, 2016

@janicduplessis the same code exists at a different place though

@janicduplessis
Copy link
Contributor Author

The main issue is that one is in babel-preset and the other one in the packager. Babel preset is actually a different module so I don't think it's possible to require something from the same place.

@satya164
Copy link
Contributor

satya164 commented Apr 5, 2016

@janicduplessis Oh. Right.

@facebook-github-bot shipit

@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are an FB employee go to Phabricator to review.

@ghost ghost closed this in c61100d Apr 5, 2016
ide pushed a commit that referenced this pull request Apr 5, 2016
Summary:Tested HMR on Windows and found 2 small issues related to paths that made it not work. Now it works nicely :)

**Test plan (required)**
Tested HMR in UIExplorer on Windows.
Closes #6678

Differential Revision: D3138379

fb-gh-sync-id: f27cd2fa21f95954685c8c6916d820f41bc187be
fbshipit-source-id: f27cd2fa21f95954685c8c6916d820f41bc187be
zebulgar pushed a commit to nightingale/react-native that referenced this pull request Jun 18, 2016
Summary:Tested HMR on Windows and found 2 small issues related to paths that made it not work. Now it works nicely :)

**Test plan (required)**
Tested HMR in UIExplorer on Windows.
Closes facebook#6678

Differential Revision: D3138379

fb-gh-sync-id: f27cd2fa21f95954685c8c6916d820f41bc187be
fbshipit-source-id: f27cd2fa21f95954685c8c6916d820f41bc187be
cpojer pushed a commit to facebook/metro that referenced this pull request Jan 26, 2017
Summary:Tested HMR on Windows and found 2 small issues related to paths that made it not work. Now it works nicely :)

**Test plan (required)**
Tested HMR in UIExplorer on Windows.
Closes facebook/react-native#6678

Differential Revision: D3138379

fb-gh-sync-id: f27cd2fa21f95954685c8c6916d820f41bc187be
fbshipit-source-id: f27cd2fa21f95954685c8c6916d820f41bc187be
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants