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

Commit a83380a

Browse files
authored
fix-next(HMR): resolve correctly modulePath in hot loaders (#781)
Use `this.rootContext` instead of `this.context`. For example in this [second-page](https://github.com/NativeScript/nativescript-dev-webpack/blob/master/demo/TypeScriptApp/app/views/second-page.xml) module: ---> `this.resourcePath` is /Users/vchimev/git/nativescript-dev-webpack/demo/TypeScriptApp/app/views/second-page.xml ---> `this.context` is /Users/vchimev/git/nativescript-dev-webpack/demo/TypeScriptApp/app/views ---> `this.rootContext` is /Users/vchimev/git/nativescript-dev-webpack/demo/TypeScriptApp/app ---> `modulePath` should be ./views/second-page.xml
1 parent 0d9ecec commit a83380a

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Diff for: markup-hot-loader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ const { reload } = require("./hot-loader-helper");
22

33
module.exports = function (source) {
44
const typeMarkup = "markup";
5-
const modulePath = this.resourcePath.replace(this.context, ".");
5+
const modulePath = this.resourcePath.replace(this.rootContext, ".");
66
return `${source};${reload({ type: typeMarkup, module: modulePath })}`;
77
};

Diff for: script-hot-loader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ const { reload } = require("./hot-loader-helper");
22

33
module.exports = function (source) {
44
const typeScript = "script";
5-
const modulePath = this.resourcePath.replace(this.context, ".");
5+
const modulePath = this.resourcePath.replace(this.rootContext, ".");
66
return `${source};${reload({ type: typeScript, module: modulePath })}`;
77
};

Diff for: style-hot-loader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ const { reload } = require("./hot-loader-helper");
22

33
module.exports = function (source) {
44
const typeStyle = "style";
5-
const modulePath = this.resourcePath.replace(this.context, ".");
5+
const modulePath = this.resourcePath.replace(this.rootContext, ".");
66
return `${source};${reload({ type: typeStyle, module: modulePath })}`;
77
};

0 commit comments

Comments
 (0)