Files
Charles Lyding e0015d3c45 refactor(migrations): support use of an ESM @angular/compiler-cli package (#43657)
Currently, migrations and schematics must be in CommonJS format. However, framework packages will only be ESM from v13 and onward. To support this configuration, dynamic import expressions are now used to load `@angular/compiler-cli` and its new secondary entry point `@angular/compiler-cli/private/migrations`. Dynamic imports within Node.js allow the `@angular/core` migrations’ CommonJS code to load ESM code. Unfortunately, TypeScript will currently, unconditionally down-level dynamic import into a require call. `require` calls cannot load ESM code and will result in a runtime error. To workaround this, a Function constructor is used to prevent TypeScript from changing the dynamic import. Once TypeScript provides support for keeping the dynamic import this workaround can be dropped and replaced with a standard dynamic import.  Due to the use of the dynamic import, a reference to the dynamically loaded modules must now be passed to all locations that use values from the modules.

PR Close #43657
2021-10-04 16:24:48 -07:00

18 lines
498 B
Python

load("//tools:defaults.bzl", "ts_library")
ts_library(
name = "utils",
srcs = glob(["**/*.ts"]),
tsconfig = "//packages/core/schematics:tsconfig.json",
visibility = ["//packages/core/schematics:__subpackages__"],
deps = [
"//packages/compiler",
"//packages/compiler-cli/private",
"@npm//@angular-devkit/core",
"@npm//@angular-devkit/schematics",
"@npm//@types/inquirer",
"@npm//@types/node",
"@npm//typescript",
],
)