To improve cross platform support, all file access (and path manipulation) is now done through a well known interface (`FileSystem`). For testing a number of `MockFileSystem` implementations are provided. These provide an in-memory file-system which emulates operating systems like OS/X, Unix and Windows. The current file system is always available via the static method, `FileSystem.getFileSystem()`. This is also used by a number of static methods on `AbsoluteFsPath` and `PathSegment`, to avoid having to pass `FileSystem` objects around all the time. The result of this is that one must be careful to ensure that the file-system has been initialized before using any of these static methods. To prevent this happening accidentally the current file system always starts out as an instance of `InvalidFileSystem`, which will throw an error if any of its methods are called. You can set the current file-system by calling `FileSystem.setFileSystem()`. During testing you can call the helper function `initMockFileSystem(os)` which takes a string name of the OS to emulate, and will also monkey-patch aspects of the TypeScript library to ensure that TS is also using the current file-system. Finally there is the `NgtscCompilerHost` to be used for any TypeScript compilation, which uses a given file-system. All tests that interact with the file-system should be tested against each of the mock file-systems. A series of helpers have been provided to support such tests: * `runInEachFileSystem()` - wrap your tests in this helper to run all the wrapped tests in each of the mock file-systems. * `addTestFilesToFileSystem()` - use this to add files and their contents to the mock file system for testing. * `loadTestFilesFromDisk()` - use this to load a mirror image of files on disk into the in-memory mock file-system. * `loadFakeCore()` - use this to load a fake version of `@angular/core` into the mock file-system. All ngcc and ngtsc source and tests now use this virtual file-system setup. PR Close #30921
71 lines
2.1 KiB
Python
71 lines
2.1 KiB
Python
package(default_visibility = ["//visibility:public"])
|
|
|
|
load("//tools:defaults.bzl", "npm_package", "ts_library")
|
|
load("@npm_bazel_typescript//:index.bzl", "ts_config")
|
|
|
|
ts_config(
|
|
name = "tsconfig",
|
|
src = "tsconfig-build.json",
|
|
deps = ["//packages:tsconfig-build.json"],
|
|
)
|
|
|
|
ts_library(
|
|
name = "compiler-cli",
|
|
srcs = glob(
|
|
[
|
|
"*.ts",
|
|
"src/**/*.ts",
|
|
],
|
|
exclude = [
|
|
"src/integrationtest/**/*.ts",
|
|
],
|
|
),
|
|
tsconfig = ":tsconfig",
|
|
deps = [
|
|
"//packages/compiler",
|
|
"//packages/compiler-cli/src/ngtsc/annotations",
|
|
"//packages/compiler-cli/src/ngtsc/cycles",
|
|
"//packages/compiler-cli/src/ngtsc/diagnostics",
|
|
"//packages/compiler-cli/src/ngtsc/entry_point",
|
|
"//packages/compiler-cli/src/ngtsc/file_system",
|
|
"//packages/compiler-cli/src/ngtsc/imports",
|
|
"//packages/compiler-cli/src/ngtsc/incremental",
|
|
"//packages/compiler-cli/src/ngtsc/indexer",
|
|
"//packages/compiler-cli/src/ngtsc/metadata",
|
|
"//packages/compiler-cli/src/ngtsc/partial_evaluator",
|
|
"//packages/compiler-cli/src/ngtsc/perf",
|
|
"//packages/compiler-cli/src/ngtsc/reflection",
|
|
"//packages/compiler-cli/src/ngtsc/routing",
|
|
"//packages/compiler-cli/src/ngtsc/scope",
|
|
"//packages/compiler-cli/src/ngtsc/shims",
|
|
"//packages/compiler-cli/src/ngtsc/switch",
|
|
"//packages/compiler-cli/src/ngtsc/transform",
|
|
"//packages/compiler-cli/src/ngtsc/typecheck",
|
|
"//packages/compiler-cli/src/ngtsc/util",
|
|
"@npm//@bazel/typescript",
|
|
"@npm//@types",
|
|
"@npm//reflect-metadata",
|
|
"@npm//tsickle",
|
|
"@npm//typescript",
|
|
],
|
|
)
|
|
|
|
npm_package(
|
|
name = "npm_package",
|
|
srcs = [
|
|
"package.json",
|
|
],
|
|
tags = [
|
|
"release-with-framework",
|
|
],
|
|
# Do not add more to this list.
|
|
# Dependencies on the full npm_package cause long re-builds.
|
|
visibility = [
|
|
"//packages/compiler-cli/integrationtest:__pkg__",
|
|
],
|
|
deps = [
|
|
":compiler-cli",
|
|
"//packages/compiler-cli/ngcc",
|
|
],
|
|
)
|