fix(migrations): fix LS server resolve with schematics encapsulation #14832
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #13712
Since the encapsulation runs our source using vm.runInNewContext with

customRequirefunction https://github.com/angular/angular-cli/blob/e51b9068763a115fa27d06e2dd7988b34a3f677c/packages/angular/cli/src/command-builder/utilities/schematic-engine-host.ts#L233-L236 that's strictly require our module resolve code fails withTypeError: require.resolve is not a functionbut that of course is only visible with log tracing on:But even if that succeeded, we also have the patch to point the first service init for the Angular compilation into the project entry point and that doesn't support the newer application builders that switched to
browserandserverentry points instead ofmain. So fixed that as well.Lastly, the very same encapsulation doesn't allow for debug session using
ts-nodeanymore, since both that package (see TypeStrong/ts-node#802) and the experimental native typescript atm (nodejs/loaders#116) don't support that directly. So switched the launch config for VS Code to use the compiled migrations with tasks to enable source maps and since the encapsulation wrap adds 3 extra lines an additional patch for that as well - that might need some adjustments down the line, I see 18.2 switched to the native module wrap and that causes just one 1 line offset.Additional information (check all that apply):
Checklist:
feature/README.MDupdates for the feature docsREADME.MDCHANGELOG.MDupdates for newly added functionalityng updatemigrations for the breaking changes (migrations guidelines)