@@ -14,6 +14,7 @@ class AureliaWebpackPlugin {
14
14
constructor ( options = { } ) {
15
15
options . root = options . root ? path . normalizeSafe ( options . root ) : path . dirname ( module . parent . filename ) ;
16
16
options . src = options . src ? path . normalizeSafe ( options . src ) : path . resolve ( options . root , 'src' ) ;
17
+ options . nameExternalModules = options . nameExternalModules == undefined || options . nameExternalModules == true ;
17
18
options . resourceRegExp = options . resourceRegExp || / a u r e l i a - l o a d e r - c o n t e x t / ;
18
19
options . customViewLoaders = Object . assign ( {
19
20
'.css' : [ 'css' ] ,
@@ -214,22 +215,24 @@ class AureliaWebpackPlugin {
214
215
let relativeToSrc = path . relative ( options . src , module . resource ) ;
215
216
moduleId = relativeToSrc ;
216
217
}
217
- if ( ! moduleId && typeof module . userRequest == 'string' ) {
218
- // paths resolved as build resources
219
- let matchingModuleIds = paths
220
- . filter ( originPath => contextElements [ originPath ] . source === module . userRequest )
221
- . map ( originPath => path . normalize ( originPath ) ) ;
222
-
223
- if ( matchingModuleIds . length ) {
224
- matchingModuleIds . sort ( ( a , b ) => b . length - a . length ) ;
225
- moduleId = matchingModuleIds [ 0 ] ;
218
+ if ( options . nameExternalModules ) {
219
+ if ( ! moduleId && typeof module . userRequest == 'string' ) {
220
+ // paths resolved as build resources
221
+ let matchingModuleIds = paths
222
+ . filter ( originPath => contextElements [ originPath ] . source === module . userRequest )
223
+ . map ( originPath => path . normalize ( originPath ) ) ;
224
+
225
+ if ( matchingModuleIds . length ) {
226
+ matchingModuleIds . sort ( ( a , b ) => b . length - a . length ) ;
227
+ moduleId = matchingModuleIds [ 0 ] ;
228
+ }
226
229
}
227
- }
228
- if ( ! moduleId && typeof module . rawRequest == 'string' && module . rawRequest . indexOf ( '.' ) !== 0 ) {
229
- // requested modules from node_modules:
230
- let index = paths . indexOf ( module . rawRequest ) ;
231
- if ( index >= 0 ) {
232
- moduleId = module . rawRequest ;
230
+ if ( ! moduleId && typeof module . rawRequest == 'string' && module . rawRequest . indexOf ( '.' ) !== 0 ) {
231
+ // requested modules from node_modules:
232
+ let index = paths . indexOf ( module . rawRequest ) ;
233
+ if ( index >= 0 ) {
234
+ moduleId = module . rawRequest ;
235
+ }
233
236
}
234
237
}
235
238
if ( moduleId ) {
0 commit comments