From a8d6c2beaf4a1ba91f24e3c17e427989419f82fd Mon Sep 17 00:00:00 2001 From: Michael Rawlings Date: Tue, 24 Sep 2019 01:16:53 -1000 Subject: [PATCH 1/3] use getters to define live export bindings --- src/compiler/transformers/module/module.ts | 50 ++++++++++++++----- .../reference/ambientShorthand_reExport.js | 9 +++- .../reference/commentsOnRequireStatement.js | 4 +- .../constEnumPreserveEmitReexport.js | 2 +- ...onEmitDefaultExportWithStaticAssignment.js | 2 +- .../declarationEmitExportDeclaration.js | 2 +- ...clarationEmitReexportedSymlinkReference.js | 7 ++- ...larationEmitReexportedSymlinkReference2.js | 7 ++- ...larationEmitReexportedSymlinkReference3.js | 7 ++- .../reference/declarationMapsMultifile.js | 2 +- .../reference/declarationMapsOutFile.js | 2 +- .../reference/destructuredDeclarationEmit.js | 4 +- .../doubleUnderscoreExportStarConflict.js | 7 ++- .../baselines/reference/es6ExportAllInEs5.js | 7 ++- ...ExportClauseWithoutModuleSpecifierInEs5.js | 8 +-- .../reference/es6ExportEqualsInterop.js | 27 ++++++---- .../reference/esModuleInteropTslibHelpers.js | 2 +- ...ationWithModuleSpecifierNameOnNextLine1.js | 6 +-- tests/baselines/reference/exportStar-amd.js | 7 ++- tests/baselines/reference/exportStar.js | 7 ++- .../reference/exportStarForValues7.js | 7 ++- .../reference/exportStarForValues8.js | 14 +++++- .../reference/exportStarForValues9.js | 14 +++++- .../reference/exportStarFromEmptyModule.js | 7 ++- .../reference/exportsAndImports1-amd.js | 24 ++++----- .../reference/exportsAndImports1-es6.js | 24 ++++----- .../baselines/reference/exportsAndImports1.js | 24 ++++----- .../reference/exportsAndImports2-amd.js | 8 +-- .../reference/exportsAndImports2-es6.js | 8 +-- .../baselines/reference/exportsAndImports2.js | 8 +-- .../reference/exportsAndImports3-amd.js | 24 ++++----- .../reference/exportsAndImports3-es6.js | 24 ++++----- .../baselines/reference/exportsAndImports3.js | 24 ++++----- .../reference/exportsAndImports4-amd.js | 4 +- .../reference/exportsAndImports4-es6.js | 4 +- .../baselines/reference/exportsAndImports4.js | 4 +- .../reference/inlineJsxFactoryDeclarations.js | 7 ++- .../isolatedModulesImportExportElision.js | 2 +- .../reference/isolatedModulesReExportType.js | 2 +- .../reference/moduleResolutionWithSymlinks.js | 2 +- ...moduleResolutionWithSymlinks_withOutDir.js | 2 +- ...duleSameValueDuplicateExportedBindings1.js | 14 +++++- ...duleSameValueDuplicateExportedBindings2.js | 9 +++- ...thMappingBasedModuleResolution6_classic.js | 2 +- .../pathMappingBasedModuleResolution6_node.js | 2 +- .../reexportWrittenCorrectlyInDeclaration.js | 4 +- .../symbolLinkDeclarationEmitModuleNames.js | 7 ++- ...msCorrectly.transformAddCommentToImport.js | 13 +++-- ...-transitive-module-with-isolatedModules.js | 2 +- .../inferred-type-from-transitive-module.js | 2 +- .../reference/unclosedExportClause01.js | 14 +++--- 51 files changed, 303 insertions(+), 172 deletions(-) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 9726c6402e168..49d72b4a2b15e 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -998,8 +998,8 @@ namespace ts { setOriginalNode( setTextRange( createExpressionStatement( - createExportExpression(getExportName(specifier), exportedValue) - ), + createExportExpression(getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true) + ), specifier), specifier ) @@ -1310,7 +1310,7 @@ namespace ts { case SyntaxKind.NamedImports: for (const importBinding of namedBindings.elements) { - statements = appendExportsOfDeclaration(statements, importBinding); + statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); } break; @@ -1420,12 +1420,12 @@ namespace ts { * appended. * @param decl The declaration to export. */ - function appendExportsOfDeclaration(statements: Statement[] | undefined, decl: Declaration): Statement[] | undefined { + function appendExportsOfDeclaration(statements: Statement[] | undefined, decl: Declaration, liveBinding?: boolean): Statement[] | undefined { const name = getDeclarationName(decl); const exportSpecifiers = currentModuleInfo.exportSpecifiers.get(idText(name)); if (exportSpecifiers) { for (const exportSpecifier of exportSpecifiers) { - statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name); + statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name, /* allowComments */ undefined, liveBinding); } } return statements; @@ -1443,8 +1443,8 @@ namespace ts { * @param location The location to use for source maps and comments for the export. * @param allowComments Whether to allow comments on the export. */ - function appendExportStatement(statements: Statement[] | undefined, exportName: Identifier, expression: Expression, location?: TextRange, allowComments?: boolean): Statement[] | undefined { - statements = append(statements, createExportStatement(exportName, expression, location, allowComments)); + function appendExportStatement(statements: Statement[] | undefined, exportName: Identifier, expression: Expression, location?: TextRange, allowComments?: boolean, liveBinding?: boolean): Statement[] | undefined { + statements = append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding)); return statements; } @@ -1485,8 +1485,8 @@ namespace ts { * @param location The location to use for source maps and comments for the export. * @param allowComments An optional value indicating whether to emit comments for the statement. */ - function createExportStatement(name: Identifier, value: Expression, location?: TextRange, allowComments?: boolean) { - const statement = setTextRange(createExpressionStatement(createExportExpression(name, value)), location); + function createExportStatement(name: Identifier, value: Expression, location?: TextRange, allowComments?: boolean, liveBinding?: boolean) { + const statement = setTextRange(createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location); startOnNewLine(statement); if (!allowComments) { setEmitFlags(statement, EmitFlags.NoComments); @@ -1502,9 +1502,30 @@ namespace ts { * @param value The exported value. * @param location The location to use for source maps and comments for the export. */ - function createExportExpression(name: Identifier, value: Expression, location?: TextRange) { + function createExportExpression(name: Identifier, value: Expression, location?: TextRange, liveBinding?: boolean) { return setTextRange( - createAssignment( + liveBinding ? createCall( + createPropertyAccess( + createIdentifier("Object"), + "defineProperty" + ), + /*typeArguments*/ undefined, + [ + createIdentifier("exports"), + createLiteral(name), + createObjectLiteral([ + createPropertyAssignment("enumerable", createLiteral(/*value*/ true)), + createPropertyAssignment("get", createArrowFunction( + /*modifiers*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ [], + /*type*/ undefined, + /*equalsGreaterThanToken*/ undefined, + value + )) + ]) + ] + ) : createAssignment( createPropertyAccess( createIdentifier("exports"), getSynthesizedClone(name) @@ -1786,7 +1807,12 @@ namespace ts { scoped: true, text: ` function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); }` }; diff --git a/tests/baselines/reference/ambientShorthand_reExport.js b/tests/baselines/reference/ambientShorthand_reExport.js index 6842d0f75541f..aed1f10c81cce 100644 --- a/tests/baselines/reference/ambientShorthand_reExport.js +++ b/tests/baselines/reference/ambientShorthand_reExport.js @@ -20,11 +20,16 @@ x($); "use strict"; exports.__esModule = true; var jquery_1 = require("jquery"); -exports.x = jquery_1.x; +Object.defineProperty(exports, "x", { enumerable: true, get: () => jquery_1.x }); //// [reExportAll.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } exports.__esModule = true; __export(require("jquery")); diff --git a/tests/baselines/reference/commentsOnRequireStatement.js b/tests/baselines/reference/commentsOnRequireStatement.js index 2a39206ecf3c0..0511285b2d2f2 100644 --- a/tests/baselines/reference/commentsOnRequireStatement.js +++ b/tests/baselines/reference/commentsOnRequireStatement.js @@ -32,7 +32,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); // blah // blah var _0_1 = require("./0"); -exports.subject = _0_1.subject; +Object.defineProperty(exports, "subject", { enumerable: true, get: () => _0_1.subject }); /* blah1 */ var _1_1 = require("./1"); -exports.subject1 = _1_1.subject1; +Object.defineProperty(exports, "subject1", { enumerable: true, get: () => _1_1.subject1 }); diff --git a/tests/baselines/reference/constEnumPreserveEmitReexport.js b/tests/baselines/reference/constEnumPreserveEmitReexport.js index 24914ee899b0d..5c0af98f75552 100644 --- a/tests/baselines/reference/constEnumPreserveEmitReexport.js +++ b/tests/baselines/reference/constEnumPreserveEmitReexport.js @@ -29,4 +29,4 @@ exports["default"] = ConstEnum_1.MyConstEnum; "use strict"; exports.__esModule = true; var ConstEnum_1 = require("./ConstEnum"); -exports["default"] = ConstEnum_1.MyConstEnum; +Object.defineProperty(exports, "default", { enumerable: true, get: () => ConstEnum_1.MyConstEnum }); diff --git a/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.js b/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.js index 0edf3b6f01bae..c6e3c07002d26 100644 --- a/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.js +++ b/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.js @@ -52,7 +52,7 @@ Example.Foo = foo_1.Foo; "use strict"; exports.__esModule = true; var foo_1 = require("./foo"); -exports.Foo = foo_1.Foo; +Object.defineProperty(exports, "Foo", { enumerable: true, get: () => foo_1.Foo }); function Example() { } exports["default"] = Example; Example.Foo = foo_1.Foo; diff --git a/tests/baselines/reference/declarationEmitExportDeclaration.js b/tests/baselines/reference/declarationEmitExportDeclaration.js index 1cde34aeba0d2..b1d7f9aab3781 100644 --- a/tests/baselines/reference/declarationEmitExportDeclaration.js +++ b/tests/baselines/reference/declarationEmitExportDeclaration.js @@ -23,7 +23,7 @@ exports.bar = bar; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = require("./utils"); -exports.bar = utils_1.bar; +Object.defineProperty(exports, "bar", { enumerable: true, get: () => utils_1.bar }); utils_1.foo(); var obj; diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference.js b/tests/baselines/reference/declarationEmitReexportedSymlinkReference.js index 0683f21cd575a..7df9712f85172 100644 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference.js +++ b/tests/baselines/reference/declarationEmitReexportedSymlinkReference.js @@ -51,7 +51,12 @@ exports.ADMIN = pkg2_1.MetadataAccessor.create('1'); //// [index.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./keys")); diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js b/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js index 5403cb95effe5..b88d7273fe678 100644 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js +++ b/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js @@ -54,7 +54,12 @@ exports.ADMIN = pkg2_1.MetadataAccessor.create('1'); //// [index.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./keys")); diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js b/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js index 2ac5a9fffbd0c..ad6502bf48bf4 100644 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js +++ b/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js @@ -51,7 +51,12 @@ exports.ADMIN = pkg2_1.MetadataAccessor.create('1'); //// [index.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./keys")); diff --git a/tests/baselines/reference/declarationMapsMultifile.js b/tests/baselines/reference/declarationMapsMultifile.js index ee86a044f9d71..7df1b99de543e 100644 --- a/tests/baselines/reference/declarationMapsMultifile.js +++ b/tests/baselines/reference/declarationMapsMultifile.js @@ -38,7 +38,7 @@ exports.Foo = Foo; "use strict"; exports.__esModule = true; var a_1 = require("./a"); -exports.Foo = a_1.Foo; +Object.defineProperty(exports, "Foo", { enumerable: true, get: () => a_1.Foo }); var c = new a_1.Foo(); exports.c = c; c.doThing({ a: 42 }); diff --git a/tests/baselines/reference/declarationMapsOutFile.js b/tests/baselines/reference/declarationMapsOutFile.js index def1f470a72bc..e15aab25becb7 100644 --- a/tests/baselines/reference/declarationMapsOutFile.js +++ b/tests/baselines/reference/declarationMapsOutFile.js @@ -39,7 +39,7 @@ define("a", ["require", "exports"], function (require, exports) { define("index", ["require", "exports", "a"], function (require, exports, a_1) { "use strict"; exports.__esModule = true; - exports.Foo = a_1.Foo; + Object.defineProperty(exports, "Foo", { enumerable: true, get: () => a_1.Foo }); var c = new a_1.Foo(); exports.c = c; c.doThing({ a: 42 }); diff --git a/tests/baselines/reference/destructuredDeclarationEmit.js b/tests/baselines/reference/destructuredDeclarationEmit.js index d41976525819e..960317a33355f 100644 --- a/tests/baselines/reference/destructuredDeclarationEmit.js +++ b/tests/baselines/reference/destructuredDeclarationEmit.js @@ -33,8 +33,8 @@ exports.arr = arr; "use strict"; exports.__esModule = true; var foo_1 = require("./foo"); -exports.foo = foo_1.foo; -exports.arr = foo_1.arr; +Object.defineProperty(exports, "foo", { enumerable: true, get: () => foo_1.foo }); +Object.defineProperty(exports, "arr", { enumerable: true, get: () => foo_1.arr }); var baz = foo_1.foo.bar, bat = foo_1.foo.bat, _a = foo_1.foo.bam.bork, ibar = _a.bar, ibaz = _a.baz; exports.baz = baz; exports.ibaz = ibaz; diff --git a/tests/baselines/reference/doubleUnderscoreExportStarConflict.js b/tests/baselines/reference/doubleUnderscoreExportStarConflict.js index e73c586852575..bf281f94f3441 100644 --- a/tests/baselines/reference/doubleUnderscoreExportStarConflict.js +++ b/tests/baselines/reference/doubleUnderscoreExportStarConflict.js @@ -24,7 +24,12 @@ exports.__foo = __foo; //// [index.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } exports.__esModule = true; __export(require("./b")); diff --git a/tests/baselines/reference/es6ExportAllInEs5.js b/tests/baselines/reference/es6ExportAllInEs5.js index ee949682f625d..c1bb72c57cd6f 100644 --- a/tests/baselines/reference/es6ExportAllInEs5.js +++ b/tests/baselines/reference/es6ExportAllInEs5.js @@ -32,7 +32,12 @@ exports.x = 10; //// [client.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./server")); diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js index 00e5f73f0fdde..6449364894ab6 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js @@ -37,13 +37,13 @@ exports.x = 10; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var server_1 = require("./server"); -exports.c = server_1.c; +Object.defineProperty(exports, "c", { enumerable: true, get: () => server_1.c }); var server_2 = require("./server"); -exports.c2 = server_2.c; +Object.defineProperty(exports, "c2", { enumerable: true, get: () => server_2.c }); var server_3 = require("./server"); -exports.instantiatedModule = server_3.m; +Object.defineProperty(exports, "instantiatedModule", { enumerable: true, get: () => server_3.m }); var server_4 = require("./server"); -exports.x = server_4.x; +Object.defineProperty(exports, "x", { enumerable: true, get: () => server_4.x }); //// [server.d.ts] diff --git a/tests/baselines/reference/es6ExportEqualsInterop.js b/tests/baselines/reference/es6ExportEqualsInterop.js index 13908a29e2d6b..1651191298620 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.js +++ b/tests/baselines/reference/es6ExportEqualsInterop.js @@ -210,7 +210,12 @@ export * from "class-module"; "use strict"; /// function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } exports.__esModule = true; var z2 = require("variable"); @@ -274,25 +279,25 @@ class_1.a; class_module_1.a; // named export var interface_2 = require("interface"); -exports.a1 = interface_2.a; +Object.defineProperty(exports, "a1", { enumerable: true, get: () => interface_2.a }); var variable_2 = require("variable"); -exports.a2 = variable_2.a; +Object.defineProperty(exports, "a2", { enumerable: true, get: () => variable_2.a }); var interface_variable_2 = require("interface-variable"); -exports.a3 = interface_variable_2.a; +Object.defineProperty(exports, "a3", { enumerable: true, get: () => interface_variable_2.a }); var module_2 = require("module"); -exports.a4 = module_2.a; +Object.defineProperty(exports, "a4", { enumerable: true, get: () => module_2.a }); var interface_module_2 = require("interface-module"); -exports.a5 = interface_module_2.a; +Object.defineProperty(exports, "a5", { enumerable: true, get: () => interface_module_2.a }); var variable_module_2 = require("variable-module"); -exports.a6 = variable_module_2.a; +Object.defineProperty(exports, "a6", { enumerable: true, get: () => variable_module_2.a }); var function_2 = require("function"); -exports.a7 = function_2.a; +Object.defineProperty(exports, "a7", { enumerable: true, get: () => function_2.a }); var function_module_2 = require("function-module"); -exports.a8 = function_module_2.a; +Object.defineProperty(exports, "a8", { enumerable: true, get: () => function_module_2.a }); var class_2 = require("class"); -exports.a9 = class_2.a; +Object.defineProperty(exports, "a9", { enumerable: true, get: () => class_2.a }); var class_module_2 = require("class-module"); -exports.a0 = class_module_2.a; +Object.defineProperty(exports, "a0", { enumerable: true, get: () => class_module_2.a }); __export(require("variable")); __export(require("interface-variable")); __export(require("module")); diff --git a/tests/baselines/reference/esModuleInteropTslibHelpers.js b/tests/baselines/reference/esModuleInteropTslibHelpers.js index a844bd40cfbb5..95377b83bd829 100644 --- a/tests/baselines/reference/esModuleInteropTslibHelpers.js +++ b/tests/baselines/reference/esModuleInteropTslibHelpers.js @@ -60,5 +60,5 @@ exports.Foo3 = Foo3; exports.__esModule = true; var tslib_1 = require("tslib"); var path_1 = tslib_1.__importStar(require("path")); -exports.Bar = path_1.Bar; +Object.defineProperty(exports, "Bar", { enumerable: true, get: () => path_1.Bar }); path_1["default"]("", "../"); diff --git a/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.js b/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.js index c9c681ac40b3d..9a01cc7e1993e 100644 --- a/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.js +++ b/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.js @@ -27,7 +27,7 @@ exports.x = "x"; "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -exports.x = t1_1.x; +Object.defineProperty(exports, "x", { enumerable: true, get: () => t1_1.x }); //// [t3.js] "use strict"; exports.__esModule = true; @@ -35,9 +35,9 @@ exports.__esModule = true; "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -exports.a = t1_1.x; +Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.x }); //// [t5.js] "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -exports.a = t1_1.x; +Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.x }); diff --git a/tests/baselines/reference/exportStar-amd.js b/tests/baselines/reference/exportStar-amd.js index 7658c470e5574..94bf8f378be18 100644 --- a/tests/baselines/reference/exportStar-amd.js +++ b/tests/baselines/reference/exportStar-amd.js @@ -58,7 +58,12 @@ define(["require", "exports"], function (require, exports) { define(["require", "exports", "./t1", "./t2", "./t3"], function (require, exports, t1_1, t2_1, t3_1) { "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } Object.defineProperty(exports, "__esModule", { value: true }); __export(t1_1); diff --git a/tests/baselines/reference/exportStar.js b/tests/baselines/reference/exportStar.js index 36818f8ae9b76..aeb9723e99edc 100644 --- a/tests/baselines/reference/exportStar.js +++ b/tests/baselines/reference/exportStar.js @@ -51,7 +51,12 @@ exports.z = z; //// [t4.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./t1")); diff --git a/tests/baselines/reference/exportStarForValues7.js b/tests/baselines/reference/exportStarForValues7.js index af213d1308028..7e34ee1514574 100644 --- a/tests/baselines/reference/exportStarForValues7.js +++ b/tests/baselines/reference/exportStarForValues7.js @@ -26,7 +26,12 @@ define(["require", "exports"], function (require, exports) { define(["require", "exports", "file2"], function (require, exports, file2_1) { "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } exports.__esModule = true; __export(file2_1); diff --git a/tests/baselines/reference/exportStarForValues8.js b/tests/baselines/reference/exportStarForValues8.js index 7a0045c22cb23..b8c09a166b1aa 100644 --- a/tests/baselines/reference/exportStarForValues8.js +++ b/tests/baselines/reference/exportStarForValues8.js @@ -44,7 +44,12 @@ define(["require", "exports"], function (require, exports) { define(["require", "exports", "file2", "file3"], function (require, exports, file2_1, file3_1) { "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } exports.__esModule = true; __export(file2_1); @@ -55,7 +60,12 @@ define(["require", "exports", "file2", "file3"], function (require, exports, fil define(["require", "exports", "file4"], function (require, exports, file4_1) { "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } exports.__esModule = true; __export(file4_1); diff --git a/tests/baselines/reference/exportStarForValues9.js b/tests/baselines/reference/exportStarForValues9.js index 8eb92c05e741f..678c12e5c47ad 100644 --- a/tests/baselines/reference/exportStarForValues9.js +++ b/tests/baselines/reference/exportStarForValues9.js @@ -24,7 +24,12 @@ define(["require", "exports"], function (require, exports) { define(["require", "exports", "file2"], function (require, exports, file2_1) { "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } exports.__esModule = true; __export(file2_1); @@ -34,7 +39,12 @@ define(["require", "exports", "file2"], function (require, exports, file2_1) { define(["require", "exports", "file3"], function (require, exports, file3_1) { "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } exports.__esModule = true; __export(file3_1); diff --git a/tests/baselines/reference/exportStarFromEmptyModule.js b/tests/baselines/reference/exportStarFromEmptyModule.js index be7de642a6a6e..2d839e8080643 100644 --- a/tests/baselines/reference/exportStarFromEmptyModule.js +++ b/tests/baselines/reference/exportStarFromEmptyModule.js @@ -36,7 +36,12 @@ exports.A = A; //// [exportStarFromEmptyModule_module3.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./exportStarFromEmptyModule_module2")); diff --git a/tests/baselines/reference/exportsAndImports1-amd.js b/tests/baselines/reference/exportsAndImports1-amd.js index f93abb906d2a7..4aa365a185691 100644 --- a/tests/baselines/reference/exportsAndImports1-amd.js +++ b/tests/baselines/reference/exportsAndImports1-amd.js @@ -65,21 +65,21 @@ define(["require", "exports"], function (require, exports) { define(["require", "exports", "./t1"], function (require, exports, t1_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.v = t1_1.v; - exports.f = t1_1.f; - exports.C = t1_1.C; - exports.E = t1_1.E; - exports.M = t1_1.M; - exports.a = t1_1.a; + Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v }); + Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f }); + Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C }); + Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E }); + Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M }); + Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a }); }); //// [t3.js] define(["require", "exports", "./t1"], function (require, exports, t1_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.v = t1_1.v; - exports.f = t1_1.f; - exports.C = t1_1.C; - exports.E = t1_1.E; - exports.M = t1_1.M; - exports.a = t1_1.a; + Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v }); + Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f }); + Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C }); + Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E }); + Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M }); + Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a }); }); diff --git a/tests/baselines/reference/exportsAndImports1-es6.js b/tests/baselines/reference/exportsAndImports1-es6.js index 71e8de6f9faa0..2fb1fa197d7d6 100644 --- a/tests/baselines/reference/exportsAndImports1-es6.js +++ b/tests/baselines/reference/exportsAndImports1-es6.js @@ -60,19 +60,19 @@ exports.a = a; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var t1_1 = require("./t1"); -exports.v = t1_1.v; -exports.f = t1_1.f; -exports.C = t1_1.C; -exports.E = t1_1.E; -exports.M = t1_1.M; -exports.a = t1_1.a; +Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v }); +Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f }); +Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C }); +Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E }); +Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M }); +Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a }); //// [t3.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const t1_1 = require("./t1"); -exports.v = t1_1.v; -exports.f = t1_1.f; -exports.C = t1_1.C; -exports.E = t1_1.E; -exports.M = t1_1.M; -exports.a = t1_1.a; +Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v }); +Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f }); +Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C }); +Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E }); +Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M }); +Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a }); diff --git a/tests/baselines/reference/exportsAndImports1.js b/tests/baselines/reference/exportsAndImports1.js index 156a7bd1152a2..6fce22937fda6 100644 --- a/tests/baselines/reference/exportsAndImports1.js +++ b/tests/baselines/reference/exportsAndImports1.js @@ -63,19 +63,19 @@ exports.a = a; "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -exports.v = t1_1.v; -exports.f = t1_1.f; -exports.C = t1_1.C; -exports.E = t1_1.E; -exports.M = t1_1.M; -exports.a = t1_1.a; +Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v }); +Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f }); +Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C }); +Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E }); +Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M }); +Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a }); //// [t3.js] "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -exports.v = t1_1.v; -exports.f = t1_1.f; -exports.C = t1_1.C; -exports.E = t1_1.E; -exports.M = t1_1.M; -exports.a = t1_1.a; +Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v }); +Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f }); +Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C }); +Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E }); +Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M }); +Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a }); diff --git a/tests/baselines/reference/exportsAndImports2-amd.js b/tests/baselines/reference/exportsAndImports2-amd.js index 04685dcaa332a..17c51eced3671 100644 --- a/tests/baselines/reference/exportsAndImports2-amd.js +++ b/tests/baselines/reference/exportsAndImports2-amd.js @@ -23,13 +23,13 @@ define(["require", "exports"], function (require, exports) { define(["require", "exports", "./t1"], function (require, exports, t1_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.y = t1_1.x; - exports.x = t1_1.y; + Object.defineProperty(exports, "y", { enumerable: true, get: () => t1_1.x }); + Object.defineProperty(exports, "x", { enumerable: true, get: () => t1_1.y }); }); //// [t3.js] define(["require", "exports", "./t1"], function (require, exports, t1_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.y = t1_1.x; - exports.x = t1_1.y; + Object.defineProperty(exports, "y", { enumerable: true, get: () => t1_1.x }); + Object.defineProperty(exports, "x", { enumerable: true, get: () => t1_1.y }); }); diff --git a/tests/baselines/reference/exportsAndImports2-es6.js b/tests/baselines/reference/exportsAndImports2-es6.js index 2a57a43f1a5ff..fed2b3712cdfa 100644 --- a/tests/baselines/reference/exportsAndImports2-es6.js +++ b/tests/baselines/reference/exportsAndImports2-es6.js @@ -21,11 +21,11 @@ exports.y = "y"; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var t1_1 = require("./t1"); -exports.y = t1_1.x; -exports.x = t1_1.y; +Object.defineProperty(exports, "y", { enumerable: true, get: () => t1_1.x }); +Object.defineProperty(exports, "x", { enumerable: true, get: () => t1_1.y }); //// [t3.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const t1_1 = require("./t1"); -exports.y = t1_1.x; -exports.x = t1_1.y; +Object.defineProperty(exports, "y", { enumerable: true, get: () => t1_1.x }); +Object.defineProperty(exports, "x", { enumerable: true, get: () => t1_1.y }); diff --git a/tests/baselines/reference/exportsAndImports2.js b/tests/baselines/reference/exportsAndImports2.js index d905ab3827fc5..cda0a3a9e74d7 100644 --- a/tests/baselines/reference/exportsAndImports2.js +++ b/tests/baselines/reference/exportsAndImports2.js @@ -21,11 +21,11 @@ exports.y = "y"; "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -exports.y = t1_1.x; -exports.x = t1_1.y; +Object.defineProperty(exports, "y", { enumerable: true, get: () => t1_1.x }); +Object.defineProperty(exports, "x", { enumerable: true, get: () => t1_1.y }); //// [t3.js] "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -exports.y = t1_1.x; -exports.x = t1_1.y; +Object.defineProperty(exports, "y", { enumerable: true, get: () => t1_1.x }); +Object.defineProperty(exports, "x", { enumerable: true, get: () => t1_1.y }); diff --git a/tests/baselines/reference/exportsAndImports3-amd.js b/tests/baselines/reference/exportsAndImports3-amd.js index 6ee327f979d8a..a31a8bd50300b 100644 --- a/tests/baselines/reference/exportsAndImports3-amd.js +++ b/tests/baselines/reference/exportsAndImports3-amd.js @@ -67,21 +67,21 @@ define(["require", "exports"], function (require, exports) { define(["require", "exports", "./t1"], function (require, exports, t1_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.v = t1_1.v1; - exports.f = t1_1.f1; - exports.C = t1_1.C1; - exports.E = t1_1.E1; - exports.M = t1_1.M1; - exports.a = t1_1.a1; + Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v1 }); + Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f1 }); + Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C1 }); + Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E1 }); + Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M1 }); + Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a1 }); }); //// [t3.js] define(["require", "exports", "./t1"], function (require, exports, t1_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.v = t1_1.v1; - exports.f = t1_1.f1; - exports.C = t1_1.C1; - exports.E = t1_1.E1; - exports.M = t1_1.M1; - exports.a = t1_1.a1; + Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v1 }); + Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f1 }); + Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C1 }); + Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E1 }); + Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M1 }); + Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a1 }); }); diff --git a/tests/baselines/reference/exportsAndImports3-es6.js b/tests/baselines/reference/exportsAndImports3-es6.js index 541223717773e..640f00ab7b9de 100644 --- a/tests/baselines/reference/exportsAndImports3-es6.js +++ b/tests/baselines/reference/exportsAndImports3-es6.js @@ -62,19 +62,19 @@ exports.a1 = exports.a; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var t1_1 = require("./t1"); -exports.v = t1_1.v1; -exports.f = t1_1.f1; -exports.C = t1_1.C1; -exports.E = t1_1.E1; -exports.M = t1_1.M1; -exports.a = t1_1.a1; +Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v1 }); +Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f1 }); +Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C1 }); +Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E1 }); +Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M1 }); +Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a1 }); //// [t3.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const t1_1 = require("./t1"); -exports.v = t1_1.v1; -exports.f = t1_1.f1; -exports.C = t1_1.C1; -exports.E = t1_1.E1; -exports.M = t1_1.M1; -exports.a = t1_1.a1; +Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v1 }); +Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f1 }); +Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C1 }); +Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E1 }); +Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M1 }); +Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a1 }); diff --git a/tests/baselines/reference/exportsAndImports3.js b/tests/baselines/reference/exportsAndImports3.js index e5a0b47639107..fc06062965b04 100644 --- a/tests/baselines/reference/exportsAndImports3.js +++ b/tests/baselines/reference/exportsAndImports3.js @@ -65,19 +65,19 @@ exports.a1 = exports.a; "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -exports.v = t1_1.v1; -exports.f = t1_1.f1; -exports.C = t1_1.C1; -exports.E = t1_1.E1; -exports.M = t1_1.M1; -exports.a = t1_1.a1; +Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v1 }); +Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f1 }); +Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C1 }); +Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E1 }); +Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M1 }); +Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a1 }); //// [t3.js] "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -exports.v = t1_1.v1; -exports.f = t1_1.f1; -exports.C = t1_1.C1; -exports.E = t1_1.E1; -exports.M = t1_1.M1; -exports.a = t1_1.a1; +Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v1 }); +Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f1 }); +Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C1 }); +Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E1 }); +Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M1 }); +Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a1 }); diff --git a/tests/baselines/reference/exportsAndImports4-amd.js b/tests/baselines/reference/exportsAndImports4-amd.js index 52a41a0a4512b..d12b1e12493ed 100644 --- a/tests/baselines/reference/exportsAndImports4-amd.js +++ b/tests/baselines/reference/exportsAndImports4-amd.js @@ -54,7 +54,7 @@ define(["require", "exports", "./t1", "./t1", "./t1", "./t1", "./t1", "./t1"], f t1_1.default; exports.c = c; c.default; - exports.d = t1_2.default; + Object.defineProperty(exports, "d", { enumerable: true, get: () => t1_2.default }); t1_2.default; var e2 = t1_3; exports.e1 = t1_3.default; @@ -62,7 +62,7 @@ define(["require", "exports", "./t1", "./t1", "./t1", "./t1", "./t1", "./t1"], f t1_3.default; e2.default; exports.f1 = t1_4.default; - exports.f2 = t1_4.default; + Object.defineProperty(exports, "f2", { enumerable: true, get: () => t1_4.default }); t1_4.default; t1_4.default; }); diff --git a/tests/baselines/reference/exportsAndImports4-es6.js b/tests/baselines/reference/exportsAndImports4-es6.js index ee35571942f6c..9106af8ffa734 100644 --- a/tests/baselines/reference/exportsAndImports4-es6.js +++ b/tests/baselines/reference/exportsAndImports4-es6.js @@ -55,7 +55,7 @@ const c = require("./t1"); exports.c = c; c.default; const t1_2 = require("./t1"); -exports.d = t1_2.default; +Object.defineProperty(exports, "d", { enumerable: true, get: () => t1_2.default }); t1_2.default; const t1_3 = require("./t1"), e2 = t1_3; exports.e1 = t1_3.default; @@ -64,6 +64,6 @@ t1_3.default; e2.default; const t1_4 = require("./t1"); exports.f1 = t1_4.default; -exports.f2 = t1_4.default; +Object.defineProperty(exports, "f2", { enumerable: true, get: () => t1_4.default }); t1_4.default; t1_4.default; diff --git a/tests/baselines/reference/exportsAndImports4.js b/tests/baselines/reference/exportsAndImports4.js index efb93eeebf62e..07c38506733dd 100644 --- a/tests/baselines/reference/exportsAndImports4.js +++ b/tests/baselines/reference/exportsAndImports4.js @@ -55,7 +55,7 @@ var c = require("./t1"); exports.c = c; c.default; var t1_2 = require("./t1"); -exports.d = t1_2.default; +Object.defineProperty(exports, "d", { enumerable: true, get: () => t1_2.default }); t1_2.default; var t1_3 = require("./t1"), e2 = t1_3; exports.e1 = t1_3.default; @@ -64,6 +64,6 @@ t1_3.default; e2.default; var t1_4 = require("./t1"); exports.f1 = t1_4.default; -exports.f2 = t1_4.default; +Object.defineProperty(exports, "f2", { enumerable: true, get: () => t1_4.default }); t1_4.default; t1_4.default; diff --git a/tests/baselines/reference/inlineJsxFactoryDeclarations.js b/tests/baselines/reference/inlineJsxFactoryDeclarations.js index 958c43af83f68..a67efd74c8d2f 100644 --- a/tests/baselines/reference/inlineJsxFactoryDeclarations.js +++ b/tests/baselines/reference/inlineJsxFactoryDeclarations.js @@ -63,7 +63,12 @@ exports.prerendered3 = renderer_1["default"].createElement("h", null); //// [index.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } exports.__esModule = true; /** @jsx dom */ diff --git a/tests/baselines/reference/isolatedModulesImportExportElision.js b/tests/baselines/reference/isolatedModulesImportExportElision.js index 1122fc12d0637..a1837ad39d6cf 100644 --- a/tests/baselines/reference/isolatedModulesImportExportElision.js +++ b/tests/baselines/reference/isolatedModulesImportExportElision.js @@ -41,5 +41,5 @@ var C = /** @class */ (function (_super) { var x = new module_1.c(); var y = ns.value; var module_3 = require("module"); -exports.c1 = module_3.c1; +Object.defineProperty(exports, "c1", { enumerable: true, get: () => module_3.c1 }); exports.z = x; diff --git a/tests/baselines/reference/isolatedModulesReExportType.js b/tests/baselines/reference/isolatedModulesReExportType.js index f057395fc3039..81c2c59eeb2a0 100644 --- a/tests/baselines/reference/isolatedModulesReExportType.js +++ b/tests/baselines/reference/isolatedModulesReExportType.js @@ -61,7 +61,7 @@ exports.C = C; exports.__esModule = true; // OK, has a value side var exportValue_1 = require("./exportValue"); -exports.C = exportValue_1.C; +Object.defineProperty(exports, "C", { enumerable: true, get: () => exportValue_1.C }); // OK, even though the namespace it exports is only types. var NS = require("./exportT"); exports.NS = NS; diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks.js b/tests/baselines/reference/moduleResolutionWithSymlinks.js index de15c90fdf1cf..901b7a99f714b 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks.js +++ b/tests/baselines/reference/moduleResolutionWithSymlinks.js @@ -54,7 +54,7 @@ exports.MyClass = MyClass; "use strict"; exports.__esModule = true; var library_a_1 = require("library-a"); -exports.MyClass2 = library_a_1.MyClass; +Object.defineProperty(exports, "MyClass2", { enumerable: true, get: () => library_a_1.MyClass }); //// [/src/app.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.js b/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.js index 0b7fa8fb41656..3c4d43b40cf6d 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.js +++ b/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.js @@ -33,7 +33,7 @@ exports.MyClass = MyClass; "use strict"; exports.__esModule = true; var library_a_1 = require("library-a"); -exports.MyClass2 = library_a_1.MyClass; +Object.defineProperty(exports, "MyClass2", { enumerable: true, get: () => library_a_1.MyClass }); //// [/src/bin/app.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js index c4d451ba9f9d3..7b8af14040b06 100644 --- a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js @@ -17,14 +17,24 @@ exports.foo = 42; //// [b.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } exports.__esModule = true; __export(require("./c")); //// [a.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } exports.__esModule = true; __export(require("./b")); diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js index d1f6dc7abc7cf..6e135b6817daf 100644 --- a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js @@ -26,11 +26,16 @@ var Animals; "use strict"; exports.__esModule = true; var c_1 = require("./c"); -exports.Animals = c_1.Animals; +Object.defineProperty(exports, "Animals", { enumerable: true, get: () => c_1.Animals }); //// [a.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } exports.__esModule = true; __export(require("./b")); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.js b/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.js index 3289efd02095f..b29938d14c58a 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.js @@ -15,7 +15,7 @@ export {x} from "../file2"; define(["require", "exports", "../file2"], function (require, exports, file2_1) { "use strict"; exports.__esModule = true; - exports.x = file2_1.x; + Object.defineProperty(exports, "x", { enumerable: true, get: () => file2_1.x }); }); //// [file1.js] define(["require", "exports", "./project/file3"], function (require, exports, file3_1) { diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution6_node.js b/tests/baselines/reference/pathMappingBasedModuleResolution6_node.js index 74c0f40758abc..590151ae6608d 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution6_node.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution6_node.js @@ -15,7 +15,7 @@ export {x} from "../file2"; "use strict"; exports.__esModule = true; var file2_1 = require("../file2"); -exports.x = file2_1.x; +Object.defineProperty(exports, "x", { enumerable: true, get: () => file2_1.x }); //// [file1.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.js b/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.js index ae3ce21ff4924..da012c8a3c8e5 100644 --- a/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.js +++ b/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.js @@ -41,9 +41,9 @@ exports.ThingB = ThingB; "use strict"; exports.__esModule = true; var ThingA_1 = require("./ThingA"); -exports.ThingA = ThingA_1.ThingA; +Object.defineProperty(exports, "ThingA", { enumerable: true, get: () => ThingA_1.ThingA }); var ThingB_1 = require("./ThingB"); -exports.ThingB = ThingB_1.ThingB; +Object.defineProperty(exports, "ThingB", { enumerable: true, get: () => ThingB_1.ThingB }); //// [Test.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js b/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js index 8cf2fab6fb4b5..bb4b203b4253e 100644 --- a/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js +++ b/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js @@ -42,7 +42,12 @@ exports.BindingKey = BindingKey; //// [index.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } exports.__esModule = true; __export(require("./src/bindingkey")); diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.transformAddCommentToImport.js b/tests/baselines/reference/transformApi/transformsCorrectly.transformAddCommentToImport.js index de19b854d20a7..4ce97f24b4943 100644 --- a/tests/baselines/reference/transformApi/transformsCorrectly.transformAddCommentToImport.js +++ b/tests/baselines/reference/transformApi/transformsCorrectly.transformAddCommentToImport.js @@ -1,16 +1,21 @@ "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); } Object.defineProperty(exports, "__esModule", { value: true }); /*comment*/ var somewhere_1 = require("somewhere"); -exports.Value = somewhere_1.Value; +Object.defineProperty(exports, "Value", { enumerable: true, get: () => somewhere_1.Value }); /*comment*/ var somewhere_2 = require("somewhere"); /*comment*/ -exports.X = somewhere_2.X; +Object.defineProperty(exports, "X", { enumerable: true, get: () => somewhere_2.X }); /*comment*/ -exports.Y = somewhere_2.Y; +Object.defineProperty(exports, "Y", { enumerable: true, get: () => somewhere_2.Y }); /*comment*/ __export(require("somewhere")); diff --git a/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-Build/inferred-type-from-transitive-module-with-isolatedModules.js b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-Build/inferred-type-from-transitive-module-with-isolatedModules.js index 568116485a416..3bf821165ada8 100644 --- a/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-Build/inferred-type-from-transitive-module-with-isolatedModules.js +++ b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-Build/inferred-type-from-transitive-module-with-isolatedModules.js @@ -61,7 +61,7 @@ export { default as bar } from './bar'; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var bar_1 = require("./bar"); -exports.bar = bar_1.default; +Object.defineProperty(exports, "bar", { enumerable: true, get: () => bar_1.default }); //// [/src/obj/tsconfig.tsbuildinfo] diff --git a/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-Build/inferred-type-from-transitive-module.js b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-Build/inferred-type-from-transitive-module.js index a04669bd97159..29d385cb96d45 100644 --- a/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-Build/inferred-type-from-transitive-module.js +++ b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-Build/inferred-type-from-transitive-module.js @@ -61,7 +61,7 @@ export { default as bar } from './bar'; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var bar_1 = require("./bar"); -exports.bar = bar_1.default; +Object.defineProperty(exports, "bar", { enumerable: true, get: () => bar_1.default }); //// [/src/obj/tsconfig.tsbuildinfo] diff --git a/tests/baselines/reference/unclosedExportClause01.js b/tests/baselines/reference/unclosedExportClause01.js index e391068997de1..1432f57304d27 100644 --- a/tests/baselines/reference/unclosedExportClause01.js +++ b/tests/baselines/reference/unclosedExportClause01.js @@ -23,22 +23,22 @@ exports.x = "x"; "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -exports.x = t1_1.x; -exports.from = t1_1.from; +Object.defineProperty(exports, "x", { enumerable: true, get: () => t1_1.x }); +Object.defineProperty(exports, "from", { enumerable: true, get: () => t1_1.from }); //// [t3.js] "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -exports.from = t1_1.from; +Object.defineProperty(exports, "from", { enumerable: true, get: () => t1_1.from }); //// [t4.js] "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -exports.a = t1_1.x; -exports.from = t1_1.from; +Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.x }); +Object.defineProperty(exports, "from", { enumerable: true, get: () => t1_1.from }); //// [t5.js] "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -exports.a = t1_1.x; -exports.from = t1_1.from; +Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.x }); +Object.defineProperty(exports, "from", { enumerable: true, get: () => t1_1.from }); From 27941d05b640148554dd60516144d04a2488536c Mon Sep 17 00:00:00 2001 From: Michael Rawlings Date: Wed, 25 Sep 2019 08:41:38 -1000 Subject: [PATCH 2/3] fix scoping in export* helper --- src/compiler/transformers/module/module.ts | 15 ++++++---- .../reference/ambientShorthand_reExport.js | 15 ++++++---- ...clarationEmitReexportedSymlinkReference.js | 15 ++++++---- ...larationEmitReexportedSymlinkReference2.js | 15 ++++++---- ...larationEmitReexportedSymlinkReference3.js | 15 ++++++---- .../doubleUnderscoreExportStarConflict.js | 15 ++++++---- .../baselines/reference/es6ExportAllInEs5.js | 15 ++++++---- .../reference/es6ExportEqualsInterop.js | 15 ++++++---- tests/baselines/reference/exportStar-amd.js | 15 ++++++---- tests/baselines/reference/exportStar.js | 15 ++++++---- .../reference/exportStarForValues7.js | 15 ++++++---- .../reference/exportStarForValues8.js | 30 +++++++++++-------- .../reference/exportStarForValues9.js | 30 +++++++++++-------- .../reference/exportStarFromEmptyModule.js | 15 ++++++---- .../reference/inlineJsxFactoryDeclarations.js | 15 ++++++---- ...duleSameValueDuplicateExportedBindings1.js | 30 +++++++++++-------- ...duleSameValueDuplicateExportedBindings2.js | 15 ++++++---- .../symbolLinkDeclarationEmitModuleNames.js | 15 ++++++---- ...msCorrectly.transformAddCommentToImport.js | 15 ++++++---- 19 files changed, 198 insertions(+), 132 deletions(-) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 49d72b4a2b15e..79d234e03a0e4 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -1807,12 +1807,15 @@ namespace ts { scoped: true, text: ` function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } }` }; diff --git a/tests/baselines/reference/ambientShorthand_reExport.js b/tests/baselines/reference/ambientShorthand_reExport.js index aed1f10c81cce..94fa992a67b16 100644 --- a/tests/baselines/reference/ambientShorthand_reExport.js +++ b/tests/baselines/reference/ambientShorthand_reExport.js @@ -24,12 +24,15 @@ Object.defineProperty(exports, "x", { enumerable: true, get: () => jquery_1.x }) //// [reExportAll.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } exports.__esModule = true; __export(require("jquery")); diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference.js b/tests/baselines/reference/declarationEmitReexportedSymlinkReference.js index 7df9712f85172..a6e3a59de40b4 100644 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference.js +++ b/tests/baselines/reference/declarationEmitReexportedSymlinkReference.js @@ -51,12 +51,15 @@ exports.ADMIN = pkg2_1.MetadataAccessor.create('1'); //// [index.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./keys")); diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js b/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js index b88d7273fe678..efa32f1284b81 100644 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js +++ b/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js @@ -54,12 +54,15 @@ exports.ADMIN = pkg2_1.MetadataAccessor.create('1'); //// [index.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./keys")); diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js b/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js index ad6502bf48bf4..7b9b8412e9f64 100644 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js +++ b/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js @@ -51,12 +51,15 @@ exports.ADMIN = pkg2_1.MetadataAccessor.create('1'); //// [index.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./keys")); diff --git a/tests/baselines/reference/doubleUnderscoreExportStarConflict.js b/tests/baselines/reference/doubleUnderscoreExportStarConflict.js index bf281f94f3441..1d071a6684229 100644 --- a/tests/baselines/reference/doubleUnderscoreExportStarConflict.js +++ b/tests/baselines/reference/doubleUnderscoreExportStarConflict.js @@ -24,12 +24,15 @@ exports.__foo = __foo; //// [index.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } exports.__esModule = true; __export(require("./b")); diff --git a/tests/baselines/reference/es6ExportAllInEs5.js b/tests/baselines/reference/es6ExportAllInEs5.js index c1bb72c57cd6f..b8df994dda539 100644 --- a/tests/baselines/reference/es6ExportAllInEs5.js +++ b/tests/baselines/reference/es6ExportAllInEs5.js @@ -32,12 +32,15 @@ exports.x = 10; //// [client.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./server")); diff --git a/tests/baselines/reference/es6ExportEqualsInterop.js b/tests/baselines/reference/es6ExportEqualsInterop.js index 1651191298620..f80c961cea1ec 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.js +++ b/tests/baselines/reference/es6ExportEqualsInterop.js @@ -210,12 +210,15 @@ export * from "class-module"; "use strict"; /// function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } exports.__esModule = true; var z2 = require("variable"); diff --git a/tests/baselines/reference/exportStar-amd.js b/tests/baselines/reference/exportStar-amd.js index 94bf8f378be18..be9cb59d23524 100644 --- a/tests/baselines/reference/exportStar-amd.js +++ b/tests/baselines/reference/exportStar-amd.js @@ -58,12 +58,15 @@ define(["require", "exports"], function (require, exports) { define(["require", "exports", "./t1", "./t2", "./t3"], function (require, exports, t1_1, t2_1, t3_1) { "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } Object.defineProperty(exports, "__esModule", { value: true }); __export(t1_1); diff --git a/tests/baselines/reference/exportStar.js b/tests/baselines/reference/exportStar.js index aeb9723e99edc..b9dcf17dfb666 100644 --- a/tests/baselines/reference/exportStar.js +++ b/tests/baselines/reference/exportStar.js @@ -51,12 +51,15 @@ exports.z = z; //// [t4.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./t1")); diff --git a/tests/baselines/reference/exportStarForValues7.js b/tests/baselines/reference/exportStarForValues7.js index 7e34ee1514574..6500a7c03b743 100644 --- a/tests/baselines/reference/exportStarForValues7.js +++ b/tests/baselines/reference/exportStarForValues7.js @@ -26,12 +26,15 @@ define(["require", "exports"], function (require, exports) { define(["require", "exports", "file2"], function (require, exports, file2_1) { "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } exports.__esModule = true; __export(file2_1); diff --git a/tests/baselines/reference/exportStarForValues8.js b/tests/baselines/reference/exportStarForValues8.js index b8c09a166b1aa..ad40e4a1c0fd2 100644 --- a/tests/baselines/reference/exportStarForValues8.js +++ b/tests/baselines/reference/exportStarForValues8.js @@ -44,12 +44,15 @@ define(["require", "exports"], function (require, exports) { define(["require", "exports", "file2", "file3"], function (require, exports, file2_1, file3_1) { "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } exports.__esModule = true; __export(file2_1); @@ -60,12 +63,15 @@ define(["require", "exports", "file2", "file3"], function (require, exports, fil define(["require", "exports", "file4"], function (require, exports, file4_1) { "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } exports.__esModule = true; __export(file4_1); diff --git a/tests/baselines/reference/exportStarForValues9.js b/tests/baselines/reference/exportStarForValues9.js index 678c12e5c47ad..beef678bbbbfd 100644 --- a/tests/baselines/reference/exportStarForValues9.js +++ b/tests/baselines/reference/exportStarForValues9.js @@ -24,12 +24,15 @@ define(["require", "exports"], function (require, exports) { define(["require", "exports", "file2"], function (require, exports, file2_1) { "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } exports.__esModule = true; __export(file2_1); @@ -39,12 +42,15 @@ define(["require", "exports", "file2"], function (require, exports, file2_1) { define(["require", "exports", "file3"], function (require, exports, file3_1) { "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } exports.__esModule = true; __export(file3_1); diff --git a/tests/baselines/reference/exportStarFromEmptyModule.js b/tests/baselines/reference/exportStarFromEmptyModule.js index 2d839e8080643..b6562175ca25c 100644 --- a/tests/baselines/reference/exportStarFromEmptyModule.js +++ b/tests/baselines/reference/exportStarFromEmptyModule.js @@ -36,12 +36,15 @@ exports.A = A; //// [exportStarFromEmptyModule_module3.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./exportStarFromEmptyModule_module2")); diff --git a/tests/baselines/reference/inlineJsxFactoryDeclarations.js b/tests/baselines/reference/inlineJsxFactoryDeclarations.js index a67efd74c8d2f..528c70444c809 100644 --- a/tests/baselines/reference/inlineJsxFactoryDeclarations.js +++ b/tests/baselines/reference/inlineJsxFactoryDeclarations.js @@ -63,12 +63,15 @@ exports.prerendered3 = renderer_1["default"].createElement("h", null); //// [index.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } exports.__esModule = true; /** @jsx dom */ diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js index 7b8af14040b06..3ebb8bd59ec36 100644 --- a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js @@ -17,24 +17,30 @@ exports.foo = 42; //// [b.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } exports.__esModule = true; __export(require("./c")); //// [a.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } exports.__esModule = true; __export(require("./b")); diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js index 6e135b6817daf..8bc530aa8d9d1 100644 --- a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js @@ -30,12 +30,15 @@ Object.defineProperty(exports, "Animals", { enumerable: true, get: () => c_1.Ani //// [a.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } exports.__esModule = true; __export(require("./b")); diff --git a/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js b/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js index bb4b203b4253e..4696c589feab5 100644 --- a/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js +++ b/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js @@ -42,12 +42,15 @@ exports.BindingKey = BindingKey; //// [index.js] "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } exports.__esModule = true; __export(require("./src/bindingkey")); diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.transformAddCommentToImport.js b/tests/baselines/reference/transformApi/transformsCorrectly.transformAddCommentToImport.js index 4ce97f24b4943..5b8c52928d616 100644 --- a/tests/baselines/reference/transformApi/transformsCorrectly.transformAddCommentToImport.js +++ b/tests/baselines/reference/transformApi/transformsCorrectly.transformAddCommentToImport.js @@ -1,11 +1,14 @@ "use strict"; function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + for (var p in m) b(p); + function b(p) { + if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { + enumerable: true, + get: function () { + return m[p]; + } + }); + } } Object.defineProperty(exports, "__esModule", { value: true }); /*comment*/ From 0b2cf9b71a04b3387acd052c063779e8d28b8fbb Mon Sep 17 00:00:00 2001 From: Michael Rawlings Date: Mon, 16 Dec 2019 13:27:58 -0800 Subject: [PATCH 3/3] Object.defineProperty cannot be used in ES3 target --- src/compiler/transformers/module/module.ts | 17 +++++---- .../reference/ambientShorthand_reExport.js | 17 +++++---- .../constEnumPreserveEmitReexport.js | 2 +- ...onEmitDefaultExportWithStaticAssignment.js | 2 +- ...larationEmitReexportedSymlinkReference2.js | 15 ++++---- .../reference/declarationMapsMultifile.js | 2 +- .../reference/declarationMapsOutFile.js | 2 +- .../reference/destructuredDeclarationEmit.js | 4 +-- .../doubleUnderscoreExportStarConflict.js | 15 ++++---- .../baselines/reference/es6ExportAllInEs5.js | 15 ++++---- .../reference/es6ExportEqualsInterop.js | 35 ++++++++++--------- .../reference/esModuleInteropTslibHelpers.js | 2 +- ...ationWithModuleSpecifierNameOnNextLine1.js | 6 ++-- tests/baselines/reference/exportStar-amd.js | 15 ++++---- tests/baselines/reference/exportStar.js | 15 ++++---- .../reference/exportStarForValues7.js | 15 ++++---- .../reference/exportStarForValues8.js | 30 +++++++++------- .../reference/exportStarForValues9.js | 30 +++++++++------- .../reference/exportStarFromEmptyModule.js | 15 ++++---- .../baselines/reference/exportsAndImports1.js | 24 ++++++------- .../baselines/reference/exportsAndImports2.js | 8 ++--- .../baselines/reference/exportsAndImports3.js | 24 ++++++------- .../reference/inlineJsxFactoryDeclarations.js | 15 ++++---- .../reference/isolatedModulesReExportType.js | 2 +- .../reference/moduleResolutionWithSymlinks.js | 2 +- ...moduleResolutionWithSymlinks_withOutDir.js | 2 +- ...duleSameValueDuplicateExportedBindings1.js | 30 +++++++++------- ...duleSameValueDuplicateExportedBindings2.js | 17 +++++---- ...thMappingBasedModuleResolution6_classic.js | 2 +- .../pathMappingBasedModuleResolution6_node.js | 2 +- .../reexportWrittenCorrectlyInDeclaration.js | 4 +-- .../symbolLinkDeclarationEmitModuleNames.js | 15 ++++---- .../reference/unclosedExportClause01.js | 14 ++++---- 33 files changed, 236 insertions(+), 179 deletions(-) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 79d234e03a0e4..cb7c82b14a664 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -1504,7 +1504,7 @@ namespace ts { */ function createExportExpression(name: Identifier, value: Expression, location?: TextRange, liveBinding?: boolean) { return setTextRange( - liveBinding ? createCall( + liveBinding && languageVersion !== ScriptTarget.ES3 ? createCall( createPropertyAccess( createIdentifier("Object"), "defineProperty" @@ -1809,12 +1809,15 @@ namespace ts { function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } }` }; diff --git a/tests/baselines/reference/ambientShorthand_reExport.js b/tests/baselines/reference/ambientShorthand_reExport.js index 94fa992a67b16..e32f3504fec71 100644 --- a/tests/baselines/reference/ambientShorthand_reExport.js +++ b/tests/baselines/reference/ambientShorthand_reExport.js @@ -20,18 +20,21 @@ x($); "use strict"; exports.__esModule = true; var jquery_1 = require("jquery"); -Object.defineProperty(exports, "x", { enumerable: true, get: () => jquery_1.x }); +exports.x = jquery_1.x; //// [reExportAll.js] "use strict"; function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } exports.__esModule = true; diff --git a/tests/baselines/reference/constEnumPreserveEmitReexport.js b/tests/baselines/reference/constEnumPreserveEmitReexport.js index 5c0af98f75552..24914ee899b0d 100644 --- a/tests/baselines/reference/constEnumPreserveEmitReexport.js +++ b/tests/baselines/reference/constEnumPreserveEmitReexport.js @@ -29,4 +29,4 @@ exports["default"] = ConstEnum_1.MyConstEnum; "use strict"; exports.__esModule = true; var ConstEnum_1 = require("./ConstEnum"); -Object.defineProperty(exports, "default", { enumerable: true, get: () => ConstEnum_1.MyConstEnum }); +exports["default"] = ConstEnum_1.MyConstEnum; diff --git a/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.js b/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.js index c6e3c07002d26..0edf3b6f01bae 100644 --- a/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.js +++ b/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.js @@ -52,7 +52,7 @@ Example.Foo = foo_1.Foo; "use strict"; exports.__esModule = true; var foo_1 = require("./foo"); -Object.defineProperty(exports, "Foo", { enumerable: true, get: () => foo_1.Foo }); +exports.Foo = foo_1.Foo; function Example() { } exports["default"] = Example; Example.Foo = foo_1.Foo; diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js b/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js index efa32f1284b81..787eedd3c851b 100644 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js +++ b/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js @@ -56,12 +56,15 @@ exports.ADMIN = pkg2_1.MetadataAccessor.create('1'); function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/declarationMapsMultifile.js b/tests/baselines/reference/declarationMapsMultifile.js index 7df1b99de543e..ee86a044f9d71 100644 --- a/tests/baselines/reference/declarationMapsMultifile.js +++ b/tests/baselines/reference/declarationMapsMultifile.js @@ -38,7 +38,7 @@ exports.Foo = Foo; "use strict"; exports.__esModule = true; var a_1 = require("./a"); -Object.defineProperty(exports, "Foo", { enumerable: true, get: () => a_1.Foo }); +exports.Foo = a_1.Foo; var c = new a_1.Foo(); exports.c = c; c.doThing({ a: 42 }); diff --git a/tests/baselines/reference/declarationMapsOutFile.js b/tests/baselines/reference/declarationMapsOutFile.js index e15aab25becb7..def1f470a72bc 100644 --- a/tests/baselines/reference/declarationMapsOutFile.js +++ b/tests/baselines/reference/declarationMapsOutFile.js @@ -39,7 +39,7 @@ define("a", ["require", "exports"], function (require, exports) { define("index", ["require", "exports", "a"], function (require, exports, a_1) { "use strict"; exports.__esModule = true; - Object.defineProperty(exports, "Foo", { enumerable: true, get: () => a_1.Foo }); + exports.Foo = a_1.Foo; var c = new a_1.Foo(); exports.c = c; c.doThing({ a: 42 }); diff --git a/tests/baselines/reference/destructuredDeclarationEmit.js b/tests/baselines/reference/destructuredDeclarationEmit.js index 960317a33355f..d41976525819e 100644 --- a/tests/baselines/reference/destructuredDeclarationEmit.js +++ b/tests/baselines/reference/destructuredDeclarationEmit.js @@ -33,8 +33,8 @@ exports.arr = arr; "use strict"; exports.__esModule = true; var foo_1 = require("./foo"); -Object.defineProperty(exports, "foo", { enumerable: true, get: () => foo_1.foo }); -Object.defineProperty(exports, "arr", { enumerable: true, get: () => foo_1.arr }); +exports.foo = foo_1.foo; +exports.arr = foo_1.arr; var baz = foo_1.foo.bar, bat = foo_1.foo.bat, _a = foo_1.foo.bam.bork, ibar = _a.bar, ibaz = _a.baz; exports.baz = baz; exports.ibaz = ibaz; diff --git a/tests/baselines/reference/doubleUnderscoreExportStarConflict.js b/tests/baselines/reference/doubleUnderscoreExportStarConflict.js index 1d071a6684229..2d70cfedf4ab5 100644 --- a/tests/baselines/reference/doubleUnderscoreExportStarConflict.js +++ b/tests/baselines/reference/doubleUnderscoreExportStarConflict.js @@ -26,12 +26,15 @@ exports.__foo = __foo; function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } exports.__esModule = true; diff --git a/tests/baselines/reference/es6ExportAllInEs5.js b/tests/baselines/reference/es6ExportAllInEs5.js index b8df994dda539..31e2d8bd297fa 100644 --- a/tests/baselines/reference/es6ExportAllInEs5.js +++ b/tests/baselines/reference/es6ExportAllInEs5.js @@ -34,12 +34,15 @@ exports.x = 10; function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/es6ExportEqualsInterop.js b/tests/baselines/reference/es6ExportEqualsInterop.js index f80c961cea1ec..8b147c67a1c98 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.js +++ b/tests/baselines/reference/es6ExportEqualsInterop.js @@ -212,12 +212,15 @@ export * from "class-module"; function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } exports.__esModule = true; @@ -282,25 +285,25 @@ class_1.a; class_module_1.a; // named export var interface_2 = require("interface"); -Object.defineProperty(exports, "a1", { enumerable: true, get: () => interface_2.a }); +exports.a1 = interface_2.a; var variable_2 = require("variable"); -Object.defineProperty(exports, "a2", { enumerable: true, get: () => variable_2.a }); +exports.a2 = variable_2.a; var interface_variable_2 = require("interface-variable"); -Object.defineProperty(exports, "a3", { enumerable: true, get: () => interface_variable_2.a }); +exports.a3 = interface_variable_2.a; var module_2 = require("module"); -Object.defineProperty(exports, "a4", { enumerable: true, get: () => module_2.a }); +exports.a4 = module_2.a; var interface_module_2 = require("interface-module"); -Object.defineProperty(exports, "a5", { enumerable: true, get: () => interface_module_2.a }); +exports.a5 = interface_module_2.a; var variable_module_2 = require("variable-module"); -Object.defineProperty(exports, "a6", { enumerable: true, get: () => variable_module_2.a }); +exports.a6 = variable_module_2.a; var function_2 = require("function"); -Object.defineProperty(exports, "a7", { enumerable: true, get: () => function_2.a }); +exports.a7 = function_2.a; var function_module_2 = require("function-module"); -Object.defineProperty(exports, "a8", { enumerable: true, get: () => function_module_2.a }); +exports.a8 = function_module_2.a; var class_2 = require("class"); -Object.defineProperty(exports, "a9", { enumerable: true, get: () => class_2.a }); +exports.a9 = class_2.a; var class_module_2 = require("class-module"); -Object.defineProperty(exports, "a0", { enumerable: true, get: () => class_module_2.a }); +exports.a0 = class_module_2.a; __export(require("variable")); __export(require("interface-variable")); __export(require("module")); diff --git a/tests/baselines/reference/esModuleInteropTslibHelpers.js b/tests/baselines/reference/esModuleInteropTslibHelpers.js index 95377b83bd829..a844bd40cfbb5 100644 --- a/tests/baselines/reference/esModuleInteropTslibHelpers.js +++ b/tests/baselines/reference/esModuleInteropTslibHelpers.js @@ -60,5 +60,5 @@ exports.Foo3 = Foo3; exports.__esModule = true; var tslib_1 = require("tslib"); var path_1 = tslib_1.__importStar(require("path")); -Object.defineProperty(exports, "Bar", { enumerable: true, get: () => path_1.Bar }); +exports.Bar = path_1.Bar; path_1["default"]("", "../"); diff --git a/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.js b/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.js index 9a01cc7e1993e..c9c681ac40b3d 100644 --- a/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.js +++ b/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.js @@ -27,7 +27,7 @@ exports.x = "x"; "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -Object.defineProperty(exports, "x", { enumerable: true, get: () => t1_1.x }); +exports.x = t1_1.x; //// [t3.js] "use strict"; exports.__esModule = true; @@ -35,9 +35,9 @@ exports.__esModule = true; "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.x }); +exports.a = t1_1.x; //// [t5.js] "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.x }); +exports.a = t1_1.x; diff --git a/tests/baselines/reference/exportStar-amd.js b/tests/baselines/reference/exportStar-amd.js index be9cb59d23524..85b797c104941 100644 --- a/tests/baselines/reference/exportStar-amd.js +++ b/tests/baselines/reference/exportStar-amd.js @@ -60,12 +60,15 @@ define(["require", "exports", "./t1", "./t2", "./t3"], function (require, export function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/exportStar.js b/tests/baselines/reference/exportStar.js index b9dcf17dfb666..0cf156b501019 100644 --- a/tests/baselines/reference/exportStar.js +++ b/tests/baselines/reference/exportStar.js @@ -53,12 +53,15 @@ exports.z = z; function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/exportStarForValues7.js b/tests/baselines/reference/exportStarForValues7.js index 6500a7c03b743..ae6179411a91c 100644 --- a/tests/baselines/reference/exportStarForValues7.js +++ b/tests/baselines/reference/exportStarForValues7.js @@ -28,12 +28,15 @@ define(["require", "exports", "file2"], function (require, exports, file2_1) { function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } exports.__esModule = true; diff --git a/tests/baselines/reference/exportStarForValues8.js b/tests/baselines/reference/exportStarForValues8.js index ad40e4a1c0fd2..265dddf82e27a 100644 --- a/tests/baselines/reference/exportStarForValues8.js +++ b/tests/baselines/reference/exportStarForValues8.js @@ -46,12 +46,15 @@ define(["require", "exports", "file2", "file3"], function (require, exports, fil function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } exports.__esModule = true; @@ -65,12 +68,15 @@ define(["require", "exports", "file4"], function (require, exports, file4_1) { function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } exports.__esModule = true; diff --git a/tests/baselines/reference/exportStarForValues9.js b/tests/baselines/reference/exportStarForValues9.js index beef678bbbbfd..54a7770a7046c 100644 --- a/tests/baselines/reference/exportStarForValues9.js +++ b/tests/baselines/reference/exportStarForValues9.js @@ -26,12 +26,15 @@ define(["require", "exports", "file2"], function (require, exports, file2_1) { function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } exports.__esModule = true; @@ -44,12 +47,15 @@ define(["require", "exports", "file3"], function (require, exports, file3_1) { function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } exports.__esModule = true; diff --git a/tests/baselines/reference/exportStarFromEmptyModule.js b/tests/baselines/reference/exportStarFromEmptyModule.js index b6562175ca25c..543e8cc216589 100644 --- a/tests/baselines/reference/exportStarFromEmptyModule.js +++ b/tests/baselines/reference/exportStarFromEmptyModule.js @@ -38,12 +38,15 @@ exports.A = A; function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/exportsAndImports1.js b/tests/baselines/reference/exportsAndImports1.js index 6fce22937fda6..156a7bd1152a2 100644 --- a/tests/baselines/reference/exportsAndImports1.js +++ b/tests/baselines/reference/exportsAndImports1.js @@ -63,19 +63,19 @@ exports.a = a; "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v }); -Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f }); -Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C }); -Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E }); -Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M }); -Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a }); +exports.v = t1_1.v; +exports.f = t1_1.f; +exports.C = t1_1.C; +exports.E = t1_1.E; +exports.M = t1_1.M; +exports.a = t1_1.a; //// [t3.js] "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v }); -Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f }); -Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C }); -Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E }); -Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M }); -Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a }); +exports.v = t1_1.v; +exports.f = t1_1.f; +exports.C = t1_1.C; +exports.E = t1_1.E; +exports.M = t1_1.M; +exports.a = t1_1.a; diff --git a/tests/baselines/reference/exportsAndImports2.js b/tests/baselines/reference/exportsAndImports2.js index cda0a3a9e74d7..d905ab3827fc5 100644 --- a/tests/baselines/reference/exportsAndImports2.js +++ b/tests/baselines/reference/exportsAndImports2.js @@ -21,11 +21,11 @@ exports.y = "y"; "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -Object.defineProperty(exports, "y", { enumerable: true, get: () => t1_1.x }); -Object.defineProperty(exports, "x", { enumerable: true, get: () => t1_1.y }); +exports.y = t1_1.x; +exports.x = t1_1.y; //// [t3.js] "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -Object.defineProperty(exports, "y", { enumerable: true, get: () => t1_1.x }); -Object.defineProperty(exports, "x", { enumerable: true, get: () => t1_1.y }); +exports.y = t1_1.x; +exports.x = t1_1.y; diff --git a/tests/baselines/reference/exportsAndImports3.js b/tests/baselines/reference/exportsAndImports3.js index fc06062965b04..e5a0b47639107 100644 --- a/tests/baselines/reference/exportsAndImports3.js +++ b/tests/baselines/reference/exportsAndImports3.js @@ -65,19 +65,19 @@ exports.a1 = exports.a; "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v1 }); -Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f1 }); -Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C1 }); -Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E1 }); -Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M1 }); -Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a1 }); +exports.v = t1_1.v1; +exports.f = t1_1.f1; +exports.C = t1_1.C1; +exports.E = t1_1.E1; +exports.M = t1_1.M1; +exports.a = t1_1.a1; //// [t3.js] "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -Object.defineProperty(exports, "v", { enumerable: true, get: () => t1_1.v1 }); -Object.defineProperty(exports, "f", { enumerable: true, get: () => t1_1.f1 }); -Object.defineProperty(exports, "C", { enumerable: true, get: () => t1_1.C1 }); -Object.defineProperty(exports, "E", { enumerable: true, get: () => t1_1.E1 }); -Object.defineProperty(exports, "M", { enumerable: true, get: () => t1_1.M1 }); -Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.a1 }); +exports.v = t1_1.v1; +exports.f = t1_1.f1; +exports.C = t1_1.C1; +exports.E = t1_1.E1; +exports.M = t1_1.M1; +exports.a = t1_1.a1; diff --git a/tests/baselines/reference/inlineJsxFactoryDeclarations.js b/tests/baselines/reference/inlineJsxFactoryDeclarations.js index 528c70444c809..4e4ad9c384c09 100644 --- a/tests/baselines/reference/inlineJsxFactoryDeclarations.js +++ b/tests/baselines/reference/inlineJsxFactoryDeclarations.js @@ -65,12 +65,15 @@ exports.prerendered3 = renderer_1["default"].createElement("h", null); function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } exports.__esModule = true; diff --git a/tests/baselines/reference/isolatedModulesReExportType.js b/tests/baselines/reference/isolatedModulesReExportType.js index 81c2c59eeb2a0..f057395fc3039 100644 --- a/tests/baselines/reference/isolatedModulesReExportType.js +++ b/tests/baselines/reference/isolatedModulesReExportType.js @@ -61,7 +61,7 @@ exports.C = C; exports.__esModule = true; // OK, has a value side var exportValue_1 = require("./exportValue"); -Object.defineProperty(exports, "C", { enumerable: true, get: () => exportValue_1.C }); +exports.C = exportValue_1.C; // OK, even though the namespace it exports is only types. var NS = require("./exportT"); exports.NS = NS; diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks.js b/tests/baselines/reference/moduleResolutionWithSymlinks.js index 901b7a99f714b..de15c90fdf1cf 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks.js +++ b/tests/baselines/reference/moduleResolutionWithSymlinks.js @@ -54,7 +54,7 @@ exports.MyClass = MyClass; "use strict"; exports.__esModule = true; var library_a_1 = require("library-a"); -Object.defineProperty(exports, "MyClass2", { enumerable: true, get: () => library_a_1.MyClass }); +exports.MyClass2 = library_a_1.MyClass; //// [/src/app.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.js b/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.js index 3c4d43b40cf6d..0b7fa8fb41656 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.js +++ b/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.js @@ -33,7 +33,7 @@ exports.MyClass = MyClass; "use strict"; exports.__esModule = true; var library_a_1 = require("library-a"); -Object.defineProperty(exports, "MyClass2", { enumerable: true, get: () => library_a_1.MyClass }); +exports.MyClass2 = library_a_1.MyClass; //// [/src/bin/app.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js index 3ebb8bd59ec36..0aa04849c6f0b 100644 --- a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js @@ -19,12 +19,15 @@ exports.foo = 42; function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } exports.__esModule = true; @@ -34,12 +37,15 @@ __export(require("./c")); function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } exports.__esModule = true; diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js index 8bc530aa8d9d1..3731436506313 100644 --- a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js @@ -26,18 +26,21 @@ var Animals; "use strict"; exports.__esModule = true; var c_1 = require("./c"); -Object.defineProperty(exports, "Animals", { enumerable: true, get: () => c_1.Animals }); +exports.Animals = c_1.Animals; //// [a.js] "use strict"; function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } exports.__esModule = true; diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.js b/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.js index b29938d14c58a..3289efd02095f 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.js @@ -15,7 +15,7 @@ export {x} from "../file2"; define(["require", "exports", "../file2"], function (require, exports, file2_1) { "use strict"; exports.__esModule = true; - Object.defineProperty(exports, "x", { enumerable: true, get: () => file2_1.x }); + exports.x = file2_1.x; }); //// [file1.js] define(["require", "exports", "./project/file3"], function (require, exports, file3_1) { diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution6_node.js b/tests/baselines/reference/pathMappingBasedModuleResolution6_node.js index 590151ae6608d..74c0f40758abc 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution6_node.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution6_node.js @@ -15,7 +15,7 @@ export {x} from "../file2"; "use strict"; exports.__esModule = true; var file2_1 = require("../file2"); -Object.defineProperty(exports, "x", { enumerable: true, get: () => file2_1.x }); +exports.x = file2_1.x; //// [file1.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.js b/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.js index da012c8a3c8e5..ae3ce21ff4924 100644 --- a/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.js +++ b/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.js @@ -41,9 +41,9 @@ exports.ThingB = ThingB; "use strict"; exports.__esModule = true; var ThingA_1 = require("./ThingA"); -Object.defineProperty(exports, "ThingA", { enumerable: true, get: () => ThingA_1.ThingA }); +exports.ThingA = ThingA_1.ThingA; var ThingB_1 = require("./ThingB"); -Object.defineProperty(exports, "ThingB", { enumerable: true, get: () => ThingB_1.ThingB }); +exports.ThingB = ThingB_1.ThingB; //// [Test.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js b/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js index 4696c589feab5..3d2e3ad162761 100644 --- a/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js +++ b/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js @@ -44,12 +44,15 @@ exports.BindingKey = BindingKey; function __export(m) { for (var p in m) b(p); function b(p) { - if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, { - enumerable: true, - get: function () { - return m[p]; - } - }); + if (!exports.hasOwnProperty(p)) + Object.create + ? Object.defineProperty(exports, p, { + enumerable: true, + get: function() { + return m[p]; + } + }) + : (exports[p] = m[p]); } } exports.__esModule = true; diff --git a/tests/baselines/reference/unclosedExportClause01.js b/tests/baselines/reference/unclosedExportClause01.js index 1432f57304d27..e391068997de1 100644 --- a/tests/baselines/reference/unclosedExportClause01.js +++ b/tests/baselines/reference/unclosedExportClause01.js @@ -23,22 +23,22 @@ exports.x = "x"; "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -Object.defineProperty(exports, "x", { enumerable: true, get: () => t1_1.x }); -Object.defineProperty(exports, "from", { enumerable: true, get: () => t1_1.from }); +exports.x = t1_1.x; +exports.from = t1_1.from; //// [t3.js] "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -Object.defineProperty(exports, "from", { enumerable: true, get: () => t1_1.from }); +exports.from = t1_1.from; //// [t4.js] "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.x }); -Object.defineProperty(exports, "from", { enumerable: true, get: () => t1_1.from }); +exports.a = t1_1.x; +exports.from = t1_1.from; //// [t5.js] "use strict"; exports.__esModule = true; var t1_1 = require("./t1"); -Object.defineProperty(exports, "a", { enumerable: true, get: () => t1_1.x }); -Object.defineProperty(exports, "from", { enumerable: true, get: () => t1_1.from }); +exports.a = t1_1.x; +exports.from = t1_1.from;