383 Commits

Author SHA1 Message Date
Alan Agius
d0cc0cbda3 fix(@angular-devkit/build-angular): correctly handle scripts when using subresource-integrity option
Fixes #19829
2021-01-25 09:16:32 -06:00
Alan Agius
cc51432661 fix(@angular-devkit/build-angular): resolve less from build-angular package 2021-01-22 10:36:20 -08:00
Alan Agius
5711e691b9 fix(@angular-devkit/build-angular): resolve postcss from build-angular package
`postcss-loader` version 4.2.0 added an `implementation` option. Using the using will ensure that the correct postcss version is used.

More info: deac9787ee

Fixes #19839
2021-01-22 10:36:20 -08:00
Alan Agius
e368b2f141 refactor(@angular-devkit/build-angular): move karma plugin in own folder 2021-01-15 13:31:48 -05:00
Charles Lyding
2ce5445ed3 feat(@angular-devkit/build-angular): support karma version 6.x
This change adds support for using karma 6.x within a project.
2021-01-13 23:12:55 +01:00
Alan Agius
37d8e25af8 fix(@angular-devkit/build-angular): generate consistent filenames
With this change we generate consistent file names when using the browser builder in watch mode with differential loading.

Closes #15157
2021-01-12 17:06:17 +01:00
Charles Lyding
76b023e55e feat(@angular-devkit/build-angular): update IE11 Object/Array polyfills
This change adds the following polyfills for IE11 (`nomodule` browsers):
ES2016:
Array.prototype.includes
ES2017:
Object.entries
Object.values
Object.getOwnPropertyDescriptors
ES2019:
Object.fromEntries
Array.prototype.flat
Array.prototype.flatMap
2021-01-12 09:30:23 +01:00
Charles Lyding
4f352ea204 refactor(@angular-devkit/build-angular): use script target in custom babel loader
This change uses the project's TypeScript configuration script target to determine the required Babel processing.
2021-01-11 08:22:10 +01:00
Charles Lyding
35d8adf020 feat(@angular-devkit/build-angular): integrate Angular compiler linker
The newly introduced library linker mode that removes the need for ngcc is integrated into the Angular CLI's build system.  This allows libraries that are built in linker mode to be used when building an application.
2021-01-08 15:45:45 +01:00
Alan Agius
1df8a3d09d fix(@angular-devkit/build-angular): correctly resolve symlinked global styles entrypoints
With this change we resolve the global stylesheet entrypoint path to use the realpath instead of the symlink path.

Fixes #3500
2021-01-06 12:01:45 +00:00
Alan Agius
cfb368408b fix(@angular-devkit/build-angular): don't downlevel web-animations-js
This library is minified and it causes Babel to consume a lot of resources when trying to downlevel.

Closes #19660
2021-01-05 11:29:34 +00:00
Charles Lyding
11bbe7c45f refactor(@angular-devkit/build-angular): add internal custom file watcher support
This change adds internal support for providing a custom file watching mechanism to the browser (and associated) builders.  The support integrates and overrides the Webpack watch system when enabled.  This is currently intended to support builder unit testing use cases.
2021-01-05 11:02:57 +00:00
Charles Lyding
0e5dab45ef fix(@angular-devkit/build-angular): use URL rewrite in karma fallback middleware
This changes the internal Angular Karma plugin's asset fallback middleware to rewrite the request URL directly instead of trying to copy the request properties.  With changes in newer Node.js versions, not all request properties may be enumerable.

Fixes: #19644
2020-12-18 08:31:59 +01:00
Alan Agius
ba9c755f33 fix(@angular-devkit/build-angular): add console error when using HMR in production mode
FIx: #19591
2020-12-15 12:25:15 +00:00
Keen Yee Liau
48a278e18f fix(@angular-devkit/build-angular): identify plugin provided as string
Karma plugins could be provided either a string or object, but our detection
logic for code coverage plugin only covers the string case.

Fix #19571
2020-12-09 09:52:57 -05:00
Charles Lyding
c94a1961fc fix(@angular-devkit/build-angular): define forwardRef as a pure function
By configuring the optimizer (`terser`) to be aware that the Angular `forwardRef` helper function is a pure function, the optimizer can completely remove the helper call when the return value is unused.
2020-12-08 19:54:14 -05:00
Alan Agius
d3afdcc1b3 fix(@angular-devkit/build-angular): add file path in CSS optimization exception
Closes #19561
2020-12-08 14:39:36 -05:00
Alan Agius
ca69c8c6b4 fix(@angular-devkit/build-angular): update ScriptsWebpackPlugin to work with Webpack 5
Closes: #19550
2020-12-07 15:23:29 -05:00
Alan Agius
eb30a92e8a feat(@angular-devkit/build-angular): enable inlining of critical CSS optimizations
This is another feature that we mentioned in the Eliminate Render Blocking Requests RFC (#18730)

Inlining of critical CSS is turned off by default. To opt-in this feature set `inlineCritical` to `true`.

Example:
```json
"configurations": {
  "production": {
    "fileReplacements": [
      {
        "replace": "src/environments/environment.ts",
        "with": "src/environments/environment.prod.ts"
      }
    ],
    "optimization": {
      "styles": {
        "minify": true,
        "inlineCritical": true,
       }
    },
```

To learn more about critical CSS see;
https://web.dev/defer-non-critical-css
https://web.dev/extract-critical-css/

In a future version of the Angular CLI `inlineCritical` will be enabled by default.

Closes: #17966
Closes: #11395
Closes: #19445
2020-12-04 15:41:29 -05:00
Alan Agius
227804fd6e fix(@angular-devkit/build-angular): stylus not resolving imports from libraries
- Adds usage of webpackImporter https://www.npmjs.com/package/stylus-loader#webpackimporter
- Removes resolve-url-loader usage since stylus handles resolve paths https://stylus-lang.com/docs/js.html#stylusresolveroptions

Closes #19524
2020-12-03 12:59:08 -05:00
Alan Agius
6fe8a6338d fix(@angular-devkit/build-angular): update index html webpack plugin to use non deprecated Webpack 5 API 2020-12-03 10:42:09 -05:00
Alan Agius
064d62014c fix(@angular-devkit/build-angular): resolve partial SCSS files in sourcemaps
Closes #19505
2020-11-30 11:17:20 +01:00
Charles Lyding
f8b9fecf88 fix(@angular-devkit/build-angular): allow default Webpack 5 caching
With upstream fixes in place, the default Webpack 5 caching behavior can now be enabled.  In development mode, memory caching will now be used, and in production, caching will be disabled as per Webpack 5 default behavior.
2020-11-26 09:17:12 +01:00
Alan Agius
d71ee210bf fix(@angular-devkit/build-angular): apply local libraries sourcemap without vendor: true
With this change we apply sourcemaps of libraries in a monorepo without the need to enable `vendor: true`. This is more intuitive behavior and  in line with what the users expect.

We also suppress the `Failed to parse source map from` in-actionable warning.

Closes #11305
2020-11-24 13:33:50 +00:00
Alan Agius
f67c612393 fix(@angular-devkit/build-angular): ERR_SSL_PROTOCOL_ERROR when using HTTPS reverse proxy
With this change we set the publicHost to `0.0.0.0:0`, when it's not provided.

This solved issues where previously the publicHost needed to be specified directly to get around `ERR_SSL_PROTOCOL_ERROR` error when proxing https -> http.

NB: this was also the behaviour in version 10 c252968225/packages/angular_devkit/build_angular/src/dev-server/index.ts (L170)

Closes #19403
2020-11-17 15:40:43 -05:00
Mike Hartington
0f72ca45c3 fix(@angular-devkit/build-angular): ignore hidden inputs with hmr
Closes #19385
Don't query for hidden inputs when using HMR
2020-11-16 13:14:06 -05:00
Alan Agius
9d82269441 refactor(@angular-devkit/build-angular): clean up index generation part 3
With this change we cleanup the index generation. The `IndexHtmlWebpackPlugin` now extends the base `IndexHtmlGenerator` class which makes it easier to override methods to retrieve compilation assets. This is important for the critical css extraction implementation because Critters needs to access the `assets` from the either the compilation when running in memory or the file-system.
2020-11-16 13:03:12 -05:00
Charles Lyding
48c7a85f0a refactor(@angular-devkit/build-angular): support postcss 8
This change updates the internal postcss plugins to use the postcss 8 API as well as updates the versions of all external plugins to postcss 8 supported versions.
2020-11-16 08:51:30 -05:00
Alan Agius
88a3794524 fix(@angular-devkit/build-angular): show missing karma-coverage error when it's not configured
This fixes an issue where previously `karma-coverage must be installed in order to run code coverage` error was shown incorrectly.

Closes: #19359
2020-11-12 13:53:20 -05:00
Alan Agius
2a1b6b1dc7 fix(@angular-devkit/build-angular): separate initial total size in build output
```
Initial Chunk Files                      | Names                |      Size
main-es5.6f60fbc22c7e19b5d179.js         | main                 | 154.89 kB
main-es2015.6f60fbc22c7e19b5d179.js      | main                 | 135.87 kB
polyfills-es5.0351d1276e488726c8dc.js    | polyfills-es5        | 129.34 kB
polyfills-es2015.904e51532a46df6b991c.js | polyfills            |  36.12 kB
scripts.b7f93721b30caf483f97.js          | scripts              |   3.45 kB
runtime-es2015.76bfea807ccb0a24e182.js   | runtime              |   1.45 kB
runtime-es5.76bfea807ccb0a24e182.js      | runtime              |   1.45 kB
styles.3ff695c00d717f2d2a11.css          | styles               |   0 bytes

                                         | Initial ES5 Total    | 289.13 kB
                                         | Initial ES2015 Total | 176.88 kB
```

Closes #19330
2020-11-12 13:15:59 -05:00
Charles Lyding
6703a7f987 fix(@angular-devkit/build-angular): convert file replacements to system paths before use
The file replacement normalization generates internal Path objects which are not compatible with Windows system paths when used externally.
2020-11-05 18:45:52 +01:00
Charles Lyding
4e168b81c5 refactor(@angular-devkit/build-angular): integrate Ivy Webpack compiler plugin
This change integrates the Ivy Webpack compiler plugin into the browser builder.
When Ivy is enabled, which is the default behavior for applications, this plugin will now be used.
If needed, the previous plugin can still be used by enabling the `NG_BUILD_IVY_LEGACY` environment variable.
2020-11-05 08:31:12 +01:00
Alan Agius
cc300212de Revert "fix(@angular-devkit/build-angular): don't generate vendor.js.map when vendor sourcemaps is disabled"
This reverts commit b17763b03d7ca1ce5d2a85d2d03d0029b6623339.

Closes #19236
2020-11-03 17:43:53 -06:00
Alan Agius
66c3f79fc2 fix(@angular-devkit/build-angular): right align size column and add total bundle size 2020-11-03 17:42:01 -06:00
Alan Agius
814ea664d6 fix(@angular-devkit/build-angular): show bundle sizes with 2 decimal places
Before
```
Initial Chunk Files | Names     | Size
vendor.js           | vendor    | 2.07 MB
polyfills.js        | polyfills | 141.3 kb
main.js             | main      | 55.77 kb
runtime.js          | runtime   | 6.15 kb
styles.css          | styles    | 119 bytes
```

After
```
Initial Chunk Files | Names     | Size
vendor.js           | vendor    | 2.07 MB
polyfills.js        | polyfills | 141.30 kb
main.js             | main      | 55.77 kb
runtime.js          | runtime   | 6.15 kb
styles.css          | styles    | 119 bytes
```
2020-11-03 17:42:01 -06:00
Alan Agius
40c25a1e4f fix(@angular-devkit/build-angular): sort bundle stats by size
Before
```
Initial Chunk Files | Names     | Size
runtime.js          | runtime   | 6.15 kB
main.js             | main      | 56.9 kB
vendor.js           | vendor    | 2.4 MB
polyfills.js        | polyfills | 141 kB
styles.css          | styles    | 119 bytes
```

After
```
vendor.js           | vendor    | 2.07 MB
polyfills.js        | polyfills | 141 kB
main.js             | main      | 55.8 kB
runtime.js          | runtime   | 6.15 kB
styles.css          | styles    | 119 bytes
```
2020-11-03 17:42:01 -06:00
Charles Lyding
c569cd0be8 refactor(@angular-devkit/build-angular): use custom babel preset to configure babel-loader
A custom babel preset is introduced to centralize the configuration of babel within the package.  Application related presets and plugins are now encapsulated within the custom preset which is used via the Webpack babel-loader.  This new custom preset will also provide the integration point for the upcoming Angular linker.
2020-11-03 17:37:59 -06:00
Alan Agius
f52fd29165 fix(@ngtools/webpack): show zone.js incompatibility warning when using ES2017+
Closes: #19226
2020-11-02 13:36:04 -06:00
Alan Agius
4cee3eb9a5 fix(@angular-devkit/build-angular): show verbose logging when using --verbose and differential loading 2020-11-02 13:35:52 -06:00
Alan Agius
83fab6b494 fix(@angular-devkit/build-angular): improve builder phase reporting 2020-11-02 13:35:52 -06:00
Charles Lyding
ea02b6e947 fix(@angular-devkit/build-angular): re-enable webpack 5 license extraction support
With updates to the `license-webpack-plugin` and adjustments to the web worker plugin configuration, license extraction can now be used with webpack 5.  This change also removes the need to filter out the duplicate asset warning on Webpack 4 that was previously being generated.
2020-10-30 10:18:42 -05:00
Alan Agius
b45a2adba5 fix(@angular-devkit/build-angular): when optimizing don't wrap function arguments in parenthesis
With this change function and arrow function arguments are not wrapped in parenthesis during the optimization phase.

`wrap_func_args` which is enabled by default in terser will wrap function arguments in parenthesis. Recently this was also changed to wrap lamdas as well:
66c3a5ce66

An increase in bundle size was observed without this change. See: https://github.com/angular/angular/pull/39432#discussion_r512345752
2020-10-27 12:04:44 -04:00
Charles Lyding
e22c196c32 fix(@angular-devkit/build-angular): support emitting AVIF image files 2020-10-23 14:43:18 -04:00
Alan Agius
f122b2f351 fix(@angular-devkit/build-angular): don't add publicHost pathname to sockPath in dev-server
With this change we remove the unintentional breaking change that added publicHost pathname to sockPath instead we now prepend the sockPath with the servePath, which can be either the passed servePath option, baseHref or deployUrl.
2020-10-22 15:49:20 +02:00
Charles Lyding
cc723d8d74 feat(@angular-devkit/build-angular): support following symlinked asset directories
By default subdirectories within a symlinked directory are not searched by a glob.  The new `followSymlinks` option for the longhand form of the `assets` browser builder option now allows opting in to search such subdirectories.
2020-10-21 22:03:24 +02:00
Alan Agius
2298ab865b refactor(@angular-devkit/build-angular): remove deprecated browser build option rebaseRootRelativeCssUrls
BREAKING CHANGE:

Deprecated `rebaseRootRelativeCssUrls` browser builder option has been removed without replacement. This option was used to change root relative URLs in stylesheets to include base HREF and deploy URL and was used only for compatibility and transition as this behavior is non-standard.
2020-10-20 16:53:24 +02:00
Alan Agius
54fc6f1923 refactor(@angular-devkit/build-angular): minor cleanup to dev-server code 2020-10-20 08:51:41 +02:00
Alan Agius
7b77e92338 refactor(@angular-devkit/build-angular): remove allowed webpack and @angular-devkit/build-angular from CommonJsUsageWarnPlugin
These are no longer needed
2020-10-20 08:51:41 +02:00
Jaime Oliveira
ae94245131 fix(@angular-devkit/build-angular): add a base href to karma debug context
This commits adds a base href value in the karma context iframe used to run unit tests where a unit test throws:
No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.
Even if the application is fine.
This is because the index.html from Angular CLI contains a base href value, but not the Karma context iframe.
So when adding a unit test with a testing module that imports a NgModule, for example AppModule,
which itself imports RouterModule, the unit test used to throw an error (regression appeared in router 3.1).
That could be solved by either adding `RouterTestingModule` to the testing module,
or by adding a provider `{ provide: APP_BASE_HREF, useValue: '/' }`, but required to understand the issue.
This solves the issue in a transparent way: developers won't even encounter the problem anymore.

Closes #19116
2020-10-19 12:34:47 +02:00
Alan Agius
574d309cda fix(@angular-devkit/build-angular): don't set watchOptions in webpack-middleware
`webpack-dev-middleware` doesn't have a `watchOptions`

See: https://github.com/webpack/webpack-dev-middleware/blob/master/src/options.json
2020-10-16 21:08:18 +02:00