Skip to content

Commit

Permalink
fix(@ngtools/webpack): allow comments in tsconfig files
Browse files Browse the repository at this point in the history
Close #5216
Close #5230
  • Loading branch information
Charles Lyding authored and filipesilva committed Mar 29, 2017
1 parent 1ef8de5 commit df3847f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/@ngtools/webpack/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,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

0 comments on commit df3847f

Please sign in to comment.