Fix #7922: Only bundle if module==AMD or module==System

This commit is contained in:
Mohamed Hegazy
2016-04-07 00:21:25 -07:00
parent c9c6e5ab4f
commit e592304aee
3 changed files with 4 additions and 6 deletions

View File

@@ -2285,10 +2285,12 @@ namespace ts {
}
function onBundledEmit(host: EmitHost) {
const moduleKind = getEmitModuleKind(options);
const moduleEmitEnabled = moduleKind === ModuleKind.AMD || moduleKind === ModuleKind.System;
// Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified
const bundledSources = filter(host.getSourceFiles(), sourceFile =>
!isDeclarationFile(sourceFile) // Not a declaration file
&& (!isExternalModule(sourceFile) || !!getEmitModuleKind(options))); // and not a module, unless module emit enabled
&& (!isExternalModule(sourceFile) || moduleEmitEnabled)); // and not a module, unless module emit enabled
if (bundledSources.length) {
const jsFilePath = options.outFile || options.out;

View File

@@ -23,8 +23,4 @@ declare class Foo {
x: string;
y: number;
}
declare module "inputFile3" {
export var foo: number;
export var bar: string;
}

View File

@@ -19,7 +19,7 @@ EmitSkipped: false
FileName : tests/cases/fourslash/inputFile2.js.map
{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AACA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,qBAAC,GAAG,IAAC,IAAI,EAAG,CAAE,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.js
var y = "my div";
var x = React.createElement("div", {name: y});
var x = React.createElement("div", { name: y });
//# sourceMappingURL=inputFile2.js.mapFileName : tests/cases/fourslash/inputFile2.d.ts
declare var React: any;
declare var y: string;