-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle some cases of inlined exports and tests.
- Loading branch information
Joel Jeske
committed
May 20, 2020
1 parent
2835ee4
commit 8362b3a
Showing
21 changed files
with
184 additions
and
65 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import Variable from '../ast/variables/Variable'; | ||
|
||
export function getSystemExportStatement(exportedVariables: Variable[]): string { | ||
if (exportedVariables.length === 1) { | ||
if (exportedVariables.length === 1 && exportedVariables[0].exportName && exportedVariables[0].exportName.length === 1) { | ||
return `exports('${exportedVariables[0].safeExportName || | ||
exportedVariables[0].exportName}', ${exportedVariables[0].getName()});`; | ||
exportedVariables[0].exportName[0]}', ${exportedVariables[0].getName()})`; | ||
} else { | ||
return `exports({${exportedVariables | ||
.map(variable => `${variable.safeExportName || variable.exportName}: ${variable.getName()}`) | ||
.join(', ')}});`; | ||
return `exports({ ${exportedVariables | ||
.map(variable => | ||
// TODO: do we always have export names at this point? | ||
variable.exportName!.map(exportName => `${exportName}: ${variable.getName()}`) | ||
.join(', ') | ||
) | ||
.join(', ')} })`; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
test/form/samples/system-multiple-class-export-bindings/_config.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
description: 'supports binding a class declaration under multiple names in systemJS', | ||
solo: true, | ||
options: { | ||
output: { | ||
format: 'system' | ||
} | ||
} | ||
}; |
10 changes: 10 additions & 0 deletions
10
test/form/samples/system-multiple-class-export-bindings/_expected.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
System.register([], function (exports) { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
|
||
class a {} exports({ a: a, b: a }); | ||
|
||
} | ||
}; | ||
}); |
3 changes: 3 additions & 0 deletions
3
test/form/samples/system-multiple-class-export-bindings/main.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class a {}; | ||
|
||
export { a as b }; |
10 changes: 10 additions & 0 deletions
10
test/form/samples/system-multiple-export-default-export-bindings/_config.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
description: 'supports binding a variable declaration under multiple names in systemJS', | ||
solo: true, | ||
options: { | ||
output: { | ||
format: 'system', | ||
exports: 'named' | ||
} | ||
} | ||
}; |
10 changes: 10 additions & 0 deletions
10
test/form/samples/system-multiple-export-default-export-bindings/_expected.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
System.register([], function (exports) { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
|
||
class A {} exports({ A: A, default: A }); | ||
|
||
} | ||
}; | ||
}); |
3 changes: 3 additions & 0 deletions
3
test/form/samples/system-multiple-export-default-export-bindings/main.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default class A {} | ||
export { A } | ||
|
9 changes: 9 additions & 0 deletions
9
test/form/samples/system-multiple-variable-declaration-export-bindings/_config.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
description: 'supports binding a variable declaration under multiple names in systemJS', | ||
solo: true, | ||
options: { | ||
output: { | ||
format: 'system' | ||
} | ||
} | ||
}; |
11 changes: 11 additions & 0 deletions
11
test/form/samples/system-multiple-variable-declaration-export-bindings/_expected.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
System.register([], function (exports) { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
|
||
let a = 123, b = exports('b', 456); | ||
exports({ a: a, c: a }); | ||
|
||
} | ||
}; | ||
}); |
2 changes: 2 additions & 0 deletions
2
test/form/samples/system-multiple-variable-declaration-export-bindings/main.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export let a = 123, b = 456; | ||
export { a as c }; |
9 changes: 9 additions & 0 deletions
9
test/form/samples/system-multiple-variable-update-export-bindings copy/_config.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
description: 'supports binding a variable declaration under multiple names in systemJS', | ||
solo: true, | ||
options: { | ||
output: { | ||
format: 'system' | ||
} | ||
} | ||
}; |
11 changes: 11 additions & 0 deletions
11
test/form/samples/system-multiple-variable-update-export-bindings copy/_expected.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
System.register([], function (exports) { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
|
||
let a = 123; exports({ a: a, b: a }); | ||
a++, exports({ a: a, b: a }); | ||
|
||
} | ||
}; | ||
}); |
3 changes: 3 additions & 0 deletions
3
test/form/samples/system-multiple-variable-update-export-bindings copy/main.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export let a = 123; | ||
a++; | ||
export { a as b }; |