-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Adds the Module transformers #7206
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
Adds the Module transformers #7206
Conversation
define, | ||
flattenNodes([ | ||
// Add the module name (if provided). | ||
moduleName, |
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.
If it's undefined
, will it be skipped in the emit or emitted as undefined
?
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.
flattenNodes
removes undefined nodes.
const moduleName = getExternalModuleNameLiteral(importNode); | ||
return createCall( | ||
createIdentifier("require"), | ||
moduleName ? [moduleName] : [] |
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.
without moduleName
, this just generates require()
, right? What will the larger generated statement be in that case, and is it meaningful?
|
||
function visitExportDeclaration(node: ExportDeclaration): OneOrMany<Statement> { | ||
if (contains(externalImports, node)) { | ||
const generatedName = getGeneratedNameForNode(node); |
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.
why does visitExportDeclaration
save the result of getGeneratedNameForNode
but visitImportDeclaration
and visitImportEqualsDeclaration
doesn't?
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.
visitExportDeclaration
must always callgetGeneratedNameForNode
.visitImportDeclaration
calls it conditionally.visitImportEqualsDeclaration
doesn't call it at all.
The Module transformer is designed to transform most Module-specific syntax into compatible down-level JavaScript, including:
The Module transformers include support for the following module kinds:
Related Pull Requests: