File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ class ParserPlugin {
4444 parser . plugin ( "evaluate Identifier imported var.moduleName" , ( expr : Webpack . MemberExpression ) => {
4545 if ( expr . property . name === "moduleName" &&
4646 expr . object . name === "PLATFORM" &&
47- expr . object . type === "Identifier" ) {
47+ expr . object . type . toString ( ) === "Identifier" ) {
4848 return new BasicEvaluatedExpression ( ) . setIdentifier ( "PLATFORM.moduleName" ) . setRange ( expr . range ) ;
4949 }
5050 return undefined ;
@@ -59,7 +59,7 @@ class ParserPlugin {
5959 parser . plugin ( "evaluate MemberExpression" , ( expr : Webpack . MemberExpression ) => {
6060 if ( expr . property . name === "moduleName" &&
6161 ( expr . object . type === "MemberExpression" && expr . object . property . name === "PLATFORM" ||
62- expr . object . type === "Identifier" && expr . object . name === "PLATFORM" ) ) {
62+ expr . object . type . toString ( ) === "Identifier" && expr . object . name === "PLATFORM" ) ) {
6363 return new BasicEvaluatedExpression ( ) . setIdentifier ( "PLATFORM.moduleName" ) . setRange ( expr . range ) ;
6464 }
6565 return undefined ;
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ export class PreserveModuleNamePlugin {
5656 }
5757
5858 // Metadata?
59+ moduleId = moduleId . replace ( / \\ / g, '/' ) ;
5960 if ( module . meta ) {
6061 module . meta [ 'aurelia-id' ] = moduleId ;
6162 }
@@ -148,11 +149,22 @@ function getNodeModuleData(module: Webpack.Module): NodeModule.Data | null {
148149 return null ;
149150 }
150151
152+ function cleanWindowsPaths ( paths : RegExpMatchArray | null ) {
153+ var out : string [ ] = [ ] ;
154+ if ( ! paths ) {
155+ return out ;
156+ }
157+ for ( var i = 0 ; i < paths . length ; i += 1 ) {
158+ out [ i ] = paths [ i ] . replace ( ':' , '' ) . split ( '\\' ) . join ( '/' ) ;
159+ }
160+ return out ;
161+ }
162+
151163 // Note that the negative lookahead (?!.*node_modules) ensures that we only match the last node_modules/ folder in the path,
152164 // in case the package was located in a sub-node_modules (which can occur in special circumstances).
153165 // We also need to take care of scoped modules. If the name starts with @ we must keep two parts,
154166 // so @corp /bar is the proper module name.
155- const modulePaths = module . resource . match ( / ( .* \b n o d e _ m o d u l e s [ \\ / ] (? ! .* \b n o d e _ m o d u l e s \b ) ( (?: @ [ ^ \\ / ] + [ \\ / ] ) ? [ ^ \\ / ] + ) ) ( .* ) / i) ;
167+ const modulePaths = cleanWindowsPaths ( module . resource . match ( / ( .* \b n o d e _ m o d u l e s [ \\ / ] (? ! .* \b n o d e _ m o d u l e s \b ) ( (?: @ [ ^ \\ / ] + [ \\ / ] ) ? [ ^ \\ / ] + ) ) ( .* ) / i) ) ;
156168 if ( ! modulePaths || modulePaths . length !== 4 ) {
157169 return null ;
158170 }
You can’t perform that action at this time.
0 commit comments