Skip to content

Commit 34a26b6

Browse files
alan-agius4vikerman
authored andcommitted
fix(@ngtools/webpack): skip NGCC when file system is read only
If the package.json of a module is read only we should skip calling NGCC. Under Bazel when running under sandbox the filesystem is read-only. See also: angular/angular#33366
1 parent c19751f commit 34a26b6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/ngcc_processor.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import { Logger, PathMappings, process as mainNgcc } from '@angular/compiler-cli/ngcc';
10-
import { existsSync } from 'fs';
10+
import { accessSync, constants, existsSync } from 'fs';
1111
import * as path from 'path';
1212
import * as ts from 'typescript';
1313
import { InputFileSystem } from 'webpack';
@@ -67,6 +67,17 @@ export class NgccProcessor {
6767
return;
6868
}
6969

70+
// If the package.json is read only we should skip calling NGCC.
71+
// With Bazel when running under sandbox the filesystem is read-only.
72+
try {
73+
accessSync(packageJsonPath, constants.W_OK);
74+
} catch {
75+
// add it to processed so the second time round we skip this.
76+
this._processedModules.add(moduleName);
77+
78+
return;
79+
}
80+
7081
const timeLabel = `NgccProcessor.processModule.ngcc.process+${moduleName}`;
7182
time(timeLabel);
7283
mainNgcc({

0 commit comments

Comments
 (0)