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

Refactor CommonJS rewriting to be a normal pass #2691

Closed

Conversation

ChadKillingsworth
Copy link
Collaborator

Reworks CommonJS module rewriting as well as imported script rewriting into normal passes. Moves them into the default pass configuration.

Rewriting JSON files will be moved in a separate PR.

import com.google.common.collect.ImmutableList;
import com.google.javascript.rhino.Node;

/** Unit tests for {@link RewriteJsonToModule} */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/** Unit tests for {@link Es6RewriteScriptsToModules} */

@@ -615,6 +615,9 @@ abstract void updateGlobalVarReferences(Map<Var, ReferenceCollection>
*/
abstract ModuleLoader getModuleLoader();

/** Lookup the type of a module from its name. */
abstract CompilerInput.ModuleType getModuleTypeByName(String moduleName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not following why we need this method. It looks like all the callers already have access to the CompilerInput in question, and that already contains the getJsModuleType() method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually stems from other work which has yet to be PR'd. It makes much more sense to use this directly off the input though, so I've switched it.

}

/** Return whether or not the given script node represents an ES6 module file. */
public static boolean isEs6ModuleRoot(Node scriptNode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like now we have 3 definitions of this method. I'd probably get rid of all but one.

@ChadKillingsworth
Copy link
Collaborator Author

@blickly Changes made. Let me know when you are ready to import and I'll squash the commits.

@blickly
Copy link
Contributor

blickly commented Nov 10, 2017

LGTM, let's squash and import.

Thanks Chad!

@ChadKillingsworth
Copy link
Collaborator Author

@blickly Sqaushed

@ChadKillingsworth ChadKillingsworth deleted the common-js-pass branch November 17, 2020 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants