Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit

Permalink
fix(HMR): modulePath on Windows to apply changes in app styles at run…
Browse files Browse the repository at this point in the history
…time (#807)

* fix(HMR): modulePath on Windows

Replace backslashes with forward slashes.

* refactor: rename a method
  • Loading branch information
vchimev authored Feb 20, 2019
1 parent bf1cc33 commit cc55d4f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
9 changes: 6 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
const os = require("os");
const path = require("path");

const {
getAppPathFromProjectData,
getAppResourcesPathFromProjectData,
getProjectDir,
isAndroid,
} = require("../projectHelpers");

Expand Down Expand Up @@ -92,12 +90,17 @@ function removeListener(eventEmitter, name) {
}
}

function convertToUnixPath(relativePath) {
return relativePath.replace(/\\/g, "/");
}

module.exports = {
buildEnvData,
debuggingEnabled,
shouldSnapshot,
getUpdatedEmittedFiles,
parseHotUpdateChunkName,
addListener,
removeListener
removeListener,
convertToUnixPath
};
4 changes: 3 additions & 1 deletion markup-hot-loader.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const { reload } = require("./hot-loader-helper");
const { convertToUnixPath } = require("./lib/utils");

module.exports = function (source) {
const typeMarkup = "markup";
const modulePath = this.resourcePath.replace(this.rootContext, ".");
const moduleRelativePath = this.resourcePath.replace(this.rootContext, ".");
const modulePath = convertToUnixPath(moduleRelativePath);
return `${source};${reload({ type: typeMarkup, path: modulePath })}`;
};
4 changes: 3 additions & 1 deletion script-hot-loader.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const { reload } = require("./hot-loader-helper");
const { convertToUnixPath } = require("./lib/utils");

module.exports = function (source) {
const typeScript = "script";
const modulePath = this.resourcePath.replace(this.rootContext, ".");
const moduleRelativePath = this.resourcePath.replace(this.rootContext, ".");
const modulePath = convertToUnixPath(moduleRelativePath);
return `${source};${reload({ type: typeScript, path: modulePath })}`;
};
4 changes: 3 additions & 1 deletion style-hot-loader.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const { reload } = require("./hot-loader-helper");
const { convertToUnixPath } = require("./lib/utils");

module.exports = function (source) {
const typeStyle = "style";
const modulePath = this.resourcePath.replace(this.rootContext, ".");
const moduleRelativePath = this.resourcePath.replace(this.rootContext, ".");
const modulePath = convertToUnixPath(moduleRelativePath);
return `${source};${reload({ type: typeStyle, path: modulePath })}`;
};

0 comments on commit cc55d4f

Please sign in to comment.