Skip to content

Commit

Permalink
Run the new ModuleMapCreator pass and test its hot swap functionality.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=232399219
  • Loading branch information
johnplaisted authored and blickly committed Feb 6, 2019
1 parent d60394e commit f04d80f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/com/google/javascript/jscomp/DefaultPassConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import com.google.javascript.jscomp.lint.CheckRequiresAndProvidesSorted;
import com.google.javascript.jscomp.lint.CheckUnusedLabels;
import com.google.javascript.jscomp.lint.CheckUselessBlocks;
import com.google.javascript.jscomp.modules.ModuleMapCreator;
import com.google.javascript.jscomp.parsing.ParserRunner;
import com.google.javascript.jscomp.parsing.parser.FeatureSet;
import com.google.javascript.rhino.IR;
Expand Down Expand Up @@ -156,6 +157,7 @@ protected List<PassFactory> getTranspileOnlyPasses() {

passes.add(checkVariableReferencesForTranspileOnly);
passes.add(gatherModuleMetadataPass);
passes.add(createModuleMapPass);

if (options.getLanguageIn().toFeatureSet().has(FeatureSet.Feature.MODULES)) {
passes.add(rewriteGoogJsImports);
Expand Down Expand Up @@ -275,6 +277,7 @@ protected List<PassFactory> getChecks() {
checks.add(checkTypeImportCodeReferences);

checks.add(gatherModuleMetadataPass);
checks.add(createModuleMapPass);

if (options.enables(DiagnosticGroups.LINT_CHECKS)) {
checks.add(lintChecks);
Expand Down Expand Up @@ -1090,6 +1093,12 @@ private void assertValidOrderForChecks(List<PassFactory> checks) {
closureCheckModule,
"Need to gather module metadata before checking closure modules.");

assertPassOrder(
checks,
gatherModuleMetadataPass,
createModuleMapPass,
"Need to gather module metadata before scanning modules.");

assertPassOrder(
checks,
checkClosureImports,
Expand Down Expand Up @@ -3436,6 +3445,19 @@ protected FeatureSet featureSet() {
}
};

private final HotSwapPassFactory createModuleMapPass =
new HotSwapPassFactory(PassNames.CREATE_MODULE_MAP) {
@Override
protected HotSwapCompilerPass create(AbstractCompiler compiler) {
return new ModuleMapCreator(compiler, compiler.getModuleMetadataMap());
}

@Override
protected FeatureSet featureSet() {
return ES_NEXT;
}
};

private final PassFactory gatherGettersAndSetters =
new PassFactory(PassNames.GATHER_GETTERS_AND_SETTERS, /* isOneTimePass= */ true) {
@Override
Expand Down
1 change: 1 addition & 0 deletions src/com/google/javascript/jscomp/PassNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public final class PassNames {
public static final String COLLAPSE_PROPERTIES = "collapseProperties";
public static final String COLLAPSE_VARIABLE_DECLARATIONS = "collapseVariableDeclarations";
public static final String CONVERT_TO_DOTTED_PROPERTIES = "convertToDottedProperties";
public static final String CREATE_MODULE_MAP = "createModuleMap";
public static final String CROSS_CHUNK_CODE_MOTION = "crossChunkCodeMotion";
public static final String CROSS_CHUNK_METHOD_MOTION = "crossChunkMethodMotion";
public static final String DEAD_ASSIGNMENT_ELIMINATION = "deadAssignmentsElimination";
Expand Down

0 comments on commit f04d80f

Please sign in to comment.