-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Walk dep tree visit exports fix for export {x, y as z} from 'module-identifier' #2726
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for PRing this. Just a couple notes.
} else if (n.getBooleanProp(Node.EXPORT_ALL_FROM)) { | ||
// export * from 'moduleIdentifier'; | ||
// not yet supported by closure ES6 transpilation: 'Wildcard export' is not yet implemented. | ||
} else if (n.hasTwoChildren()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only case we care about since I believe the only way an export has more than one child is if it exports from another module. There's no need to special case export *
. While transpilation may not handle this case yet, we still want to add it to the module graph.
Can you simplify this case to that single if test?
// export {x, y as z} from 'moduleIdentifier'; | ||
Node moduleIdentifier = n.getLastChild(); | ||
Node importNode = IR.importNode(IR.empty(), IR.empty(), moduleIdentifier.cloneNode()); | ||
visit(t, importNode, parent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than cloning a node and revisiting, can you refactor out the ES6 import case to a function getModuleNameFromImportPath
? Then you can just call that with the 2nd child and add the result to the graph.
@ChadKillingsworth thanks for doing the review. |
@ChadKillingsworth Thanks for the comments. I'll work on your recommended changes today. |
@ChadKillingsworth Pushed the refactored changes. Ended up adding two functions to capture the common functionality for import and export statements: Tested it against https://github.com/gregmagolan/closure-export-example. Also tested with an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Assigning to @blickly for import.
@gregmagolan can you squash your commits? Importing multiple commits is known to cause problems. |
0f6f89d
to
540822d
Compare
Done |
Is it possible to add a test of this? |
d443e54
to
86e151f
Compare
Added testProperEs6ModuleOrderingWithExport |
…identifier';` export format
b095232
to
eae1ea4
Compare
Great, thanks! Importing now... |
I needed the following change for a build to work that contained exports such as:
Files referenced on lines like this were not being included in the bundle. I took a look at the Es6ModuleRewrite code and used that as an example to update FindModuleDependencies.java so that the files referenced in export lines like the one above are visited and end up included in the bundle.
Originally PR'd against the walk-dep tree branch: ChadKillingsworth#2.
@ChadKillingsworth has taken a look at it