335 Commits

Author SHA1 Message Date
Alan Agius
04f5dfe5e2 fix(@angular-devkit/build-angular): use new Webpack watch API in karma webpack plugin
In Webpack 5, the Webpack callback must be used when Webpack is running in watch mode.

Related warning
```
.(node:6565) [DEP_WEBPACK_WATCH_WITHOUT_CALLBACK] DeprecationWarning: A 'callback' argument need to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.
```
2021-04-20 09:27:05 -05:00
Alan Agius
cb9e51f687 refactor(@angular-devkit/build-angular): remove custom Webpack Stats types
Webpack 5 contains improved types that we can leverage.
2021-04-20 09:27:05 -05:00
Charles Lyding
5804fec902 refactor(@angular-devkit/build-angular): remove Webpack 4 specific type casting
Webpack 5 contains improved types and exports that reduce the need to perform additional type casting throughout the internal Webpack plugins.
2021-04-19 20:32:13 +02:00
Charles Lyding
e55923656c fix(@angular-devkit/build-angular): avoid double build optimizer processing
TypeScript files had the potential to be processed twice by the build optimizer. This did not affect the output code but could lead to longer production build times. The build optimizer is now configured in one centralized location for both TypeScript and JavaScript files. The Webpack configuration partial for TypeScript support is also reduced to one common function for both AOT and JIT as a result.
2021-04-19 20:30:21 +02:00
Charles Lyding
bac563e5ee feat(@angular-devkit/build-angular): support specifying stylesheet language for inline component styles
A new build option named `inlineStyleLanguage` has been introduced that will allow a project to define the stylesheet language used in an application's inline component styles. Inline component styles are styles defined via the `styles` property within the Angular `Component` decorator. Both JIT and AOT mode are supported. However, JIT mode requires that inline styles only be string literals (compile-time partial evaluation is not supported in JIT mode). Currently supported language options are: `CSS` (default), `Sass`, `SCSS`, and `Less`. If the option is not specified, `CSS` will be used and enables existing projects to continue to function as expected.
2021-04-14 07:21:11 -04:00
Charles Lyding
330235230c refactor(@angular-devkit/build-angular): remove redundant webpack-sources dependency
The `webpack` package now exports the `Source` based classes directly.
2021-04-13 15:34:54 -04:00
Alan Agius
c609e7104c build: update to cssnano to version 5.0.0
Closes #19106
2021-04-13 10:50:02 -04:00
Alan Agius
cc52e5453c fix(@angular-devkit/build-angular): remove duplicate application bundle generation complete message
In some scenarios in Webpack 5 percentage goes from 1 back to 0.99, ex: 0.99 -> 1 -> 0.99 -> 1. This causes the "complete" message to be displayed multiple times.
2021-04-13 10:49:40 -04:00
Alan Agius
1532e32cc2 refactor: clean up webpack 4 code 2021-04-13 10:49:17 -04:00
Charles Lyding
d47b4417d4 feat(@angular-devkit/build-angular): support processing component inline CSS styles
The internal Webpack configuration now includes support for style rules with MIME type conditions. This allows the data URIs generated for inline component CSS styles by the Angular Webpack plugin to be processed with the same loaders as file based styles.
2021-04-12 14:08:43 -04:00
Alan Agius
dee6b79489 refactor: remove @types/webpack 2021-04-12 10:02:07 -04:00
Alan Agius
0f4bbb58d4 refactor(@angular-devkit/build-angular): remove webpack 4 checks
These are no longer needed as we don't support Webpack 4 any longer
2021-04-12 10:02:07 -04:00
Alan Agius
bd0aba7c80 fix(@angular-devkit/build-angular): disable webpack cache when using NG_BUILD_CACHE 2021-04-12 10:02:07 -04:00
Charles Lyding
79f369c26f refactor(@angular-devkit/build-angular): optimize analytics plugin bundle stats for Webpack 5
Newer Webpack 5 APIs allow the bundle stat generation for analytics to be optimized including less iteration of chunks and assets.
2021-04-08 09:42:47 -04:00
Charles Lyding
d883ce5d7e feat(@angular-devkit/build-angular): upgrade to Webpack 5 throughout the build system
With this change Webpack 5 is now used by the Angular tooling to build applications. Webpack 4 usage and support has been removed.
No project level configuration changes are required to take advantage of the upgraded Webpack version when using the official Angular builders.
Custom builders based on this package that use the experimental programmatic APIs may need to be updated to become compatible with Webpack 5.

BREAKING CHANGE: Webpack 5 lazy loaded file name changes
Webpack 5 generates similar but differently named files for lazy loaded JavaScript files in development configurations (when the `namedChunks` option is enabled).
For the majority of users this change should have no effect on the application and/or build process. Production builds should also not be affected as the `namedChunks` option is disabled by default in production configurations.
However, if a project's post-build process makes assumptions as to the file names then adjustments may need to be made to account for the new naming paradigm.
Such post-build processes could include custom file transformations after the build, integration into service-side frameworks, or deployment procedures.
Example development file name change: `lazy-lazy-module.js` --> `src_app_lazy_lazy_module_ts.js`

BREAKING CHANGE: Webpack 5 web worker support
Webpack 5 now includes web worker support. However, the structure of the URL within the `Worker` constructor must be in a specific format that differs from the current requirement.
Web worker usage should be updated as shown below (where `./app.worker` should be replaced with the actual worker name):
Before: `new Worker('./app.worker', ...)`
After:  `new Worker(new URL('./app.worker', import.meta.url), ...)`
2021-04-08 09:42:47 -04:00
Charles Lyding
8770d5f015 refactor(@angular-devkit/build-angular): remove use of deprecated ngtools ivy namespace export
With the removal of the deprecated ViewEngine-based Webpack plugin, the ivy namespace export that was previously used is now deprecated in favor of direct exports of the Ivy-based plugin.
2021-04-05 19:20:56 +02:00
Charles Lyding
677913fc38 fix(@angular-devkit/build-angular): remove usage of deprecated View Engine 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, Ivy-based compilation will always be used when building an application.
The default behavior for applications is to use the Ivy compiler when building and no changes are required for these applications.
For applications that have opted-out of Ivy, a warning will be shown and an Ivy-based build will be attempted. If the build fails,
the application may need to be updated to become Ivy compatible.
2021-04-02 08:11:11 +02:00
Alan Agius
3d1bd01641 refactor(@angular-devkit/build-angular): remove ngfactories checks 2021-03-30 14:37:09 -06:00
Alan Agius
b35517505f refactor(@angular-devkit/build-angular): remove view engine check from analytics collector 2021-03-30 14:37:09 -06:00
Charles Lyding
ac4c109beb fix(@angular-devkit/build-angular): ensure output directory is present before writing stats JSON
If an error occurs during a build, it is possible that the output path directory may not be present and then cause the stats JSON file write to fail.

Fixes: #20349
2021-03-22 15:41:41 -04:00
Alan Agius
2616ef0d3f feat(@angular-devkit/build-angular): integrate JIT mode linker
With this change we intergate JIT mode linker into the Angular CLI.

Closes #20281
2021-03-18 15:38:52 +01:00
Charles Lyding
d5645675fd fix(@angular-devkit/build-angular): support writing large Webpack stat outputs
When using the `statsJson` browser builder option, the resulting JSON data is now streamed into a file instead of written in one large block.  This mitigates crashes due to the generated string exceeded the Node.js limit.
2021-03-17 11:27:27 +01:00
Alan Agius
6cc8c26083 refactor(@ngtools/webpack): remove suppressZoneJsIncompatibilityWarning option
BREAKING CHANGE

`suppressZoneJsIncompatibilityWarning` option has been removed. If you are using this plugin directly and `async/await` in ES2017 make sure you downlevel the async syntax using Babel.

See: https://github.com/angular/zone.js/pull/1140 for more information.
2021-03-15 20:31:25 +01:00
Charles Lyding
699b641b85 perf(@angular-devkit/build-angular): remove Webpack Stats.toJson usage in karma plugin
Webpack's `Stats.toJson` function is an expensive operation and is recommended to be avoided where possible. In the case of the karma plugin, the compilation errors can be accessed directly without the need for the function call.
2021-03-15 09:01:50 +01:00
Charles Lyding
3affd28f5e perf(@angular-devkit/build-angular): remove Webpack Stats.toJson usage in analytics plugin
Webpack's Stats.toJson function is an expensive operation and is recommended to be avoided where possible. In the case of the analytics plugin, the chunks and assets can be accessed directly from the Webpack compilation.
2021-03-15 09:01:36 +01:00
Alan Agius
1e9881bcb4 refactor(@angular-devkit/build-angular): replace lazy loading resources context path 2021-03-10 12:44:04 -06:00
Alan Agius
988b05a8e5 refactor(@angular/cli): remove deprecated lazyModules option from schema 2021-03-10 12:44:04 -06:00
Alan Agius
8d66912323 refactor(@angular-devkit/build-angular): remove deprecated lazyModules option
BREAKING CHANGE:

Server and Browser builder `lazyModules` option has been removed without replacement.
2021-03-10 12:44:04 -06:00
Charles Lyding
240727aefa refactor(@angular-devkit/build-angular): separate global script configuration logic
This change moves the global script resolution logic to a separate function to aid in reducing the complexity of the Webpack styles configuration partial generation function.
2021-03-08 08:46:20 -06:00
Charles Lyding
1b5798dba3 refactor(@angular-devkit/build-angular): use nested Webpack rules to define style processing
By using Webpack's nested rule and `oneOf` rule support, a large amount of conditional logic and array processing can be removed from the Webpack style configuration generator function.
2021-03-08 08:46:20 -06:00
Charles Lyding
3408c3df49 refactor(@angular-devkit/build-angular): only inline component stylesheet sourcemaps
This change also ensures that hidden sourcemaps will be propagated through the loader chain and are extracted for global stylesheets.
2021-03-02 06:13:19 -05:00
Alan Agius
2ef39498b0 fix(@angular-devkit/build-angular): disable declaration and declarationMap
When building an application or testing a library. TypeScript declarations are not needed.

Closes #20103
2021-02-22 16:55:44 +01:00
Alan Agius
f309516bcd refactor(@angular-devkit/build-angular): drop support for zone.js 0.10
BREAKING CHANGE:

Minimum supported `zone.js` version is `0.11.4`
2021-02-17 12:44:43 -06:00
Renovate Bot
e2d6df29e7 build: update webpack-dev-middleware to version 4.1.0 2021-02-15 14:46:21 -06:00
Charles Lyding
40dc44b64b refactor(@angular-devkit/build-angular): remove usage of Webpack Stats.ToJsonOutput type
The `Stats.ToJsonOutput` type is not present in the Webpack 5 typings. There was also a large amount of forced typing in the code to successfully compile.
Minimal Webpack JSON stat types are now used that represent the fields used by the tooling.
2021-02-11 12:33:47 -05:00
Charles Lyding
e871f87fa2 refactor(@angular-devkit/build-angular): remove use of Webpack RuleSetLoader type
The `RuleSetLoader` type is not exported from the Webpack 5 types.
2021-02-10 14:08:07 -05:00
Alan Agius
9337617723 feat(@angular-devkit/build-angular): add postcss-preset-env with stage 3 features
With this change we add `postcss-preset-env` with stage 3 features. This stage includes support for:

 - all property
 - break properties
 - custom properties
 - font-variant property
 - gap properties
 - media query ranges

See https://preset-env.cssdb.org/features#stage-3
2021-02-09 10:30:42 -05:00
Alan Agius
fb2d7ee903 refactor(@angular-devkit/build-angular): remove experimental rollup pass
The experimental rollup pass has significant issues with the new Ivy webpack plugin. It also, didn't produce as well as we hoped in real world scenarios infact in many cases this caused build to fail.

REAKING CHANGE:

The experimental rollup pass `--experimental-rollup-pass` option has been removed.

Closes #15836
2021-02-09 08:50:00 -05:00
Alan Agius
aedfcc1862 build: update to @types/node version 12 2021-02-08 14:07:24 -05:00
Amadou Sall
1b5971a0bc fix(@angular-devkit/build-angular): the root Tailwind configuration file is always picked
A configuration file in the project root should take precedence over one in the workspace root, but it's not currently the case.
2021-02-08 09:33:59 -05:00
S. Iftekhar Hossain
a7ffce10ee fix(@angular-devkit/build-angular): fixed ignoring of karma plugins config
Previously `karma-coverage` was validated only when in karma plugins config one of these was added
``'karma-coverage'` or `require('karma-coverage')`

This change will allow cli to validate `karma-coverage` plugin if in `karma.conf.js` `'karma-*'` is used. Example:
```
plugins: [
      ...
      'karma-*',
      require('@angular-devkit/build-angular/plugins/karma'),
      ...
    ]
```

Fixes #19993
2021-02-08 09:30:00 -05:00
Charles Lyding
ab5078d660 fix(@angular-devkit/build-angular): increase resilience of babel cache identifier
This provides a default cache identifer to the babel loader that includes all internal options from the customized babel loader.
2021-02-04 19:44:07 +01:00
Alan Agius
6732294ff3 refactor(@angular-devkit/build-angular): remove file-loader dependency
`file-loader` resolves `import/require()` on a file into a url. This is non standard, undocumented, unsupported Webpack specific functionality. This was introduced in the Angular CLI  before `postcss-cli-resources` existed and was never removed.

Using `file-loader` and `postcss-cli-resources` are no longer needed with Webpack 5, because of the introduction of [Assets Modules](https://webpack.js.org/guides/asset-modules/).

BREAKING CHANGE:

The unsupported/undocumented, Webpack specific functionality to `import`/`require()` a non-module file has been removed.

Before
```js
import img from './images/asset.png';
```

After
```html
<img src="images/asset.png">
```
2021-02-04 08:42:57 +01:00
Alan Agius
d2ce3e7d62 fix(@ngtools/webpack): don't use skipTemplateCodegen to determine if compilation is JIT mode
With this change we add a new `jitMode` option to the ivy AngularWebpackPlugin.
`readConfiguration` from `@angular/compiler-cli` will use file configuration options over programmaticly supplied options. By using a separate option the options precedence issue can be avoided.

Closes #19949
2021-02-03 20:44:07 +01:00
Alan Agius
238438e26f refactor(@angular-devkit/build-angular): remove BundleBudgetPlugin
Remove BundleBudgetPlugin, and instead use the `checkBudgets` method directly in the browser buillder.
2021-02-03 18:14:26 +01:00
Charles Lyding
73b409881f feat(@angular-devkit/build-angular): detect and use tailwindcss in projects
This feature adds detection of the `tailwindcss` package (https://tailwindcss.com) and provides a mechanism to automatically include support. To enable tailwindcss for a project, two actions must be taken:
1) Install `tailwindcss` into the Angular workspace (`npm install -D tailwindcss`/`yarn add -D tailwindcss`)
2) Create a tailwindcss configuration file (`tailwind.config.js`) in either the workspace root or the project root.  A configuration file in the project root takes precedence over one in the workspace root.

When both conditions are met, the Angular CLI will initialize and integrate tailwindcss into the stylesheet build pipeline.
2021-02-03 09:57:06 +01:00
Alan Agius
52d14d7261 refactor(@angular-devkit/build-angular): remove config barrel file export 2021-02-02 15:21:39 +01:00
Alan Agius
e02d737cb8 fix(@angular-devkit/build-angular): handle promise rejection in IndexHtmlWebpackPlugin
Webpack doesn't handle promise rejections properly. With this change use use a try/catch block and add the error to the compilation.

Closes #19893
2021-01-28 20:32:39 +01:00
Alan Agius
60b2cb7f10 fix(@angular-devkit/build-angular): add fallback for non defined stats options
A fallback value for stats options when an option is not defined. It has precedence over local webpack defaults.
2021-01-28 20:32:17 +01:00
Alan Agius
a86ea3f154 fix(@angular-devkit/build-angular): allow emitting multiple files with the same filename
Previously when hashing of media was disabled, if 2 files had the same name. Only one files used to be emitted. With this change we change the behaviour so that both files are emitted.

Closes #12186
2021-01-28 09:35:31 +01:00