Merge pull request #14493 from Microsoft/master-fixEmitExtraESModuleMark
[Master] Do not emit ESModule marker if file is not external module
This commit is contained in:
commit
0425175b3a
|
@ -55,9 +55,7 @@ namespace ts {
|
||||||
* @param node The SourceFile node.
|
* @param node The SourceFile node.
|
||||||
*/
|
*/
|
||||||
function transformSourceFile(node: SourceFile) {
|
function transformSourceFile(node: SourceFile) {
|
||||||
if (isDeclarationFile(node)
|
if (isDeclarationFile(node) || !(isExternalModule(node) || compilerOptions.isolatedModules)) {
|
||||||
|| !(isExternalModule(node)
|
|
||||||
|| compilerOptions.isolatedModules)) {
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +72,14 @@ namespace ts {
|
||||||
return aggregateTransformFlags(updated);
|
return aggregateTransformFlags(updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function shouldEmitUnderscoreUnderscoreESModule() {
|
||||||
|
if (!currentModuleInfo.exportEquals && isExternalModule(currentSourceFile)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms a SourceFile into a CommonJS module.
|
* Transforms a SourceFile into a CommonJS module.
|
||||||
*
|
*
|
||||||
|
@ -85,7 +91,7 @@ namespace ts {
|
||||||
const statements: Statement[] = [];
|
const statements: Statement[] = [];
|
||||||
const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor);
|
const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor);
|
||||||
|
|
||||||
if (!currentModuleInfo.exportEquals) {
|
if (shouldEmitUnderscoreUnderscoreESModule()) {
|
||||||
append(statements, createUnderscoreUnderscoreESModule());
|
append(statements, createUnderscoreUnderscoreESModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +384,7 @@ namespace ts {
|
||||||
const statements: Statement[] = [];
|
const statements: Statement[] = [];
|
||||||
const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor);
|
const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor);
|
||||||
|
|
||||||
if (!currentModuleInfo.exportEquals) {
|
if (shouldEmitUnderscoreUnderscoreESModule()) {
|
||||||
append(statements, createUnderscoreUnderscoreESModule());
|
append(statements, createUnderscoreUnderscoreESModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,6 @@ C = tslib_1.__decorate([
|
||||||
], C);
|
], C);
|
||||||
//// [script.js]
|
//// [script.js]
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
var tslib_1 = require("tslib");
|
var tslib_1 = require("tslib");
|
||||||
var A = (function () {
|
var A = (function () {
|
||||||
function A() {
|
function A() {
|
||||||
|
|
|
@ -7,6 +7,5 @@ run(1);
|
||||||
//// [isolatedModulesPlainFile-AMD.js]
|
//// [isolatedModulesPlainFile-AMD.js]
|
||||||
define(["require", "exports"], function (require, exports) {
|
define(["require", "exports"], function (require, exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
run(1);
|
run(1);
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,5 +6,4 @@ run(1);
|
||||||
|
|
||||||
//// [isolatedModulesPlainFile-CommonJS.js]
|
//// [isolatedModulesPlainFile-CommonJS.js]
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
run(1);
|
run(1);
|
||||||
|
|
|
@ -15,6 +15,5 @@ run(1);
|
||||||
}
|
}
|
||||||
})(function (require, exports) {
|
})(function (require, exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
run(1);
|
run(1);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
//# sourceMappingURL=file.js.map
|
//# sourceMappingURL=file.js.map
|
|
@ -1,5 +1,4 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
a;
|
a;
|
||||||
b;
|
b;
|
||||||
//# sourceMappingURL=file.js.map
|
//# sourceMappingURL=file.js.map
|
|
@ -1,6 +1,5 @@
|
||||||
define(["require", "exports"], function (require, exports) {
|
define(["require", "exports"], function (require, exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=file.js.map
|
//# sourceMappingURL=file.js.map
|
|
@ -1,5 +1,4 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
/// <reference path="file2.ts" />
|
/// <reference path="file2.ts" />
|
||||||
var x = 0;
|
var x = 0;
|
||||||
//# sourceMappingURL=file.js.map
|
//# sourceMappingURL=file.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
//# sourceMappingURL=file.js.map
|
//# sourceMappingURL=file.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
//# sourceMappingURL=file.js.map
|
//# sourceMappingURL=file.js.map
|
|
@ -1,3 +1,2 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
//# sourceMappingURL=file.js.map
|
//# sourceMappingURL=file.js.map
|
|
@ -1,3 +1,2 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
//# sourceMappingURL=file.js.map
|
//# sourceMappingURL=file.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
var a = 10;
|
var a = 10;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
var a = 10;
|
var a = 10;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
var x;
|
var x;
|
||||||
//# sourceMappingURL=b.js.map
|
//# sourceMappingURL=b.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,3 +1,2 @@
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
x;
|
x;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
var x;
|
var x;
|
||||||
//# sourceMappingURL=file.js.map
|
//# sourceMappingURL=file.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
//# sourceMappingURL=file.js.map
|
//# sourceMappingURL=file.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
var a = 10;
|
var a = 10;
|
||||||
//# sourceMappingURL=input.js.map
|
//# sourceMappingURL=input.js.map
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
|
||||||
var x = React.createElement("div", null);
|
var x = React.createElement("div", null);
|
||||||
//# sourceMappingURL=file.js.map
|
//# sourceMappingURL=file.js.map
|
Loading…
Reference in a new issue