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

Add possibility to pass i18n options to Webpack Aot Plugin #3047

Closed
wants to merge 2 commits 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
3 changes: 2 additions & 1 deletion packages/webpack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ The loader works with the webpack plugin to compile your TypeScript. It's import
* `entryModule`. Optional if specified in `angularCompilerOptions`. The path and classname of the main application module. This follows the format `path/to/file#ClassName`.
* `mainPath`. Optional if `entryModule` is specified. The `main.ts` file containing the bootstrap code. The plugin will use AST to determine the `entryModule`.
* `genDir`. Optional. The output directory of the offline compiler. The files created by the offline compiler will be in a virtual file system, but the import paths might change. This can also be specified in `angularCompilerOptions`, and by default will be the same as `basePath`.
* `typeChecking`. Optional, defaults to true. Enable type checking through your application. This will slow down compilation, but show syntactic and semantic errors in webpack.
* `typeChecking`. Optional, defaults to true. Enable type checking through your application. This will slow down compilation, but show syntactic and semantic errors in webpack.
* `i18nOptions`. Optional. Pass an object of type NgcCliOptions.
11 changes: 7 additions & 4 deletions packages/webpack/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface AotPluginOptions {
entryModule?: string;
mainPath?: string;
typeChecking?: boolean;
i18nOptions?: ngCompiler.NgcCliOptions
}


Expand Down Expand Up @@ -71,7 +72,7 @@ export class AotPlugin {
private _typeCheck: boolean = true;
private _basePath: string;
private _genDir: string;

private _i18nOptions: ngCompiler.NgcCliOptions;

constructor(options: AotPluginOptions) {
this._setupOptions(options);
Expand Down Expand Up @@ -110,6 +111,7 @@ export class AotPlugin {
genDir = tsConfig.ngOptions.genDir;
}

this._i18nOptions = options.i18nOptions;
this._compilerOptions = tsConfig.parsed.options;

if (options.entryModule) {
Expand Down Expand Up @@ -201,13 +203,14 @@ export class AotPlugin {

this._resourceLoader = new WebpackResourceLoader(compilation);

const i18nOptions: ngCompiler.NgcCliOptions = {
const i18nOptions: ngCompiler.NgcCliOptions = this._i18nOptions || {
i18nFile: undefined,
i18nFormat: undefined,
locale: undefined,
basePath: this.basePath
locale: undefined
};

i18nOptions.basePath = this.basePath;

// Create the Code Generator.
const codeGenerator = ngCompiler.CodeGenerator.create(
this._angularCompilerOptions,
Expand Down