mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
fix esmodule big, unify export emit between es6/pre-es6
This commit is contained in:
@@ -3628,12 +3628,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// only allow export default at a source file level
|
||||
if (modulekind === ModuleKind.CommonJS || modulekind === ModuleKind.AMD || modulekind === ModuleKind.UMD) {
|
||||
if (!isEs6Module) {
|
||||
if (languageVersion === ScriptTarget.ES5) {
|
||||
if (languageVersion !== ScriptTarget.ES3) {
|
||||
// default value of configurable, enumerable, writable are `false`.
|
||||
write("Object.defineProperty(exports, \"__esModule\", { value: true });");
|
||||
writeLine();
|
||||
}
|
||||
else if (languageVersion === ScriptTarget.ES3) {
|
||||
else {
|
||||
write("exports.__esModule = true;");
|
||||
writeLine();
|
||||
}
|
||||
@@ -5171,35 +5171,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
if (!(node.flags & NodeFlags.Export)) {
|
||||
return;
|
||||
}
|
||||
// If this is an exported class, but not on the top level (i.e. on an internal
|
||||
// module), export it
|
||||
if (node.flags & NodeFlags.Default) {
|
||||
// if this is a top level default export of decorated class, write the export after the declaration.
|
||||
writeLine();
|
||||
if (thisNodeIsDecorated && modulekind === ModuleKind.ES6) {
|
||||
write("export default ");
|
||||
emitDeclarationName(node);
|
||||
write(";");
|
||||
}
|
||||
else if (modulekind === ModuleKind.System) {
|
||||
write(`${exportFunctionForFile}("default", `);
|
||||
emitDeclarationName(node);
|
||||
write(");");
|
||||
}
|
||||
else if (modulekind !== ModuleKind.ES6) {
|
||||
write(`exports.default = `);
|
||||
emitDeclarationName(node);
|
||||
write(";");
|
||||
}
|
||||
if (modulekind !== ModuleKind.ES6) {
|
||||
emitExportMemberAssignment(node as ClassDeclaration);
|
||||
}
|
||||
else if (node.parent.kind !== SyntaxKind.SourceFile || (modulekind !== ModuleKind.ES6 && !(node.flags & NodeFlags.Default))) {
|
||||
writeLine();
|
||||
emitStart(node);
|
||||
emitModuleMemberName(node);
|
||||
write(" = ");
|
||||
emitDeclarationName(node);
|
||||
emitEnd(node);
|
||||
write(";");
|
||||
else {
|
||||
// If this is an exported class, but not on the top level (i.e. on an internal
|
||||
// module), export it
|
||||
if (node.flags & NodeFlags.Default) {
|
||||
// if this is a top level default export of decorated class, write the export after the declaration.
|
||||
if (thisNodeIsDecorated) {
|
||||
writeLine();
|
||||
write("export default ");
|
||||
emitDeclarationName(node);
|
||||
write(";");
|
||||
}
|
||||
}
|
||||
else if (node.parent.kind !== SyntaxKind.SourceFile) {
|
||||
writeLine();
|
||||
emitStart(node);
|
||||
emitModuleMemberName(node);
|
||||
write(" = ");
|
||||
emitDeclarationName(node);
|
||||
emitEnd(node);
|
||||
write(";");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user