Skip to content

Commit

Permalink
chore(tsconfig): parse all tsconfig data
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Jul 28, 2020
1 parent 920445a commit 26d1fed
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/compiler/config/load-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ export const loadConfig = async (init: LoadConfigInit = {}) => {
config: null,
diagnostics: [],
tsconfig: {
path: null,
compilerOptions: null,
files: null,
include: null,
exclude: null,
extends: null,
},
};

Expand Down Expand Up @@ -70,7 +75,13 @@ export const loadConfig = async (init: LoadConfigInit = {}) => {

results.config.tsconfig = tsConfigResults.path;
results.config.tsCompilerOptions = tsConfigResults.compilerOptions;
results.tsconfig.compilerOptions = tsConfigResults.compilerOptions;

results.tsconfig.path = tsConfigResults.path;
results.tsconfig.compilerOptions = JSON.parse(JSON.stringify(tsConfigResults.compilerOptions));
results.tsconfig.files = tsConfigResults.files;
results.tsconfig.include = tsConfigResults.include;
results.tsconfig.exclude = tsConfigResults.exclude;
results.tsconfig.extends = tsConfigResults.extends;
}

if (isString(init.typescriptPath)) {
Expand Down
17 changes: 17 additions & 0 deletions src/compiler/sys/typescript/typescript-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export const validateTsConfig = async (ts: typeof TypeScript, config: d.Config,
const tsconfig = {
path: null as string,
compilerOptions: null as any,
files: null as string[],
include: null as string[],
exclude: null as string[],
extends: null as string,
diagnostics: [] as d.Diagnostic[],
};

Expand Down Expand Up @@ -58,6 +62,19 @@ export const validateTsConfig = async (ts: typeof TypeScript, config: d.Config,
warn.header = `tsconfig.json should not reference stencil.config.ts`;
warn.messageText = `stencil.config.ts is not part of the output build, it should not be included.`;
}

if (Array.isArray(results.raw.files)) {
tsconfig.files = results.raw.files.slice();
}
if (Array.isArray(results.raw.include)) {
tsconfig.include = results.raw.include.slice();
}
if (Array.isArray(results.raw.exclude)) {
tsconfig.exclude = results.raw.exclude.slice();
}
if (isString(results.raw.extends)) {
tsconfig.extends = results.raw.extends;
}
}

if (results.options) {
Expand Down
5 changes: 5 additions & 0 deletions src/declarations/stencil-public-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1996,7 +1996,12 @@ export interface LoadConfigResults {
config: Config;
diagnostics: Diagnostic[];
tsconfig: {
path: string;
compilerOptions: any;
files: string[];
include: string[];
exclude: string[];
extends: string;
};
}

Expand Down

0 comments on commit 26d1fed

Please sign in to comment.