@@ -33,15 +33,20 @@ function shouldWrapSchematic(schematicFile: string): boolean {
33
33
}
34
34
}
35
35
36
+ const normalizedSchematicFile = schematicFile . replace ( / \\ / g, '/' ) ;
36
37
// Never wrap the internal update schematic when executed directly
37
38
// It communicates with the update command via `global`
38
- if ( / [ \/ \\ ] n o d e _ m o d u l e s [ \/ \\ ] @ a n g u l a r [ \/ \\ ] c l i [ \/ \\ ] / . test ( schematicFile ) ) {
39
+ // But we still want to redirect schematics located in `@angular/cli/node_modules`.
40
+ if (
41
+ normalizedSchematicFile . includes ( 'node_modules/@angular/cli/' ) &&
42
+ ! normalizedSchematicFile . includes ( 'node_modules/@angular/cli/node_modules/' )
43
+ ) {
39
44
return false ;
40
45
}
41
46
42
47
// Default is only first-party Angular schematic packages
43
48
// Angular schematics are safe to use in the wrapped VM context
44
- return / [ \/ \\ ] n o d e _ m o d u l e s [ \/ \\ ] @ (?: a n g u l a r | s c h e m a t i c s | n g u n i v e r s a l ) [ \/ \\ ] / . test ( schematicFile ) ;
49
+ return / \/ n o d e _ m o d u l e s \/ @ (?: a n g u l a r | s c h e m a t i c s | n g u n i v e r s a l ) \/ / . test ( normalizedSchematicFile ) ;
45
50
}
46
51
47
52
export class SchematicEngineHost extends NodeModulesEngineHost {
@@ -115,10 +120,8 @@ function wrap(
115
120
moduleCache : Map < string , unknown > ,
116
121
exportName ?: string ,
117
122
) : ( ) => unknown {
118
- const { createRequire, createRequireFromPath } = require ( 'module' ) ;
119
- // Node.js 10.x does not support `createRequire` so fallback to `createRequireFromPath`
120
- // `createRequireFromPath` is deprecated in 12+ and can be removed once 10.x support is removed
121
- const scopedRequire = createRequire ?.( schematicFile ) || createRequireFromPath ( schematicFile ) ;
123
+ const { createRequire } = require ( 'module' ) ;
124
+ const scopedRequire = createRequire ( schematicFile ) ;
122
125
123
126
const customRequire = function ( id : string ) {
124
127
if ( legacyModules [ id ] ) {
0 commit comments