mirror of
https://github.com/status-im/metro.git
synced 2025-03-02 11:40:55 +00:00
Fix HMR on Windows
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 https://github.com/facebook/react-native/pull/6678 Differential Revision: D3138379 fb-gh-sync-id: f27cd2fa21f95954685c8c6916d820f41bc187be fbshipit-source-id: f27cd2fa21f95954685c8c6916d820f41bc187be
This commit is contained in:
parent
97e1db3e6c
commit
30bdfdd370
19
react-packager/src/Bundler/index.js
vendored
19
react-packager/src/Bundler/index.js
vendored
@ -189,23 +189,24 @@ class Bundler {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_hmrURL(prefix, platform, extensionOverride, path) {
|
_hmrURL(prefix, platform, extensionOverride, filePath) {
|
||||||
const matchingRoot = this._projectRoots.find(root => path.startsWith(root));
|
const matchingRoot = this._projectRoots.find(root => filePath.startsWith(root));
|
||||||
|
|
||||||
if (!matchingRoot) {
|
if (!matchingRoot) {
|
||||||
throw new Error('No matching project root for ', path);
|
throw new Error('No matching project root for ', filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
const extensionStart = path.lastIndexOf('.');
|
// Replaces '\' with '/' for Windows paths.
|
||||||
let resource = path.substring(
|
if (path.sep === '\\') {
|
||||||
|
filePath = filePath.replace(/\\/g, '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
const extensionStart = filePath.lastIndexOf('.');
|
||||||
|
let resource = filePath.substring(
|
||||||
matchingRoot.length,
|
matchingRoot.length,
|
||||||
extensionStart !== -1 ? extensionStart : undefined,
|
extensionStart !== -1 ? extensionStart : undefined,
|
||||||
);
|
);
|
||||||
|
|
||||||
const extension = extensionStart !== -1
|
|
||||||
? path.substring(extensionStart + 1)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
prefix + resource +
|
prefix + resource +
|
||||||
'.' + extensionOverride + '?' +
|
'.' + extensionOverride + '?' +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user