mirror of
https://github.com/ezolenko/rollup-plugin-typescript2.git
synced 2025-12-08 19:06:16 +00:00
- reporting tsconfig parsing errors
This commit is contained in:
parent
a99c6cd9c1
commit
5891f93427
10
dist/rollup-plugin-typescript2.cjs.js
vendored
10
dist/rollup-plugin-typescript2.cjs.js
vendored
@ -389,12 +389,16 @@ catch (e) {
|
||||
console.warn("Error loading `tslib` helper library.");
|
||||
throw e;
|
||||
}
|
||||
function parseTsConfig() {
|
||||
function parseTsConfig(context) {
|
||||
var fileName = findFile(process.cwd(), "tsconfig.json");
|
||||
if (!fileName)
|
||||
throw new Error("couldn't find 'tsconfig.json' in " + process.cwd());
|
||||
var text = ts.sys.readFile(fileName);
|
||||
var result = ts.parseConfigFileTextToJson(fileName, text);
|
||||
if (result.error) {
|
||||
printDiagnostics(context, convertDiagnostic([result.error]));
|
||||
throw new Error("failed to parse " + fileName);
|
||||
}
|
||||
var configParseResult = ts.parseJsonConfigFileContent(result.config, ts.sys, path.dirname(fileName), getOptionsOverrides(), fileName);
|
||||
return configParseResult;
|
||||
}
|
||||
@ -435,11 +439,11 @@ function typescript(options) {
|
||||
exclude: ["*.d.ts", "**/*.d.ts"],
|
||||
abortOnError: true,
|
||||
});
|
||||
var context = new ConsoleContext(options.verbosity, "rollup-plugin-typescript2: ");
|
||||
var filter$$1 = createFilter(options.include, options.exclude);
|
||||
var parsedConfig = parseTsConfig();
|
||||
var parsedConfig = parseTsConfig(context);
|
||||
var servicesHost = new LanguageServiceHost(parsedConfig);
|
||||
var services = ts.createLanguageService(servicesHost, ts.createDocumentRegistry());
|
||||
var context = new ConsoleContext(options.verbosity, "rollup-plugin-typescript2: ");
|
||||
var cache = new Cache(servicesHost, options.cacheRoot, parsedConfig.options, parsedConfig.fileNames, context);
|
||||
if (options.clean)
|
||||
cache.clean();
|
||||
|
||||
10
dist/rollup-plugin-typescript2.es.js
vendored
10
dist/rollup-plugin-typescript2.es.js
vendored
@ -394,12 +394,16 @@ catch (e) {
|
||||
console.warn("Error loading `tslib` helper library.");
|
||||
throw e;
|
||||
}
|
||||
function parseTsConfig() {
|
||||
function parseTsConfig(context) {
|
||||
var fileName = findFile(process.cwd(), "tsconfig.json");
|
||||
if (!fileName)
|
||||
throw new Error("couldn't find 'tsconfig.json' in " + process.cwd());
|
||||
var text = sys.readFile(fileName);
|
||||
var result = parseConfigFileTextToJson(fileName, text);
|
||||
if (result.error) {
|
||||
printDiagnostics(context, convertDiagnostic([result.error]));
|
||||
throw new Error("failed to parse " + fileName);
|
||||
}
|
||||
var configParseResult = parseJsonConfigFileContent(result.config, sys, dirname(fileName), getOptionsOverrides(), fileName);
|
||||
return configParseResult;
|
||||
}
|
||||
@ -440,11 +444,11 @@ function typescript(options) {
|
||||
exclude: ["*.d.ts", "**/*.d.ts"],
|
||||
abortOnError: true,
|
||||
});
|
||||
var context = new ConsoleContext(options.verbosity, "rollup-plugin-typescript2: ");
|
||||
var filter$$1 = createFilter(options.include, options.exclude);
|
||||
var parsedConfig = parseTsConfig();
|
||||
var parsedConfig = parseTsConfig(context);
|
||||
var servicesHost = new LanguageServiceHost(parsedConfig);
|
||||
var services = createLanguageService(servicesHost, createDocumentRegistry());
|
||||
var context = new ConsoleContext(options.verbosity, "rollup-plugin-typescript2: ");
|
||||
var cache = new Cache(servicesHost, options.cacheRoot, parsedConfig.options, parsedConfig.fileNames, context);
|
||||
if (options.clean)
|
||||
cache.clean();
|
||||
|
||||
15
src/index.ts
15
src/index.ts
@ -60,7 +60,7 @@ try
|
||||
throw e;
|
||||
}
|
||||
|
||||
function parseTsConfig()
|
||||
function parseTsConfig(context: IContext)
|
||||
{
|
||||
const fileName = findFile(process.cwd(), "tsconfig.json");
|
||||
if (!fileName)
|
||||
@ -68,6 +68,13 @@ function parseTsConfig()
|
||||
|
||||
const text = ts.sys.readFile(fileName);
|
||||
const result = ts.parseConfigFileTextToJson(fileName, text);
|
||||
|
||||
if (result.error)
|
||||
{
|
||||
printDiagnostics(context, convertDiagnostic([result.error]));
|
||||
throw new Error(`failed to parse ${fileName}`);
|
||||
}
|
||||
|
||||
const configParseResult = ts.parseJsonConfigFileContent(result.config, ts.sys, path.dirname(fileName), getOptionsOverrides(), fileName);
|
||||
|
||||
return configParseResult;
|
||||
@ -129,16 +136,16 @@ export default function typescript (options: IOptions)
|
||||
abortOnError: true,
|
||||
});
|
||||
|
||||
const context = new ConsoleContext(options.verbosity, "rollup-plugin-typescript2: ");
|
||||
|
||||
const filter = createFilter(options.include, options.exclude);
|
||||
|
||||
const parsedConfig = parseTsConfig();
|
||||
const parsedConfig = parseTsConfig(context);
|
||||
|
||||
const servicesHost = new LanguageServiceHost(parsedConfig);
|
||||
|
||||
const services = ts.createLanguageService(servicesHost, ts.createDocumentRegistry());
|
||||
|
||||
const context = new ConsoleContext(options.verbosity, "rollup-plugin-typescript2: ");
|
||||
|
||||
const cache = new Cache(servicesHost, options.cacheRoot, parsedConfig.options, parsedConfig.fileNames, context);
|
||||
|
||||
if (options.clean)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user