Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit d1c107e

Browse files
committed
Further restrict the non-hermetic reads of tsc_wrapped.
As indicated in this comment, we need to allow TS to read files like node_modules/foo/package.json, and this cannot be included in the files[] list in tsconfig, so we still cannot restrict fileExists to only files in the cache. Ultimately as Martin points out this is the correct behavior. This fix is needed in Angular, where we compile rxjs in an aspect to get the "ESM5" JavaScript flavor, and this suffers from microsoft/TypeScript#22208 where we try to read a `.ts` file when the `.d.ts` file was in the root files. In this case we don't have a worker mode so the usual sandboxing doesn't mask the problem. PiperOrigin-RevId: 194095485
1 parent 1727c07 commit d1c107e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/tsc_wrapped/compiler_host.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,10 @@ export class CompilerHost implements ts.CompilerHost, tsickle.TsickleHost {
383383
// section of tsconfig.json, and that is what populates the knownFiles set.
384384
// In addition, the node module resolver may need to read package.json files
385385
// and these are not permitted in the files[] section.
386-
// So we permit reading any files from the action inputs, even though this
386+
// So we permit reading node_modules/* from action inputs, even though this
387387
// can include data[] dependencies and is broader than we would like.
388388
// This should only be enabled under Bazel, not Blaze.
389-
if (this.allowActionInputReads) {
389+
if (this.allowActionInputReads && filePath.indexOf('/node_modules/') >= 0) {
390390
const result = this.fileLoader.fileExists(filePath);
391391
if (DEBUG && !result && this.delegate.fileExists(filePath)) {
392392
debug("Path exists, but is not registered in the cache", filePath);

0 commit comments

Comments
 (0)