Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@ngtools/webpack): allow comments in tsconfig files #5230

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/@ngtools/webpack/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,16 @@ export class AotPlugin implements Tapable {
basePath = path.resolve(process.cwd(), options.basePath);
}

let tsConfigJson: any = null;
try {
tsConfigJson = JSON.parse(ts.sys.readFile(this._tsConfigPath));
} catch (err) {
throw new Error(`An error happened while parsing ${this._tsConfigPath} JSON: ${err}.`);
const configResult = ts.readConfigFile(this._tsConfigPath, ts.sys.readFile);
if (configResult.error) {
const diagnostic = configResult.error;
const {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
throw new Error(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message})`);
}

const tsConfigJson = configResult.config;

if (options.hasOwnProperty('compilerOptions')) {
tsConfigJson.compilerOptions = Object.assign({},
tsConfigJson.compilerOptions,
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/assets/webpack/test-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
// Test comment
"compilerOptions": {
"baseUrl": "",
"module": "es2015",
Expand Down