Skip to content

Commit 581a65d

Browse files
rishipalcopybara-github
authored andcommitted
Prohibit passes from reintroducing any feature that already got transpiled
Except modules (as they can get reintroduced later by the ConvertChunksToESModules pass), prohibit any pass from adding a feature which already got transpiled. PiperOrigin-RevId: 555024562
1 parent 74a3d91 commit 581a65d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/com/google/javascript/jscomp/NodeUtil.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -6001,8 +6001,13 @@ static void addFeatureToScript(Node scriptNode, Feature feature, AbstractCompile
60016001
? currentFeatures.with(feature)
60026002
: FeatureSet.BARE_MINIMUM.with(feature);
60036003
scriptNode.putProp(Node.FEATURE_SET, newFeatures);
6004-
// TODO(lharker): remove this and instead validate that `feature` is already allowed.
6005-
compiler.setAllowableFeatures(compiler.getAllowableFeatures().with(feature));
6004+
if (feature != Feature.MODULES) {
6005+
// Except MODULES (which can get reintroduced later in ConvertChunksToEsModules pass),
6006+
// prohibit passes from reintroducing any feature that already got transpiled.
6007+
checkState(compiler.getAllowableFeatures().contains(feature));
6008+
} else {
6009+
compiler.setAllowableFeatures(compiler.getAllowableFeatures().with(feature));
6010+
}
60066011
}
60076012

60086013
/**

0 commit comments

Comments
 (0)