Skip to content

Commit

Permalink
feat(@ngtools/webpack): allow to pass in overrides for compilerOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva authored and Zhicheng Wang committed Mar 16, 2017
1 parent ed9fda1 commit 84a3131
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/@ngtools/webpack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ The loader works with the webpack plugin to compile your TypeScript. It's import
* `mainPath`. Optional if `entryModule` is specified. The `main.ts` file containing the bootstrap code. The plugin will use AST to determine the `entryModule`.
* `skipCodeGeneration`. Optional, defaults to false. Disable code generation and do not refactor the code to bootstrap. This replaces `templateUrl: "string"` with `template: require("string")` (and similar for styles) to allow for webpack to properly link the resources.
* `typeChecking`. Optional, defaults to true. Enable type checking through your application. This will slow down compilation, but show syntactic and semantic errors in webpack.
* `exclude`. Optional. Extra files to exclude from TypeScript compilation.
* `compilerOptions`. Optional. Override options in `tsconfig.json`.

## Features
The benefits and ability of using [`@ngtools/webpack`](https://www.npmjs.com/~ngtools) standalone from the Angular CLI as presented in [Stephen Fluin's Angular CLI talk](https://youtu.be/uBRK6cTr4Vk?t=6m45s) at Angular Connect 2016:
Expand Down
9 changes: 9 additions & 0 deletions packages/@ngtools/webpack/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface AotPluginOptions {

// Use tsconfig to include path globs.
exclude?: string | string[];
compilerOptions?: ts.CompilerOptions;
}


Expand Down Expand Up @@ -113,6 +114,14 @@ export class AotPlugin implements Tapable {
} catch (err) {
throw new Error(`An error happened while parsing ${this._tsConfigPath} JSON: ${err}.`);
}

if (options.hasOwnProperty('compilerOptions')) {
tsConfigJson.compilerOptions = Object.assign({},
tsConfigJson.compilerOptions,
options.compilerOptions
);
}

const tsConfig = ts.parseJsonConfigFileContent(
tsConfigJson, ts.sys, basePath, null, this._tsConfigPath);

Expand Down

0 comments on commit 84a3131

Please sign in to comment.