Skip to content

Commit

Permalink
fix(webpack): Aliased module paths now properly map to the correct au…
Browse files Browse the repository at this point in the history
…relia-loader module id

Added more information and with more minimal changes
  • Loading branch information
Pat Herlihy committed Feb 26, 2018
1 parent 5177bb3 commit 3a48255
Show file tree
Hide file tree
Showing 3 changed files with 434 additions and 86 deletions.
9 changes: 8 additions & 1 deletion src/AureliaDependenciesPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { IncludeDependency } from "./IncludeDependency";
import BasicEvaluatedExpression = require("webpack/lib/BasicEvaluatedExpression");
import { preserveModuleName } from "./PreserveModuleNamePlugin";

class AureliaDependency extends IncludeDependency {
constructor(request: string,
Expand All @@ -11,7 +12,13 @@ class AureliaDependency extends IncludeDependency {

class Template {
apply(dep: AureliaDependency, source: Webpack.Source) {
source.replace(dep.range[0], dep.range[1] - 1, "'" + dep.request.replace(/^async(?:\?[^!]*)?!/, "") + "'");
// Get the module id, fallback to using the module request
let moduleId: string = dep.request;
if (dep.module && typeof dep.module[preserveModuleName] === 'string') {
moduleId = dep.module[preserveModuleName];
}

source.replace(dep.range[0], dep.range[1] - 1, "'" + moduleId.replace(/^async(?:\?[^!]*)?!/, "") + "'");
};
}

Expand Down
Loading

0 comments on commit 3a48255

Please sign in to comment.