673 Commits

Author SHA1 Message Date
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
Charles Lyding
9144cf87ff refactor(@angular-devkit/build-angular): support Webpack 5 errors/warnings
Webpack 5 uses an object to represent errors and warnings unlike Webpack 4 which used a string.  This change provides support for both scenarios.
2020-09-14 15:54:30 -04:00
Alan Agius
14d70d15b9 refactor(@angular-devkit/build-angular): add missing formatOptions which is non optional in v11.0.0-next.1
Related to https://github.com/angular/angular/pull/38787
2020-09-11 14:31:07 -04:00
Alan Agius
622d08447d refactor: use ansi-colors instead of removed terminal utils 2020-09-10 20:19:33 +02:00
Charles Lyding
f31f853de8 refactor(@angular-devkit/build-angular): use Webpack ChunkGraph API in SuppressExtractedTextChunksWebpackPlugin 2020-09-10 19:46:45 +02:00
Alan Agius
9087197e4a fix(@angular-devkit/build-angular): set logging level to verbose when using --verbose 2020-09-10 17:53:02 +02: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
0a9e1fd3af build: update postcss-loader to version 4.0 2020-09-09 18:31:29 +02:00
Charles Lyding
16fabddbf1 refactor(@angular-devkit/build-angular): support dedupe plugin with Webpack 5
The structure of the data from the `afterResolve` hook has changed in Webpack 5.  This change provides compatibility for both the Webpack 5+ and Webpack 4 variants.
2020-09-09 10:47:13 +02:00
Charles Lyding
22ecb13986 fix(@angular-devkit/build-angular): filter unactionable System.import webpack warning
Webpack 5+ has no facility to disable this warning. `System.import` is used in `@angular/core` for deprecated string-form lazy routes.
2020-09-09 00:05:40 +02:00
Alan Agius
72097ea55c refactor(@angular-devkit/build-angular): lazy require autoprefixer, mini-css-extract-plugin and postcss-import 2020-09-08 19:47:09 +02:00
Keen Yee Liau
8995e49f0b feat(@angular-devkit/build-angular): Switch to karma-coverage
This commit switches coverage tooling from karma-coverage-istanbul-reporter
to karma-coverage since it's better supported.

Closes #17757
2020-09-06 12:22:25 +02:00
Alan Agius
5f064eba74 build: update @types/webpack to 4.41.22 2020-09-03 18:08:09 +02:00
Alan Agius
e95b73f6fb refactor(@angular-devkit/build-angular): set resolve roots to projectRoot
Previously roots was the same as context which was set to projectRoot, however in the previous change we changed the context to workspaceRoot.

With this change we maintain the same resolve root setting.

More info:
4a3e4bda6b/lib/config/defaults.js (L875)

 https://webpack.js.org/configuration/resolve/
2020-09-03 18:08:09 +02:00
Alan Agius
086d74d2b4 fix(@angular-devkit/build-angular): improve debugging experience
With this change we improve the debugging experience with 2 things.

1. Cleaner Karma stack traces in the terminal
Before
```
Chrome 84.0.4147.105 (Mac OS 10.15.5) AppComponent should have as title 'foo' FAILED
        Error: Expected 'foo' to equal 'fox'.
            at <Jasmine>
            at UserContext.<anonymous> (http://localhost:9876/_karma_webpack_/webpack:/projects/foo/src/app/app.component.spec.ts:22:23)
            at ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-evergreen.js:364:1)
            at ProxyZoneSpec.push../node_modules/zone.js/dist/zone-testing.js.ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-testing.js:292:1)
Chrome 84.0.4147.105 (Mac OS 10.15.5): Executed 3 of 3 (1 FAILED) (0 secs / 0.214 secs)
Chrome 84.0.4147.105 (Mac OS 10.15.5) AppComponent should have as title 'foo' FAILED
        Error: Expected 'foo' to equal 'fox'.
            at <Jasmine>
            at UserContext.<anonymous> (http://localhost:9876/_karma_webpack_/webpack:/projects/foo/src/app/app.component.spec.ts:22:23)
            at ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-evergreen.js:364:1)
            at ProxyZoneSpec.push../node_modules/zone.js/dist/zone-testing.js.ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zChrome 84.0.4147.105 (Mac OS 10.15.5): Executed 3 of 3 (1 FAILED) (0.225 secs / 0.214 secs)
```

After
```
Chrome 84.0.4147.105 (Mac OS 10.15.5) AppComponent should have as title 'foo' FAILED
        Error: Expected 'foo' to equal 'fox'.
            at <Jasmine>
            at UserContext.<anonymous> (projects/foo/src/app/app.component.spec.ts:22:23)
            at ZoneDelegate.invoke (node_modules/zone.js/dist/zone-evergreen.js:364:1)
            at ProxyZoneSpec.push../node_modules/zone.js/dist/zone-testing.js.ProxyZoneSpec.onInvoke (node_modules/zone.js/dist/zone-testing.js:292:1)
Chrome 84.0.4147.105 (Mac OS 10.15.5): Executed 2 of 3 (1 FAILED) (0 secs / 0.225 secs)
Chrome 84.0.4147.105 (Mac OS 10.15.5) AppComponent should have as title 'foo' FAILED
        Error: Expected 'foo' to equal 'fox'.
            at <Jasmine>
            at UserContext.<anonymous> (projects/foo/src/app/app.component.spec.ts:22:23)
            at ZoneDelegate.invoke (node_modules/zone.js/dist/zone-evergreen.js:364:1)
Chrome 84.0.4147.105 (Mac OS 10.15.5): Executed 3 of 3 (1 FAILED) (0.281 secs / 0.237 secs)
```

2. Reduce VS Code configuration
Before
```
{
  "name": "ng test",
  "type": "chrome",
  "request": "launch",
  "url": "http://localhost:9876/debug.html",
  "webRoot": "${workspaceFolder}",
  "sourceMaps": true,
  "sourceMapPathOverrides": {
    "webpack:/*": "${webRoot}/*",
    "/./*": "${webRoot}/*",
    "/src/*": "${webRoot}/*",
    "/*": "*",
    "/./~/*": "${webRoot}/node_modules/*"
  }
},
```

After
```
{
  "name": "ng test",
  "type": "chrome",
  "request": "launch",
  "url": "http://localhost:9876/debug.html",
  "webRoot": "${workspaceFolder}",
},
```
2020-09-03 18:08:09 +02:00
Alan Agius
ee7d8f64c8 fix(@angular-devkit/build-angular): generate sourcemaps with relative paths in monorepo
With this change we fix the issue that when having a monorepo style workspace, sourcemaps sources references absolute paths.

Closes #17046
2020-09-03 18:08:09 +02:00
Charles Lyding
a3e404bf16 fix(@angular-devkit/build-angular): correct i18n function parameter type
The type of the first parameter of the internal unwrapTemplateLiteral function should be a `NodePath<types.TaggedTemplateExpression>` not a `NodePath<types.TemplateLiteral>`.
2020-09-03 00:23:30 +03: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
Charles Lyding
484c94ef0a refactor(@angular-devkit/build-angular): support Webpack with no node shims
Webpack 5+ no longer provides node shims by default.  The dev-server builder previously assumed that Webpack would provide them.  This change adds a conditional check to cover both cases.
2020-09-03 00:20:54 +03:00
Charles Lyding
9a1871d58a fix(@angular-devkit/build-angular): correct Windows paths in ivy i18n extract
POSIX path handling was errantly being used to resolve paths which does not handle Windows drive letters.
2020-08-31 11:58:13 +01: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
Charles Lyding
71360878d9 fix(@angular-devkit/build-angular): ensure ivy extraction file names match sourcemaps
Not doing so results in a circular sourcemap warning when attempting extraction.
2020-08-28 08:55:36 +01:00
Charles Lyding
156e31778f feat(@angular-devkit/build-angular): ask to use a new port if in use
The dev-server builder will now ask the user if an available port can be used when a specified port is already in use.  If the user answers in the affirmative, an available port will be used instead.  Otherwise, the serve operation will fail.  If the terminal is not interactive (for example, CI), the serve operation will fail directly in the event of an already in use port.
2020-08-28 08:52:40 +01:00
Alan Agius
86fe03c979 build: update webpack-merge to version 5.1.2 2020-08-28 08:50:30 +01:00
Charles Lyding
854d1844db fix(@angular-devkit/build-angular): support @angular/localize 10.1.0
Several utility functions within `@angular/localize` were updated in 10.1.0.  This change ensures that this newer version will function with 10.1.0 of `@angular-devkit/build-angular`.
2020-08-26 18:46:14 -04:00
Charles Lyding
802d5ade78 feat(@angular-devkit/build-angular): allow transformation of i18n extraction builder configuration
This change allows the underlying webpack configuration of the i18n extraction builder to be modified when programmatically using the builder.
Programmatic usage of the `@angular-devkit/build-angular` builders is currently considered experimental.

Closes #16679
2020-08-26 10:54:24 -04: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
Charles Lyding
0d7e0f5eb5 style(@angular-devkit/build-angular): remove duplicate license header 2020-08-24 07:50:01 -04:00
Charles Lyding
a5293fe747 feat(@angular-devkit/build-angular): support i18n message extraction with Ivy
This change adds support for extracting i18n translation messages with an Ivy enabled application. This is accomplished by using the new extraction capabilities present in the `@angular/localize` package and will require version 10.1 or later of the package.  Since this change uses an new extraction method, it currently must be enabled during extraction by using the `--ivy` flag. The flag is a precaution to prevent unintentional breakage for existing applications but will become the default behavior for all Ivy enabled applications in a future release.

Closes #18275
2020-08-18 16:49:45 +02:00
Alan Agius
60a42c28f6 refactor(@angular-devkit/build-angular): remove JIT mode styles and templates workaround 2020-08-17 19:17:46 +02: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
e5b29ac756 feat(@angular-devkit/build-angular): add ng-packagr builder in @angular-devkit/build-angular
With this change we add the `ng-packagr` builder in `@angular-devkit/build-angular`
2020-08-14 15:38:12 +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
60e8ac2b1e refactor(@angular-devkit/build-angular): improve HMR warning 2020-08-13 20:53:54 +02:00
Alan Agius
24fedb268c feat(@angular-devkit/build-angular): enable HMR for extracted CSS
The latest versions of mini-css-extract-plugin support HMR, see: https://github.com/webpack-contrib/mini-css-extract-plugin#hot-module-reloading-hmr for more details
2020-08-13 20:53:54 +02:00
Charles Lyding
9cd796b124 feat(@angular-devkit/build-angular): support multiple translation files per locale
This change implements the capability to specify multiple translation files per locale. The specified translation files for each locale will be merged prior to localization. The Angular configuration file has been updated to allow for both a single path string or an array of path strings when specifying the translations for each locale. If the same message identifier is present in multiple translation files, a warning will currently be issued and the last file with the duplicate message identifier will take precedence.

Closes #18276
2020-08-13 12:23:59 +02:00
Charles Lyding
8cca8ab961 refactor(@angular-devkit/build-angular): cleanup server webpack configuration 2020-08-12 19:29:25 +01:00
Alan Agius
0ba5664525 refactor(@angular-devkit/build-angular): update bundle calculator make it strict compliant 2020-08-12 19:28:17 +01:00
Alan Agius
5085da3417 refactor(@angular-devkit/build-angular): update postcss-cli-resources plugin to make it strict compliant 2020-08-12 19:28:17 +01: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
2dada50774 refactor(@angular-devkit/build-angular): change allEquivalent parameter type of generic iterable
Co-authored-by: Charles <19598772+clydin@users.noreply.github.com>
2020-08-12 19:27:19 +01:00
Alan Agius
0da7f79ab3 refactor(@angular-devkit/build-angular): simplify budgets allEquivalent method 2020-08-12 19:27:19 +01:00
Charles Lyding
4116dddb65 refactor(@angular-devkit/build-angular): cleanup Webpack type usage
These changes simplify type usage in several places as well as cover more usage scenarios with alternate configuration option structures (for example, options that can be arrays or object literals)..
2020-08-12 19:27:00 +01:00
Charles Lyding
155215d60a refactor(@angular-devkit/build-angular): support Webpack assets as string or Buffer
Webpack 5 allows an asset's source to be either a string or a Buffer.
2020-08-12 19:27:00 +01:00
Alan Agius
fc5d2b3ff2 test: remove tsconfig.base.json from test cases 2020-08-12 19:26:12 +01:00
Alexey Makhrov
042c33cfd2 fix(@angular-devkit/build-angular): better handle relative paths with bundleDependencies=false
When `bundleDependencies` is turned off, webpack only bundles modules imported via relative path.
Existing check works well for import paths like `'./some/file'`,
but fails for imports traversing the dir structure up, like `'../some/file'`.
2020-08-10 09:46:47 +01:00