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

fix(HMR): modulePath on Windows to apply changes in app styles at runtime #807

Merged
merged 2 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 fromRelativePathToUnix(relativePath) {
return relativePath.replace(/\\/g, "/");
}

module.exports = {
buildEnvData,
debuggingEnabled,
shouldSnapshot,
getUpdatedEmittedFiles,
parseHotUpdateChunkName,
addListener,
removeListener
removeListener,
fromRelativePathToUnix
};
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 { fromRelativePathToUnix } = 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 = fromRelativePathToUnix(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 { fromRelativePathToUnix } = 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 = fromRelativePathToUnix(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 { fromRelativePathToUnix } = 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 = fromRelativePathToUnix(moduleRelativePath);
return `${source};${reload({ type: typeStyle, path: modulePath })}`;
};