This commit is contained in:
Eugene Zolenko 2019-01-15 18:15:43 -07:00
parent 8dcdfb89be
commit d1082d830f
14 changed files with 31 additions and 79 deletions

View File

@ -1 +1 @@
{"version":3,"file":"check-tsconfig.d.ts","sourceRoot":"","sources":["src/check-tsconfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,wBAAgB,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAc3E"}
{"version":3,"file":"check-tsconfig.d.ts","sourceRoot":"","sources":["src/check-tsconfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,wBAAgB,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAM3E"}

View File

@ -1,6 +0,0 @@
export declare function getOptionsDefaults(): {
compilerOptions: {
module: string;
};
};
//# sourceMappingURL=get-option-defaults.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"get-option-defaults.d.ts","sourceRoot":"","sources":["src/get-option-defaults.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB;;;;EAQjC"}

View File

@ -1 +1 @@
{"version":3,"file":"get-options-overrides.d.ts","sourceRoot":"","sources":["src/get-options-overrides.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,wBAAgB,mBAAmB,CAAC,EAAE,yBAAyB,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAAE,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,eAAe,CA4B9J"}
{"version":3,"file":"get-options-overrides.d.ts","sourceRoot":"","sources":["src/get-options-overrides.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,wBAAgB,mBAAmB,CAAC,EAAE,yBAAyB,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAAE,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,eAAe,CA+B9J"}

View File

@ -1 +1 @@
{"version":3,"file":"parse-tsconfig.d.ts","sourceRoot":"","sources":["src/parse-tsconfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAKrC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKtC,wBAAgB,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CA8CnG"}
{"version":3,"file":"parse-tsconfig.d.ts","sourceRoot":"","sources":["src/parse-tsconfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAKrC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,wBAAgB,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CA8CnG"}

View File

@ -24957,38 +24957,25 @@ function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsed
allowNonTsExtensions: true,
};
if (preParsedTsconfig) {
if (preParsedTsconfig.options.module === undefined)
overrides.module = tsModule.ModuleKind.ES2015;
const declaration = preParsedTsconfig.options.declaration;
if (!declaration)
overrides.declarationDir = null;
overrides.declarationDir = undefined;
if (declaration && !useTsconfigDeclarationDir)
overrides.declarationDir = process.cwd();
// unsetting sourceRoot if sourceMap is not enabled (in case original tsconfig had inlineSourceMap set that is being unset and would cause TS5051)
const sourceMap = preParsedTsconfig.options.sourceMap;
if (!sourceMap)
overrides.sourceRoot = null;
overrides.sourceRoot = undefined;
}
return overrides;
}
function checkTsConfig(parsedConfig) {
const module = parsedConfig.options.module;
switch (module) {
case tsModule.ModuleKind.ES2015:
case tsModule.ModuleKind.ESNext:
break;
case undefined:
throw new Error(`Incompatible tsconfig option. Missing module option. This is incompatible with rollup, please use 'module: "ES2015"' or 'module: "ESNext"'.`);
default:
throw new Error(`Incompatible tsconfig option. Module resolves to '${tsModule.ModuleKind[module]}'. This is incompatible with rollup, please use 'module: "ES2015"' or 'module: "ESNext"'.`);
}
}
function getOptionsDefaults() {
return {
compilerOptions: {
module: "ES2015",
},
};
if (module !== tsModule.ModuleKind.ES2015 && module !== tsModule.ModuleKind.ESNext)
throw new Error(`Incompatible tsconfig option. Module resolves to '${tsModule.ModuleKind[module]}'. This is incompatible with rollup, please use 'module: "ES2015"' or 'module: "ESNext"'.`);
}
function parseTsConfig(context, pluginOptions) {
@ -25015,7 +25002,7 @@ function parseTsConfig(context, pluginOptions) {
configFileName = fileName;
}
const mergedConfig = {};
lodash_14(mergedConfig, getOptionsDefaults(), pluginOptions.tsconfigDefaults, loadedConfig, pluginOptions.tsconfigOverride);
lodash_14(mergedConfig, pluginOptions.tsconfigDefaults, loadedConfig, pluginOptions.tsconfigOverride);
const preParsedTsConfig = tsModule.parseJsonConfigFileContent(mergedConfig, tsModule.sys, baseDir, getOptionsOverrides(pluginOptions), configFileName);
const compilerOptionsOverride = getOptionsOverrides(pluginOptions, preParsedTsConfig);
const parsedTsConfig = tsModule.parseJsonConfigFileContent(mergedConfig, tsModule.sys, baseDir, compilerOptionsOverride, configFileName);

File diff suppressed because one or more lines are too long

View File

@ -24953,38 +24953,25 @@ function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsed
allowNonTsExtensions: true,
};
if (preParsedTsconfig) {
if (preParsedTsconfig.options.module === undefined)
overrides.module = tsModule.ModuleKind.ES2015;
const declaration = preParsedTsconfig.options.declaration;
if (!declaration)
overrides.declarationDir = null;
overrides.declarationDir = undefined;
if (declaration && !useTsconfigDeclarationDir)
overrides.declarationDir = process.cwd();
// unsetting sourceRoot if sourceMap is not enabled (in case original tsconfig had inlineSourceMap set that is being unset and would cause TS5051)
const sourceMap = preParsedTsconfig.options.sourceMap;
if (!sourceMap)
overrides.sourceRoot = null;
overrides.sourceRoot = undefined;
}
return overrides;
}
function checkTsConfig(parsedConfig) {
const module = parsedConfig.options.module;
switch (module) {
case tsModule.ModuleKind.ES2015:
case tsModule.ModuleKind.ESNext:
break;
case undefined:
throw new Error(`Incompatible tsconfig option. Missing module option. This is incompatible with rollup, please use 'module: "ES2015"' or 'module: "ESNext"'.`);
default:
throw new Error(`Incompatible tsconfig option. Module resolves to '${tsModule.ModuleKind[module]}'. This is incompatible with rollup, please use 'module: "ES2015"' or 'module: "ESNext"'.`);
}
}
function getOptionsDefaults() {
return {
compilerOptions: {
module: "ES2015",
},
};
if (module !== tsModule.ModuleKind.ES2015 && module !== tsModule.ModuleKind.ESNext)
throw new Error(`Incompatible tsconfig option. Module resolves to '${tsModule.ModuleKind[module]}'. This is incompatible with rollup, please use 'module: "ES2015"' or 'module: "ESNext"'.`);
}
function parseTsConfig(context, pluginOptions) {
@ -25011,7 +24998,7 @@ function parseTsConfig(context, pluginOptions) {
configFileName = fileName;
}
const mergedConfig = {};
lodash_14(mergedConfig, getOptionsDefaults(), pluginOptions.tsconfigDefaults, loadedConfig, pluginOptions.tsconfigOverride);
lodash_14(mergedConfig, pluginOptions.tsconfigDefaults, loadedConfig, pluginOptions.tsconfigOverride);
const preParsedTsConfig = tsModule.parseJsonConfigFileContent(mergedConfig, tsModule.sys, baseDir, getOptionsOverrides(pluginOptions), configFileName);
const compilerOptionsOverride = getOptionsOverrides(pluginOptions, preParsedTsConfig);
const parsedTsConfig = tsModule.parseJsonConfigFileContent(mergedConfig, tsModule.sys, baseDir, compilerOptionsOverride, configFileName);

File diff suppressed because one or more lines are too long

View File

@ -3,16 +3,8 @@ import * as tsTypes from "typescript";
export function checkTsConfig(parsedConfig: tsTypes.ParsedCommandLine): void
{
const module = parsedConfig.options.module;
const module = parsedConfig.options.module!;
switch (module)
{
case tsModule.ModuleKind.ES2015:
case tsModule.ModuleKind.ESNext:
break;
case undefined:
throw new Error(`Incompatible tsconfig option. Missing module option. This is incompatible with rollup, please use 'module: "ES2015"' or 'module: "ESNext"'.`);
default:
throw new Error(`Incompatible tsconfig option. Module resolves to '${tsModule.ModuleKind[module]}'. This is incompatible with rollup, please use 'module: "ES2015"' or 'module: "ESNext"'.`);
}
if (module !== tsModule.ModuleKind.ES2015 && module !== tsModule.ModuleKind.ESNext)
throw new Error(`Incompatible tsconfig option. Module resolves to '${tsModule.ModuleKind[module]}'. This is incompatible with rollup, please use 'module: "ES2015"' or 'module: "ESNext"'.`);
}

View File

@ -1,9 +0,0 @@
export function getOptionsDefaults()
{
return {
compilerOptions:
{
module: "ES2015",
},
};
}

View File

@ -5,7 +5,7 @@ import * as _ from "lodash";
export function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IOptions, preParsedTsconfig?: tsTypes.ParsedCommandLine): tsTypes.CompilerOptions
{
const overrides = {
const overrides: tsTypes.CompilerOptions = {
noEmitHelpers: false,
importHelpers: true,
noResolve: false,
@ -18,16 +18,19 @@ export function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IO
if (preParsedTsconfig)
{
if (preParsedTsconfig.options.module === undefined)
overrides.module = tsModule.ModuleKind.ES2015;
const declaration = preParsedTsconfig.options.declaration;
if (!declaration)
(overrides as any).declarationDir = null;
overrides.declarationDir = undefined;
if (declaration && !useTsconfigDeclarationDir)
(overrides as any).declarationDir = process.cwd();
overrides.declarationDir = process.cwd();
// unsetting sourceRoot if sourceMap is not enabled (in case original tsconfig had inlineSourceMap set that is being unset and would cause TS5051)
const sourceMap = preParsedTsconfig.options.sourceMap;
if (!sourceMap)
(overrides as any).sourceRoot = null;
overrides.sourceRoot = undefined;
}
return overrides;

View File

@ -8,7 +8,6 @@ import { getOptionsOverrides } from "./get-options-overrides";
import { IOptions } from "./ioptions";
import * as _ from "lodash";
import { checkTsConfig } from "./check-tsconfig";
import { getOptionsDefaults } from "./get-option-defaults";
export function parseTsConfig(context: IContext, pluginOptions: IOptions): tsTypes.ParsedCommandLine
{
@ -43,7 +42,7 @@ export function parseTsConfig(context: IContext, pluginOptions: IOptions): tsTyp
}
const mergedConfig = {};
_.merge(mergedConfig, getOptionsDefaults(), pluginOptions.tsconfigDefaults, loadedConfig, pluginOptions.tsconfigOverride);
_.merge(mergedConfig, pluginOptions.tsconfigDefaults, loadedConfig, pluginOptions.tsconfigOverride);
const preParsedTsConfig = tsModule.parseJsonConfigFileContent(mergedConfig, tsModule.sys, baseDir, getOptionsOverrides(pluginOptions), configFileName);
const compilerOptionsOverride = getOptionsOverrides(pluginOptions, preParsedTsConfig);

View File

@ -1,5 +1,5 @@
{
"extends": "./tsconfig.base",
"extends": "./tsconfig.base",
"compilerOptions": {
"target": "es6",
"noImplicitAny": true,