-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(compiler-cli): ngtsc shim files not being generated on case-insensitive platforms #27466
fix(compiler-cli): ngtsc shim files not being generated on case-insensitive platforms #27466
Conversation
You can preview f368ade at https://pr27466-f368ade.ngbuilds.io/. |
I experience the same issue in macOS (APFS filesystem), so this is not Windows specific. Your fix works for me too 👍 |
…sitive platforms Common insensitive platforms are `win32/win64` (see: [here](https://github.com/Microsoft/TypeScript/blob/3e4c5c95abd515eb9713b881d27ab3a93cc00461/src/compiler/sys.ts#L681-L682)) Currently when running `bazel build packages/core --define=compile=aot`, the `compiler-cli` will throw because it cannot find the `index.ngfactory.ts` file in the compiler host. This is because the shim host wrapper is not properly generating the requested `ngfactory` file. This happens because we call `getCanonicalFileName` that returns a path that is different to the actual program filenames that are used to construct a map of generated files. Since the generators always use the paths which are not "canonical" and pases them internally like that, we can just stop manually calling `getCanonicalFileName`.
f368ade
to
95e6b07
Compare
@JoostK Good catch. Didn't know that MacOS (APFS) is case-insensitive. Updated the title/description. Thanks |
You can preview 95e6b07 at https://pr27466-95e6b07.ngbuilds.io/. |
…sitive platforms (#27466) Common insensitive platforms are `win32/win64` (see: [here](https://github.com/Microsoft/TypeScript/blob/3e4c5c95abd515eb9713b881d27ab3a93cc00461/src/compiler/sys.ts#L681-L682)) Currently when running `bazel build packages/core --define=compile=aot`, the `compiler-cli` will throw because it cannot find the `index.ngfactory.ts` file in the compiler host. This is because the shim host wrapper is not properly generating the requested `ngfactory` file. This happens because we call `getCanonicalFileName` that returns a path that is different to the actual program filenames that are used to construct a map of generated files. Since the generators always use the paths which are not "canonical" and pases them internally like that, we can just stop manually calling `getCanonicalFileName`. PR Close #27466
…sitive platforms (angular#27466) Common insensitive platforms are `win32/win64` (see: [here](https://github.com/Microsoft/TypeScript/blob/3e4c5c95abd515eb9713b881d27ab3a93cc00461/src/compiler/sys.ts#L681-L682)) Currently when running `bazel build packages/core --define=compile=aot`, the `compiler-cli` will throw because it cannot find the `index.ngfactory.ts` file in the compiler host. This is because the shim host wrapper is not properly generating the requested `ngfactory` file. This happens because we call `getCanonicalFileName` that returns a path that is different to the actual program filenames that are used to construct a map of generated files. Since the generators always use the paths which are not "canonical" and pases them internally like that, we can just stop manually calling `getCanonicalFileName`. PR Close angular#27466
…tforms This change is kind of similar to angular#27466, but instead of ensuring that these shims can be generated, we also need to make sure that developers are able to also use the factory shims like with `ngc`. This issue is now surfacing because we have various old examples which are now also built with `ngtsc` (due to the bazel migration). On case insensitive platforms (e.g. windows) these examples cannot be built because ngtsc fails the app imports a generated shim file (such as the factory shim files). This is because the `GeneratedShimsHostWrapper` TypeScript host uses the `getCanonicalFileName` method in order to check whether a given file/module exists in the generator file maps. e.g. ``` // Generator Map: 'C:/users/paul/_bazel_paul/lm3s4mgv/execroot/angular/packages/core/index.ngfactory.ts' => 'C:/users/paul/_bazel_paul/lm3s4mgv/execroot/angular/packages/core/index.ts', // Path passed into `fileExists` C:/users/paul/_bazel_paul/lm3s4mgv/execroot/angular/packages/core/index.ngfactory.ts // After getCanonicalFileName (notice the **lower-case drive name**) c:/users/paul/_bazel_paul/lm3s4mgv/execroot/angular/packages/core/index.ngfactory.ts ``` As seen above, the generator map does not use the canonical file names, as well as TypeScript internally does not pass around canonical file names. We can fix this by removing the manual call to `getCanonicalFileName` and just following TypeScript internal-semantics.
…tforms (#28831) This change is kind of similar to #27466, but instead of ensuring that these shims can be generated, we also need to make sure that developers are able to also use the factory shims like with `ngc`. This issue is now surfacing because we have various old examples which are now also built with `ngtsc` (due to the bazel migration). On case insensitive platforms (e.g. windows) these examples cannot be built because ngtsc fails the app imports a generated shim file (such as the factory shim files). This is because the `GeneratedShimsHostWrapper` TypeScript host uses the `getCanonicalFileName` method in order to check whether a given file/module exists in the generator file maps. e.g. ``` // Generator Map: 'C:/users/paul/_bazel_paul/lm3s4mgv/execroot/angular/packages/core/index.ngfactory.ts' => 'C:/users/paul/_bazel_paul/lm3s4mgv/execroot/angular/packages/core/index.ts', // Path passed into `fileExists` C:/users/paul/_bazel_paul/lm3s4mgv/execroot/angular/packages/core/index.ngfactory.ts // After getCanonicalFileName (notice the **lower-case drive name**) c:/users/paul/_bazel_paul/lm3s4mgv/execroot/angular/packages/core/index.ngfactory.ts ``` As seen above, the generator map does not use the canonical file names, as well as TypeScript internally does not pass around canonical file names. We can fix this by removing the manual call to `getCanonicalFileName` and just following TypeScript internal-semantics. PR Close #28831
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Common insensitive platforms are
win32/win64
(see: here)Currently when running
bazel build packages/core --define=compile=aot
, thecompiler-cli
will throw because it cannot find theindex.ngfactory.ts
file in the compiler host. This is because the shim host wrapper is not properly generating the requestedngfactory
file.This happens because we call
getCanonicalFileName
that returns a path that is different to the actualrootNames
(passed toNgtscProgram
) which are used to construct a map of generated files.Since the generators always use the paths which are not normalized and TypeScript seems to pass "non"-canonical paths to the host
getSourceFile
, we should be able to stop manually callinggetCanonicalFileName
(this would then follow typescript internal semantics apparently)Example:
See source code of getCanonicalFileName.