Skip to content

Commit

Permalink
Further restrict the non-hermetic reads of tsc_wrapped.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alexeagle committed Apr 26, 2018
1 parent fef4c71 commit 30d2894
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,10 @@ export class CompilerHost implements ts.CompilerHost, tsickle.TsickleHost {
// section of tsconfig.json, and that is what populates the knownFiles set.
// In addition, the node module resolver may need to read package.json files
// and these are not permitted in the files[] section.
// So we permit reading any files from the action inputs, even though this
// So we permit reading node_modules/* from action inputs, even though this
// can include data[] dependencies and is broader than we would like.
// This should only be enabled under Bazel, not Blaze.
if (this.allowActionInputReads) {
if (this.allowActionInputReads && filePath.indexOf('/node_modules/') >= 0) {
const result = this.fileLoader.fileExists(filePath);
if (DEBUG && !result && this.delegate.fileExists(filePath)) {
debug("Path exists, but is not registered in the cache", filePath);
Expand Down

0 comments on commit 30d2894

Please sign in to comment.