183 Commits

Author SHA1 Message Date
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
247b87d40a refactor(@angular-devkit/build-angular): move dev-server webpack config in a separate file
With this change we remove webpack dev-server logic to a seperate file. We also use the webpack-dev-server API to add live-reload and hmr entry-points and settings.
2020-10-16 21:08:18 +02:00
Alan Agius
e253fffbe6 refactor(@angular-devkit/build-angular): move addition of HMR plugins and loaders to webpack configs 2020-10-14 21:57:47 +03:00
Alan Agius
871dd6a434 feat(@angular-devkit/build-angular): enable font inlining optimizations
With this change we inline Google fonts and icons in the index html file when optimization is enabled.

**Before**
```html
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
```
**After**
```html
<style>
  @font-face {
    font-family: 'Material Icons';
    font-style: normal;
    font-weight: 400;
    src: url(https://fonts.gstatic.com/s/materialicons/v55/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2) format('woff2');
  }

  .material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
  }
</style>
```

To opt-out of this feature set `optimization.fonts: false` or `optimization.fonts.inline: false` in the browser builder options.

Example:
```js
"configurations": {
  "production": {
    "fileReplacements": [
      {
        "replace": "src/environments/environment.ts",
        "with": "src/environments/environment.prod.ts"
      }
    ],
    "optimization": {
      "fonts": false
    },
```

More information about the motivation for this feature can be found: https://github.com/angular/angular-cli/issues/18730

Note: internet access is required during the build for this optimization to work.
2020-10-14 21:57:29 +03:00
Charles Lyding
a4d31fd16e refactor(@angular-devkit/build-angular): fully temporarily disable Webpack 5 license extraction 2020-10-14 10:11:02 -04:00
Charles Lyding
755cb8dc57 test(@angular-devkit/build-angular): disable experimental Rollup size tests
The experimental Webpack Rollup pass no longer produces smaller sizes than the standard production build.
2020-10-12 11:04:14 -04:00
Alan Agius
84b63e5893 refactor(@angular-devkit/build-angular): remove RxJs usage from writeIndexHtml 2020-10-09 13:12:28 -04:00
Alan Agius
e96fbd3c8a refactor(@angular-devkit/build-angular): change errors and warnings messages
Sometimes the WARNING IN/ERROR IN can lead of ambiguous messages

 - Use `Warning` instead of `WARNING IN`
-  Use `Error` instead of `Error In`
2020-09-30 16:17:05 +02:00
Charles Lyding
cdb404bd3c fix(@angular-devkit/build-angular): warn if using unsupported IE9/10 browsers
As of Angular v11, IE9 and IE10 are no longer officially supported.  A warning will now be shown during builds if these browsers are requested in the project's browserslist configuration.
2020-09-25 22:46:04 +02:00
Charles Lyding
0c112e5d91 feat(@angular-devkit/build-angular): support package references in styles & scripts options
The browser builder's `styles` and `scripts` options now support using a package name in the path when specifying a style or script.  This removes the need to use a relative path to the node modules directory in these options.  This provides support for Yarn PnP as well as reducing the complexity of the options especially for monorepo setups.  Relatively located files will take precedence over packages if they exist.  This precedence provides backwards compatibility with existing configurations.

Before :
`"styles": ["../node_modules/bootstrap/dist/css/bootstrap.css"]`

After:
`"styles": ["bootstrap/dist/css/bootstrap.css"]`
2020-09-25 20:22:04 +02:00
Charles Lyding
93e2438954 test(@angular-devkit/build-angular): test Ivy specific files in unused file tests
The test was previously run only in Ivy mode but with VE specific test case files.  The test now also enables strict templates to ensure template type checking files are properly excluded.
2020-09-24 14:30:15 +02:00
Alan Agius
b9c98ee5f1 fix(@angular-devkit/build-angular): add missing defaults to optimization property 2020-09-24 14:27:25 +02:00
Alan Agius
ee14ab0193 refactor(@angular-devkit/build-angular): use optional chaining operator where possible in browser builder 2020-09-23 11:22:58 -05:00
Alan Agius
a73c947205 refactor(@angular-devkit/build-angular): use architect builder output error instead of logger 2020-09-23 11:22:58 -05:00
Alan Agius
76557029a9 style: add proper indentation to RXJS pipe operators 2020-09-23 11:22:58 -05:00
Alan Agius
11c6abdd79 refactor(@angular-devkit/build-angular): clean up differential loading config generation
Closes #16098
2020-09-23 11:22:58 -05:00
Alan Agius
d3ad09508f refactor(@angular-devkit/architect): remove deprecated TestLogger
BREAKING CHANGE:

Deprecated `TestLogger` has been removed. Use `logging` API from `'@angular-devkit/core'` instead.

**Note:** this change doesn't effect application developers.
2020-09-22 10:29:53 -05:00
Alan Agius
5996896076 feat(@angular-devkit/build-angular): improve build stats output format
With this change we also remove sourcemaps from build info to align with Webpack 5 output.
2020-09-18 14:52:38 -05:00
Alan Agius
13b17baebe refactor(@angular-devkit/build-angular): add spinners for localize and downlevelling 2020-09-16 10:38:58 -04:00
Alan Agius
0d10de5cbb refactor(@angular-devkit/build-angular): re-structure folder structure and move code
Previous
```
packages/angular_devkit/build_angular
├── plugins
│   └── webpack
└── src
    ├── angular-cli-files
    │   ├── models
    │   │   └── webpack-configs
    │   ├── plugins
    │   └── utilities
    │       ├── index-file
    │       └── service-worker
    ├── app-shell
    ├── browser
    │   └── specs
    ├── dev-server
    ├── extract-i18n
    ├── karma
    ├── ng-packagr
    ├── protractor
    ├── server
    ├── tslint
    ├── utils
    └── webpack
        └── models
```

Now
```
packages/angular_devkit/build_angular
├── plugins
└── src
    ├── app-shell
    ├── browser
    │   └── specs
    ├── dev-server
    ├── extract-i18n
    ├── karma
    ├── ng-packagr
    ├── protractor
    ├── server
    ├── tslint
    ├── utils
    │   └── index-file
    └── webpack
        ├── configs
        ├── plugins
        └── utils
```
2020-09-14 16:40:39 -04:00
Alan Agius
1ebd7e610d refactor(@angular-devkit/build-angular): use common logging function for webpack stats
With this change we align all builders to have the same output structure.
2020-09-10 16:21:28 +02:00
Alan Agius
f5ee8a0c1a fix(@angular-devkit/build-angular): don't generate vendor.js.map when vendor sourcemaps is disabled
This reduced the build time of an `ng new` application from `5920ms` to `4616ms`

Closes #18060
2020-09-03 00:22:08 +03:00
Alan Agius
d49888b350 docs: update fileReplacements description 2020-08-31 11:58:04 +01:00
Alan Agius
197e96b8c5 refactor(@angular-devkit/build-angular): remove deprecated scripts[].lazy and styles[].lazy
BREAKING CHANGE:

- Deprecated `scripts[].lazy` has been renamed with `scripts[].inject`
- Deprecated `styles[].lazy` has been renamed with `styles[].inject`

Note: this change only effects direct `@angular-devkit/build-angular` users and not application developers. Users will be migrated automatically off these options.
2020-08-31 11:54:23 +01:00
Alan Agius
dd260185a1 refactor(@angular-devkit/build-angular): deprecate extractCss browser builder option
BREAKING CHANGE:

Browser builder `extractCss` option default value has been changed from `false` to `true`. This is to reflect the default behaviour when this deprecated option is removed.
2020-08-31 11:54:23 +01:00
Hari G
61701ab259 fix(@angular-devkit/build-angular): handle base tag endOffset in index.html generation
* fix endOffset if the base tag is already present
* add test case for this

Closes #18381
2020-08-25 12:52:38 -04:00
Alan Agius
bbe83ae377 fix(@angular-devkit/build-angular): don't warn on transitive CommonJS dependencies in AOT mode
At the moment in AOT mode if a CommonJS dependency has transitive CommonJS dependency we are issue warning for both.

With this change we align the behaviour with JIT mode, where we issue warnings only for direct CommonJS dependencies or ES dependencies which have CommonJS dependencies.

Closes #18526
2020-08-14 16:21:49 +02:00
Alan Agius
155707a1ba fix(@angular-devkit/build-angular): don't log blank warnings in console
Closes #18524
2020-08-14 14:41:18 +02:00
Alan Agius
0ac6def35c test(@angular-devkit/build-angular): update allow js test plugin to make it strict compliant 2020-08-12 19:28:17 +01:00
Alan Agius
fc5d2b3ff2 test: remove tsconfig.base.json from test cases 2020-08-12 19:26:12 +01:00
Alan Agius
e11d55679e fix(@angular-devkit/build-angular): generate service worker manifest when running build in watch mode
Closes #16883
2020-08-07 00:58:18 +01:00
Alan Agius
05588fcee1 refactor: clean up unused code and imports 2020-07-24 08:01:52 +02:00
Alan Agius
2aedad9a9b fix(@angular-devkit/build-angular): suppress warning for CommonJS templateUrl and styleUrl
Currently, when users use either absolute paths, or path mappings in JIT mode, we issue a warning for templateUrl and styleUrl. With this change we suppress those warning.

Closes: #18057
2020-07-15 13:51:00 -04:00
Charles Lyding
c75a48dfcc test(@angular-devkit/build-angular): increase rebuild debounce times
CI performance variability can cause test flakes in rebuild tests due to the rebuilds taking longer than expected.  This change increases the 500ms debounce time for the web worker rebuild tests to 1000ms to mitigate these issues.
2020-07-13 12:17:06 -04:00
Charles Lyding
bcb41e3977 fix(@angular-devkit/build-angular): wrap ES5 differential loading bundles
This change ensures that classic (ES5) script's top-level function helpers do not get overwritten by other scripts top-level functions that happen to have the same name.  This is not an issue when using module script types because each module has its own scope.
2020-07-13 12:16:42 -04:00
Alan Agius
0a573e7376 fix(@angular-devkit/build-angular): remove non-global locale import warning
We have not yet deprecated the non-global locale data modules (e.g. `@angular/common/locales/fr`) so we should not be issuing warnings about developers using them.

We recently added warning suggesting that a "global" locale should be used instead, and the previous CommonJS/AMD warning about the format of these non-global modules are just confusing for the developer.

Reference: TOOL-1388
Closes: #18123
2020-07-07 08:56:59 +02:00
Alan Agius
64a2686293 fix(@angular-devkit/build-angular): show child compilation errors
Closes #17565
2020-07-03 09:42:24 +02:00
Alan Agius
c578c73575 fix(@angular-devkit/build-angular): show warning when using non global locale data
When using the `localize` option directly importing locale data from `@angular/common` is not needed because the Angular CLI  will automatically include locale data. When not using the `localize` option, most likely users meant to import the global variant of the local data.

See: https://angular.io/guide/i18n#import-global-variants-of-the-locale-data
2020-07-01 14:04:05 +01:00
Alan Agius
708360e267 fix(@angular-devkit/build-angular): match allowed dependencies against the package name
With this change we add the functionality to also match an allowed dependency against a package name. The package name is retrieved from the rawRequest.

Previously, users needed to add the request path which in some case might be a deep import. Ex: `zone.js/dist/zone-error`. With this change adding the package name example `zone.js` will suffice.

Closes: #18058
2020-07-01 14:04:05 +01:00
Alan Agius
f66c4bd2b9 docs(@angular-devkit/build-angular): update link for commonjs warning 2020-06-24 15:22:59 -04:00
Charles Lyding
3af3281e05 test(@angular-devkit/build-angular): use async expect in asset tests 2020-06-24 14:42:08 -04:00
Charles Lyding
3c734a89e1 fix(@angular-devkit/build-angular): use copy-on-write asset processing for non-watch builds
Optimized asset processing was only being performed when differential loading was enabled.  This change ensures that the optimized approach is used for non-watch builds.  This does not affect `ng serve` usage since it currently requires all application files to be in memory.
2020-06-24 14:42:08 -04:00
Alan Agius
01a0f1fce8 fix(@angular-devkit/build-angular): update copy-webpack-plugin to version 6
Fixes #17858
2020-06-09 11:36:40 +01:00
cexbrayat
03fc4aff00 refactor(@angular-devkit/build-angular): mention how to disable the warning for commonjs dependencies
The current message clearly mentions which dependencies are CommonJS ones, but doesn't point out how to get rid of the warning if nothing can be done. This commit adds a mention of `allowedCommonJsDependencies` in the warning to help developers (as we do for `versionMismatch` for example).
2020-05-28 15:03:37 -04:00
Alan Agius
93e253bc93 refactor: rename tsconfig.json to tsconfig.base.json 2020-05-20 12:12:33 -07:00
Charles Lyding
2ae0300ad5 refactor(@angular-devkit/build-angular): optimize parallel worker shutdown
Stopping the workers can be a potentially lengthy process with a multi-stage approach based on the state of the worker.  This can cause lengthy blocking of the build.  This change allows the shutdown to happen in parallel to the remainder of the build.
2020-05-18 19:30:03 +01:00
Charles Lyding
4048e3c26f test(@angular-devkit/build-angular): improve performance of autoprefixer tests
These tests check the output of the global stylesheet and require a browserslist to target IE but this also triggers differential loading which is unneeded for the test.
2020-05-18 19:30:03 +01:00
Alan Agius
4e4e0e42ec style: fix typo in allowedCommonJsDependencies description 2020-05-18 19:25:41 +01:00
Alan Agius
4d4fc099ff build: udate angular packages to version 10 2020-05-07 10:38:22 -07:00