Skip to content

Commit e630236

Browse files
author
Brandon Roberts
committed
fix(loader): Added check for Windows OS and use appropriate path API
1 parent 27ac59a commit e630236

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ module.exports = function(source, sourcemap) {
4040
filePath = path.join(relativeDir, filePath);
4141
}
4242

43+
filePath = utils.normalizeFilePath(filePath);
44+
4345
if (loader === 'system') {
4446
return utils.getSystemLoader(filePath, moduleName);
4547
} else {

src/utils.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
var os = require('os');
12
var path = require('path');
23

3-
function getRequireLoader(filePath, moduleName) {
4+
module.exports.getRequireLoader = function(filePath, moduleName) {
45
var result = [
56
'loadChildren: () => new Promise(function (resolve) {\n',
67
' (require as any).ensure([], function (require) {\n',
@@ -10,9 +11,9 @@ function getRequireLoader(filePath, moduleName) {
1011
];
1112

1213
return result.join('');
13-
}
14+
};
1415

15-
function getSystemLoader(filePath, moduleName) {
16+
module.exports.getSystemLoader = function(filePath, moduleName) {
1617
var result = [
1718
'loadChildren: () => System.import(\'' + filePath + '\')\n',
1819
' .then(function(module) {\n',
@@ -21,12 +22,18 @@ function getSystemLoader(filePath, moduleName) {
2122
];
2223

2324
return result.join('');
24-
}
25+
};
2526

26-
function getFilename(resourcePath) {
27+
module.exports.getFilename = function(resourcePath) {
2728
var filename = path.basename(resourcePath);
2829

2930
return path.basename(resourcePath, path.extname(filename));
30-
}
31+
};
3132

32-
module.exports = { getRequireLoader, getSystemLoader, getFilename };
33+
module.exports.normalizeFilePath = function(filePath) {
34+
if (os.platform() === 'win32') {
35+
return newPath.replace(/\//g, '\\\\');
36+
}
37+
38+
return filePath;
39+
}

0 commit comments

Comments
 (0)