-
Notifications
You must be signed in to change notification settings - Fork 13.4k
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
Merged
rbuckton
merged 17 commits into
transforms-transformer-es6
from
transforms-transformer-module
Mar 18, 2016
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
39628d7
Added CommonJS/AMD/UMD module transformer
rbuckton 5564537
Added initial SystemJS transformer.
rbuckton 0b64048
Merge branch 'transforms-transformer-es6' into transforms-transformer…
rbuckton 0d8e152
Merge branch 'transforms-transformer-es6' into transforms-transformer…
rbuckton 72bfd2f
Fixed linter warnings.
rbuckton 70cbb9b
Merge branch 'transforms-transformer-es6' into transforms-transformer…
rbuckton c4a75ba
Merge branch 'transforms-transformer-es6' into transforms-transformer…
rbuckton 72eebdb
Switched to onEmitNode
rbuckton 1cf183b
Fixed invalid assertion in ts transformer
rbuckton d89e21a
General fixes and cleanup
rbuckton 5b8cf96
Moved modifier related flags to separate enum
rbuckton 99e6ad8
Removed ModifiersArray
rbuckton 47cdfbe
Add support for array return values from visitors
rbuckton 2699bf9
Removed NodeArrayNode in favor of arrays
rbuckton 94018a1
cleaned up assertions and removed flattenNodes.
rbuckton ad0dd4e
Fixed perf issue in binder, plus PR feedback
rbuckton 44ca7d4
Updated baselines
rbuckton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixed linter warnings.
- Loading branch information
commit 72bfd2f5b6a8467c52a4e99e2fc27bab04cc532c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,7 @@ namespace ts { | |
| let contextObjectForFile: Identifier; | ||
| let exportedLocalNames: Identifier[]; | ||
| let exportedFunctionDeclarations: ExpressionStatement[]; | ||
| let noSubstitution: Map<boolean> = {}; | ||
| const noSubstitution: Map<boolean> = {}; | ||
|
|
||
| return transformSourceFile; | ||
|
|
||
|
|
@@ -992,7 +992,7 @@ namespace ts { | |
|
|
||
| function hasExportedReferenceInArrayDestructuringElement(node: Expression): boolean { | ||
| if (isSpreadElementExpression(node)) { | ||
| let expression = node.expression; | ||
| const expression = node.expression; | ||
| return isIdentifier(expression) && isExportedBinding(expression); | ||
| } | ||
| else { | ||
|
|
@@ -1002,7 +1002,7 @@ namespace ts { | |
|
|
||
| function hasExportedReferenceInDestructuringElement(node: Expression): boolean { | ||
| if (isBinaryExpression(node)) { | ||
| let left = node.left; | ||
| const left = node.left; | ||
| return node.operatorToken.kind === SyntaxKind.EqualsToken | ||
| && isDestructuringPattern(left) | ||
| && hasExportedReferenceInDestructuringPattern(left); | ||
|
|
@@ -1011,7 +1011,7 @@ namespace ts { | |
| return isExportedBinding(node); | ||
| } | ||
| else if (isSpreadElementExpression(node)) { | ||
| let expression = node.expression; | ||
| const expression = node.expression; | ||
| return isIdentifier(expression) && isExportedBinding(expression); | ||
| } | ||
| else if (isDestructuringPattern(node)) { | ||
|
|
@@ -1052,7 +1052,7 @@ namespace ts { | |
| } | ||
|
|
||
| function getExternalModuleNameLiteral(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration) { | ||
| let moduleName = getExternalModuleName(importNode); | ||
| const moduleName = getExternalModuleName(importNode); | ||
| if (moduleName.kind === SyntaxKind.StringLiteral) { | ||
| return tryRenameExternalModule(<StringLiteral>moduleName) | ||
| || getSynthesizedNode(<StringLiteral>moduleName); | ||
|
|
@@ -1074,12 +1074,12 @@ namespace ts { | |
| } | ||
|
|
||
| function getLocalNameTextForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): string { | ||
| let name = getLocalNameForExternalImport(node); | ||
| const name = getLocalNameForExternalImport(node); | ||
| return name ? name.text : undefined; | ||
| } | ||
|
|
||
| function getLocalNameForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): Identifier { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's weird, there are two identical declarations of this function in this review |
||
| let namespaceDeclaration = getNamespaceDeclarationNode(node); | ||
| const namespaceDeclaration = getNamespaceDeclarationNode(node); | ||
| if (namespaceDeclaration && !isDefaultImport(node)) { | ||
| return createIdentifier(getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name)); | ||
| } | ||
|
|
@@ -1182,8 +1182,8 @@ namespace ts { | |
| * @param node The declaration to export. | ||
| */ | ||
| function createDeclarationExport(node: DeclarationStatement) { | ||
| let declarationName = getDeclarationName(node); | ||
| let exportName = node.flags & NodeFlags.Default ? createLiteral("default") : declarationName; | ||
| const declarationName = getDeclarationName(node); | ||
| const exportName = node.flags & NodeFlags.Default ? createLiteral("default") : declarationName; | ||
| return createExportStatement(exportName, declarationName); | ||
| } | ||
|
|
||
|
|
@@ -1209,15 +1209,15 @@ namespace ts { | |
| } | ||
|
|
||
| function collectDependencyGroups(externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]) { | ||
| let groupIndices: Map<number> = {}; | ||
| let dependencyGroups: DependencyGroup[] = []; | ||
| for (let i = 0; i < externalImports.length; ++i) { | ||
| let externalImport = externalImports[i]; | ||
| let externalModuleName = getExternalModuleNameLiteral(externalImport); | ||
| let text = externalModuleName.text; | ||
| const groupIndices: Map<number> = {}; | ||
| const dependencyGroups: DependencyGroup[] = []; | ||
| for (let i = 0; i < externalImports.length; i++) { | ||
| const externalImport = externalImports[i]; | ||
| const externalModuleName = getExternalModuleNameLiteral(externalImport); | ||
| const text = externalModuleName.text; | ||
| if (hasProperty(groupIndices, text)) { | ||
| // deduplicate/group entries in dependency list by the dependency name | ||
| let groupIndex = groupIndices[text]; | ||
| const groupIndex = groupIndices[text]; | ||
| dependencyGroups[groupIndex].externalImports.push(externalImport); | ||
| continue; | ||
| } | ||
|
|
@@ -1245,14 +1245,6 @@ namespace ts { | |
| exportedLocalNames.push(name); | ||
| } | ||
|
|
||
| function hoistExportedVariableDeclaration(name: Identifier) { | ||
|
|
||
| } | ||
|
|
||
| function hoistExportedFunctionDeclaration(node: FunctionDeclaration) { | ||
|
|
||
| } | ||
|
|
||
| function recordExportedFunctionDeclaration(node: FunctionDeclaration) { | ||
| if (!exportedFunctionDeclarations) { | ||
| exportedFunctionDeclarations = []; | ||
|
|
@@ -1262,7 +1254,7 @@ namespace ts { | |
| } | ||
|
|
||
| function hoistBindingElement(node: VariableDeclaration | BindingElement, isExported: boolean) { | ||
| let name = node.name; | ||
| const name = node.name; | ||
| if (isIdentifier(name)) { | ||
| hoistVariableDeclaration(getSynthesizedNode(name)); | ||
| if (isExported) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
visitExportDeclarationsave the result ofgetGeneratedNameForNodebutvisitImportDeclarationandvisitImportEqualsDeclarationdoesn'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.
visitExportDeclarationmust always callgetGeneratedNameForNode.visitImportDeclarationcalls it conditionally.visitImportEqualsDeclarationdoesn't call it at all.