Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore ES6 module processing of input #2637

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/com/google/javascript/jscomp/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,11 @@ Node parseInputs() {
if (!inputsToRewrite.isEmpty()) {
forceToEs6Modules(inputsToRewrite.values());
}

if (options.needsTranspilationFrom(FeatureSet.ES6_MODULES)) {
processEs6Modules(parsePotentialModules(inputs));
}

} else {
// Use an empty module loader if we're not actually dealing with modules.
this.moduleLoader = ModuleLoader.EMPTY;
Expand Down Expand Up @@ -2031,6 +2036,20 @@ void forceToEs6Modules(Collection<CompilerInput> inputsToProcess) {
}
}

void processEs6Modules(List<CompilerInput> inputsToProcess) {
for (CompilerInput input : inputsToProcess) {
input.setCompiler(this);
Node root = input.getAstRoot(this);
if (root == null) {
continue;
}
if (Es6RewriteModules.isEs6ModuleRoot(root)) {
new Es6RewriteModules(this).processFile(root);
}
}
setFeatureSet(featureSet.without(Feature.MODULES));
}

private List<CompilerInput> parsePotentialModules(List<CompilerInput> inputsToProcess) {
List<CompilerInput> filteredInputs = new ArrayList<>();
for (CompilerInput input : inputsToProcess) {
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/Es6RewriteModules.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void hotSwapScript(Node scriptNode, Node originalRoot) {
/**
* Rewrite a single ES6 module file to a global script version.
*/
private void processFile(Node root) {
public void processFile(Node root) {
checkArgument(isEs6ModuleRoot(root), root);
clearState();
NodeTraversal.traverseEs6(compiler, root, this);
Expand Down