Skip to content

Commit

Permalink
Move reportUntranspilableFeatures pass to stage2
Browse files Browse the repository at this point in the history
Pros of moving to stage2:
1. typedAST: In stage1 the pass is skipped for typedAST builds anyway as it requires language_out which is not available in `checksOnly` mode of typedAST
2. semantics: removes features from compiler's featureset early (most other passes update the featureset only when transpiling)

Cons:
1. late error: the pass reports an impending problem with transpilation earlier. By moving it to stage2, we will lose the early error from JSCompiler for regular binary compilations
PiperOrigin-RevId: 549466005
  • Loading branch information
rishipal authored and copybara-github committed Jul 20, 2023
1 parent 101b758 commit fd3ffea
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/com/google/javascript/jscomp/DefaultPassConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,6 @@ protected PassListBuilder getChecks() {
// Run this pass before any pass tries to inject new runtime libraries
checks.maybeAdd(addSyntheticScript);

if (!options.checksOnly) {
checks.maybeAdd(reportUntranspilableFeatures);
}

checks.maybeAdd(gatherGettersAndSetters);

if (options.getLanguageIn().toFeatureSet().contains(Feature.DYNAMIC_IMPORT)
Expand Down Expand Up @@ -511,6 +507,7 @@ protected PassListBuilder getChecks() {
protected PassListBuilder getOptimizations() {
PassListBuilder passes = new PassListBuilder(options);
if (options.isPropertyRenamingOnlyCompilationMode()) {
passes.maybeAdd(reportUntranspilableFeatures);
TranspilationPasses.addTranspilationRuntimeLibraries(passes);
passes.maybeAdd(closureProvidesRequires);
passes.maybeAdd(processDefinesOptimize);
Expand Down Expand Up @@ -554,6 +551,8 @@ protected PassListBuilder getOptimizations() {
passes.maybeAdd(j2clPass);
}

passes.maybeAdd(reportUntranspilableFeatures);

TranspilationPasses.addTranspilationRuntimeLibraries(passes);

if (options.rewritePolyfills || options.getIsolatePolyfills()) {
Expand Down

0 comments on commit fd3ffea

Please sign in to comment.