Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit cc55d4f

Browse files
authored
fix(HMR): modulePath on Windows to apply changes in app styles at runtime (#807)
* fix(HMR): modulePath on Windows Replace backslashes with forward slashes. * refactor: rename a method
1 parent bf1cc33 commit cc55d4f

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

‎lib/utils.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
const os = require("os");
2-
const path = require("path");
32

43
const {
54
getAppPathFromProjectData,
65
getAppResourcesPathFromProjectData,
7-
getProjectDir,
86
isAndroid,
97
} = require("../projectHelpers");
108

@@ -92,12 +90,17 @@ function removeListener(eventEmitter, name) {
9290
}
9391
}
9492

93+
function convertToUnixPath(relativePath) {
94+
return relativePath.replace(/\\/g, "/");
95+
}
96+
9597
module.exports = {
9698
buildEnvData,
9799
debuggingEnabled,
98100
shouldSnapshot,
99101
getUpdatedEmittedFiles,
100102
parseHotUpdateChunkName,
101103
addListener,
102-
removeListener
104+
removeListener,
105+
convertToUnixPath
103106
};

‎markup-hot-loader.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
const { reload } = require("./hot-loader-helper");
2+
const { convertToUnixPath } = require("./lib/utils");
23

34
module.exports = function (source) {
45
const typeMarkup = "markup";
5-
const modulePath = this.resourcePath.replace(this.rootContext, ".");
6+
const moduleRelativePath = this.resourcePath.replace(this.rootContext, ".");
7+
const modulePath = convertToUnixPath(moduleRelativePath);
68
return `${source};${reload({ type: typeMarkup, path: modulePath })}`;
79
};

‎script-hot-loader.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
const { reload } = require("./hot-loader-helper");
2+
const { convertToUnixPath } = require("./lib/utils");
23

34
module.exports = function (source) {
45
const typeScript = "script";
5-
const modulePath = this.resourcePath.replace(this.rootContext, ".");
6+
const moduleRelativePath = this.resourcePath.replace(this.rootContext, ".");
7+
const modulePath = convertToUnixPath(moduleRelativePath);
68
return `${source};${reload({ type: typeScript, path: modulePath })}`;
79
};

‎style-hot-loader.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
const { reload } = require("./hot-loader-helper");
2+
const { convertToUnixPath } = require("./lib/utils");
23

34
module.exports = function (source) {
45
const typeStyle = "style";
5-
const modulePath = this.resourcePath.replace(this.rootContext, ".");
6+
const moduleRelativePath = this.resourcePath.replace(this.rootContext, ".");
7+
const modulePath = convertToUnixPath(moduleRelativePath);
68
return `${source};${reload({ type: typeStyle, path: modulePath })}`;
79
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /