@@ -195,7 +195,7 @@ var AMDLoader;
195195 return isEmpty ;
196196 } ;
197197 Utilities . recursiveClone = function ( obj ) {
198- if ( ! obj || typeof obj !== 'object' ) {
198+ if ( ! obj || typeof obj !== 'object' || obj instanceof RegExp ) {
199199 return obj ;
200200 }
201201 var result = Array . isArray ( obj ) ? [ ] : { } ;
@@ -304,6 +304,9 @@ var AMDLoader;
304304 if ( typeof options . cspNonce !== 'string' ) {
305305 options . cspNonce = '' ;
306306 }
307+ if ( typeof options . preferScriptTags === 'undefined' ) {
308+ options . preferScriptTags = false ;
309+ }
307310 if ( ! Array . isArray ( options . nodeModules ) ) {
308311 options . nodeModules = [ ] ;
309312 }
@@ -459,7 +462,9 @@ var AMDLoader;
459462 * Transform a module id to a location. Appends .js to module ids
460463 */
461464 Configuration . prototype . moduleIdToPaths = function ( moduleId ) {
462- if ( this . nodeModulesMap [ moduleId ] === true ) {
465+ var isNodeModule = ( ( this . nodeModulesMap [ moduleId ] === true )
466+ || ( this . options . amdModulesPattern instanceof RegExp && ! this . options . amdModulesPattern . test ( moduleId ) ) ) ;
467+ if ( isNodeModule ) {
463468 // This is a node module...
464469 if ( this . isBuild ( ) ) {
465470 // ...and we are at build time, drop it
@@ -567,11 +572,24 @@ var AMDLoader;
567572 OnlyOnceScriptLoader . prototype . load = function ( moduleManager , scriptSrc , callback , errorback ) {
568573 var _this = this ;
569574 if ( ! this . _scriptLoader ) {
570- this . _scriptLoader = ( this . _env . isWebWorker
571- ? new WorkerScriptLoader ( )
572- : this . _env . isNode
573- ? new NodeScriptLoader ( this . _env )
574- : new BrowserScriptLoader ( ) ) ;
575+ if ( this . _env . isWebWorker ) {
576+ this . _scriptLoader = new WorkerScriptLoader ( ) ;
577+ }
578+ else if ( this . _env . isElectronRenderer ) {
579+ var preferScriptTags = moduleManager . getConfig ( ) . getOptionsLiteral ( ) . preferScriptTags ;
580+ if ( preferScriptTags ) {
581+ this . _scriptLoader = new BrowserScriptLoader ( ) ;
582+ }
583+ else {
584+ this . _scriptLoader = new NodeScriptLoader ( this . _env ) ;
585+ }
586+ }
587+ else if ( this . _env . isNode ) {
588+ this . _scriptLoader = new NodeScriptLoader ( this . _env ) ;
589+ }
590+ else {
591+ this . _scriptLoader = new BrowserScriptLoader ( ) ;
592+ }
575593 }
576594 var scriptCallbacks = {
577595 callback : callback ,
0 commit comments