Skip to content

Commit 160102a

Browse files
clydinalan-agius4
authored andcommitted
fix(@ngtools/webpack): remove Webpack plugin for deprecated ViewEngine compiler
BREAKING CHANGE: Removal of View Engine support from application builds With the removal of the deprecated View Engine compiler in Angular version 12 for applications, the View Engine Webpack plugin has been removed. The Ivy-based Webpack plugin is the default used within the Angular CLI. If using a custom standalone Webpack configuration, the removed `AngularCompilerPlugin` should be replaced with the Ivy-based `AngularWebpackPlugin`.
1 parent 0273660 commit 160102a

39 files changed

+65
-5286
lines changed

packages/ngtools/webpack/BUILD.bazel

-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ ts_library(
3535
module_name = "@ngtools/webpack",
3636
module_root = "src/index.d.ts",
3737
deps = [
38-
"//packages/angular_devkit/core",
39-
"//packages/angular_devkit/core/node",
4038
"@npm//@angular/compiler-cli",
4139
"@npm//@types/node",
4240
"@npm//@types/webpack",

packages/ngtools/webpack/README.md

+12-51
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,38 @@
1-
# Angular Ahead-of-Time Webpack Plugin
1+
# Angular Compiler Webpack Plugin
22

3-
Webpack 4.0 plugin that AoT compiles your Angular components and modules.
3+
Webpack 4.x/5.x plugin for the Angular Ahead-of-Time compiler. The plugin also supports Angular JIT mode.
44

55
## Usage
66

77
In your webpack config, add the following plugin and loader.
88

9-
Angular version 5 and up, use `AngularCompilerPlugin`:
10-
119
```typescript
12-
import { AngularCompilerPlugin } from '@ngtools/webpack';
10+
import { AngularWebpackPlugin } from '@ngtools/webpack';
1311

1412
exports = { /* ... */
1513
module: {
1614
rules: [
1715
{
18-
test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
16+
test: /\.[jt]sx?$/,
1917
loader: '@ngtools/webpack'
2018
}
2119
]
2220
},
2321

2422
plugins: [
25-
new AngularCompilerPlugin({
26-
tsConfigPath: 'path/to/tsconfig.json',
27-
entryModule: 'path/to/app.module#AppModule',
28-
sourceMap: true,
29-
i18nInFile: 'path/to/translations.en.xlf',
30-
i18nInFormat: 'xlf',
31-
i18nOutFile: 'path/to/translations.xlf',
32-
i18nOutFormat: 'xlf',
33-
locale: 'en',
34-
hostReplacementPaths: {
35-
'path/to/config.development.ts': 'path/to/config.production.ts'
36-
}
23+
new AngularWebpackPlugin({
24+
tsconfig: 'path/to/tsconfig.json',
3725
})
3826
]
3927
};
4028
```
4129

42-
The loader works with webpack plugin to compile your TypeScript. It's important to include both, and to not include any other TypeScript compiler loader.
30+
The loader works with webpack plugin to compile the application's TypeScript. It is important to include both, and to not include any other TypeScript loader.
4331

4432
## Options
4533

46-
* `tsConfigPath`. The path to the `tsconfig.json` file. This is required. In your `tsconfig.json`, you can pass options to the Angular Compiler with `angularCompilerOptions`.
47-
* `basePath`. Optional. The root to use by the compiler to resolve file paths. By default, use the `tsConfigPath` root.
48-
* `entryModule`. Optional if specified in `angularCompilerOptions`. The path and class name of the main application module. This follows the format `path/to/file#ClassName`.
49-
* `mainPath`. Optional if `entryModule` is specified. The `main.ts` file containing the bootstrap code. The plugin will use AST to determine the `entryModule`.
50-
* `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.
51-
* `sourceMap`. Optional. Include sourcemaps.
52-
* `compilerOptions`. Optional. Override options in `tsconfig.json`.
53-
* `contextElementDependencyConstructor`. Optional. Set to `require('webpack/lib/dependencies/ContextElementDependency')` if you are having `No module factory available for dependency type: ContextElementDependency` errors.
54-
* `directTemplateLoading`. Optional. It causes the plugin to load component templates (HTML) directly from the filesystem. This is more efficient if only using the `raw-loader` to load component templates. Do not enable this option if additional loaders are configured for component templates.
55-
* `forkTypeChecker`. Optional, defaults to `true`. Run the TypeScript type checker in a forked process.
56-
* `hostReplacementPaths`. Optional. It allows replacing resources with other resources in the build.
57-
* `platform`. Optional, defaults to `0`. Possible values are `0` and `1`. `0` stands for browser and `1` for server.
58-
* `logger`. Optional. A custom logger that sends information to STDOUT and STDERR.
59-
* `nameLazyFiles`. Optional. If `true` then uses the `[request]` placeholder to set dynamic chunk names.
60-
* `missingTranslation`. Optional and only used for View Engine compilations. defaults to `warning`. Possible values are `warning`, `error` or `ignore`. Determines how to handle missing translations for i18n.
61-
* `i18nInFile`. Optional and only used for View Engine compilations. Localization file to use for i18n.
62-
* `i18nInFormat`. Optional and only used for View Engine compilations. The format of the localization file.
63-
* `i18nOutFile`. Optional and only used for View Engine compilations. The name of the file to write extractions to.
64-
* `i18nOutFormat`. Optional and only used for View Engine compilations. The format of the localization file where extractions will be written to.
65-
* `locale`. Optional and only used for View Engine compilations. Locale to use for i18n.
66-
## Features
67-
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:
68-
69-
* Compiles Sass/Less into CSS
70-
* TypeScript transpilation
71-
* Bundles JavaScript, CSS
72-
* Asset optimization
73-
* Virtual filesystem for assets
74-
* For serving local assets and compile versions.
75-
* Live-reload via websockets
76-
* Code splitting
77-
* Recognizing the use of `loadChildren` in the router, and bundling those modules separately so that any dependencies of those modules are not going to be loaded as part of your main bundle. These separate bundles will be pulled out of the critical path of your application, making your total application bundle much smaller and loading it much more performant.
34+
* `tsconfig` [default: `tsconfig.json`] - The path to the application's TypeScript Configuration file. In the `tsconfig.json`, you can pass options to the Angular Compiler with `angularCompilerOptions`. Relative paths will be resolved from the Webpack compilation's context.
35+
* `compilerOptions` [default: none] - Overrides options in the application's TypeScript Configuration file (`tsconfig.json`).
36+
* `jitMode` [default: `false`] - Enables JIT compilation 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.
37+
* `directTemplateLoading` [default: `true`] - Causes the plugin to load component templates (HTML) directly from the filesystem. This is more efficient if only using the `raw-loader` to load component templates. Do not enable this option if additional loaders are configured for component templates.
38+
* `fileReplacements` [default: none] - Allows replacing TypeScript files with other TypeScript files in the build. This option acts on fully resolved file paths.

packages/ngtools/webpack/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
},
2222
"homepage": "https://github.com/angular/angular-cli/tree/master/packages/@ngtools/webpack",
2323
"dependencies": {
24-
"@angular-devkit/core": "0.0.0",
2524
"enhanced-resolve": "5.7.0",
2625
"webpack-sources": "2.2.0"
2726
},
@@ -31,6 +30,7 @@
3130
"webpack": "^4.0.0 || ^5.20.0"
3231
},
3332
"devDependencies": {
33+
"@angular-devkit/core": "0.0.0",
3434
"@angular/compiler": "12.0.0-next.7",
3535
"@angular/compiler-cli": "12.0.0-next.7",
3636
"typescript": "4.2.3",

0 commit comments

Comments
 (0)