Skip to content

Commit

Permalink
fix(webpack): support more CommonJS import styles
Browse files Browse the repository at this point in the history
  • Loading branch information
jods4 committed Mar 28, 2017
1 parent 5cf040c commit c86042f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/AureliaDependenciesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ class ParserPlugin {
// This covers commonjs modules, for example:
// const _aureliaPal = require("aurelia-pal");
// _aureliaPal.PLATFORM.moduleName("id");
// Or (note: no renaming supported):
// const PLATFORM = require("aurelia-pal").PLATFORM;
// PLATFORM.moduleName("id");
parser.plugin("evaluate MemberExpression", (expr: Webpack.MemberExpression) => {
if (expr.property.name === "moduleName" &&
expr.object.type === "MemberExpression" &&
expr.object.property.name === "PLATFORM") {
(expr.object.type === "MemberExpression" && expr.object.property.name === "PLATFORM" ||
expr.object.type === "Identifier" && expr.object.name === "PLATFORM")) {
return new BasicEvaluatedExpression().setIdentifier("PLATFORM.moduleName").setRange(expr.range);
}
return undefined;
Expand Down

0 comments on commit c86042f

Please sign in to comment.