213 Commits

Author SHA1 Message Date
Alan Agius
74537a11d4 test(@angular-devkit/build-angular): update tests to reflect the change in ES targets 2021-03-15 20:31:25 +01:00
Alan Agius
5e2c45c8db test(@angular-devkit/build-angular): change test to use await/async 2021-02-22 12:43:31 +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
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
cexbrayat
53193eaf77 fix(@schematics/angular): remove duplicated Karma traces
Currently, Karma is reporting a failed test and the total twice in a bare CLI project:

```
12 11 2020 13:59:46.666:INFO [launcher]: Starting browser Chrome
✔ Browser application bundle generation complete.
12 11 2020 13:59:50.457:INFO [Chrome 86.0.4240.198 (Mac OS 10.15.7)]: Connected on socket F0ehOBWL6BYFqXfbAAAA with id 69358036
Chrome 86.0.4240.198 (Mac OS 10.15.7) AppComponent should render title FAILED
	Error: Expected 'ponyracer app is running!' to contain 'other'.
	    at <Jasmine>
	    at UserContext.<anonymous> (src/app/app.component.spec.ts:29:65)
	    at ZoneDelegate.invoke (node_modules/zone.js/dist/zone-evergreen.js:364:1)
	    at ProxyZoneSpec.push.QpwO.ProxyZoneSpec.onInvoke (node_modules/zone.js/dist/zone-testing.js:292:1)
Chrome 86.0.4240.198 (Mac OS 10.15.7): Executed 2 of 3 (1 FAILED) (0 secs / 0.231 secs)
Chrome 86.0.4240.198 (Mac OS 10.15.7) AppComponent should render title FAILED
	Error: Expected 'ponyracer app is running!' to contain 'other'.
	    at <Jasmine>
	    at UserContext.<anonymous> (src/app/app.component.spec.ts:29:65)
	    at ZoneDelegate.invoke (node_modules/zone.js/dist/zone-evergreen.js:364:1)
Chrome 86.0.4240.198 (Mac OS 10.15.7): Executed 3 of 3 (1 FAILED) (0.309 secs / 0.242 secs)
TOTAL: 1 FAILED, 2 SUCCESS
TOTAL: 1 FAILED, 2 SUCCESS
```

This is a bit annoying when you have several tests failing, and tend to confuse beginners.

This commit configures the Karma HTML reporter to suppress the duplicates (both error and success), which results in only one reporter showing the failed test and total:

```
12 11 2020 14:01:43.002:INFO [launcher]: Starting browser Chrome
✔ Browser application bundle generation complete.
12 11 2020 14:01:58.728:INFO [Chrome 86.0.4240.198 (Mac OS 10.15.7)]: Connected on socket Pc0xPggxJPdC8E_LAAAA with id 54797430
Chrome 86.0.4240.198 (Mac OS 10.15.7) AppComponent should render title FAILED
	Error: Expected 'ponyracer app is running!' to contain 'other'.
	    at <Jasmine>
	    at UserContext.<anonymous> (src/app/app.component.spec.ts:29:65)
	    at ZoneDelegate.invoke (node_modules/zone.js/dist/zone-evergreen.js:364:1)
	    at ProxyZoneSpec.push.QpwO.ProxyZoneSpec.onInvoke (node_modules/zone.js/dist/zone-testing.js:292:1)
Chrome 86.0.4240.198 (Mac OS 10.15.7): Executed 3 of 3 (1 FAILED) (0.331 secs / 0.252 secs)
TOTAL: 1 FAILED, 2 SUCCESS
```
2020-11-13 15:53:01 -05:00
Renovate Bot
251b53672e build: update angular packages 2020-11-12 17:13:22 -05:00
Alan Agius
58dfe228f0 build: remove @types/jasminewd2 from repo devDependencies 2020-10-26 10:13:05 -04:00
Alan Agius
bda8bc8b70 test(@angular-devkit/build-angular): fix unit test setup to be able to run new Ivy extraction 2020-09-28 21:24:10 +02:00
Alan Agius
155a6f6f88 test: disable progress during extract-i18n 2020-09-28 15:58:26 +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
ba7f6e8cf2 test(@angular-devkit/build-angular): add ng-packagr test application in build-angular 2020-08-14 15:38:12 +02:00
Alan Agius
fc5d2b3ff2 test: remove tsconfig.base.json from test cases 2020-08-12 19:26:12 +01:00
Charles Lyding
872bd48bbf test: update generated tests to not use async helper function 2020-07-15 12:36:48 -04:00
Alan Agius
d50a2fef2f fix(@schematics/angular): use ES2016 as syntax target for server bundles
The supported versions of Node.js support up to ES2018, the only reason why we don't use ES2017+ is because native `async` and `await` don't work with zone.js

See: https://github.com/angular/angular/issues/31730

With this change, we also ensure that we don't downlevel the server bundle to ES5 which is unnecessary.

Closes: #17794
2020-06-01 14:53:37 -04:00
Alan Agius
ade3f491fe fix(@schematics/angular): remove node typings from tsconfig.spec.json 2020-05-27 14:17:05 +02:00
Alan Agius
93e253bc93 refactor: rename tsconfig.json to tsconfig.base.json 2020-05-20 12:12:33 -07:00
Alan Agius
0fd3c550b5 feat(@schematics/angular): update compiler options target and module settings
With this change we update the target and module settings of various compilation units.

- We replace ES5 target in protractor. Protractor runs on Node.Js which support ES2018
- For applications we now use `ES2020` instead of `ESNext` as a module to avoid unexpected changes in behaviour

This changes also adds a migration to update existing projects and also removes `module` from the Universal tsconfig as per #17352 to enable lazy loading on the server.
2020-05-06 11:42:35 -07:00
Filipe Silva
9a28114f6b test: remove non-bazel test setup 2020-04-30 15:12:46 -07:00
Filipe Silva
ef7a07050a test(@angular-devkit/build-angular): build and test with Bazel 2020-04-30 15:12:46 -07:00
Alan Agius
8fb7e586cc refactor(@angular-devkit/build-angular): remove deprecated evalSourceMap, vendorSourceMap, profile and skipAppShell options
BREAKING CHANGE:

The following deprecated devkit builders options have been removed:
- `skipAppShell:` This has no effect
- `evalSourceMap`: This done to improve performance in older versions of the CLI and is no longer needed
- `vendorSourceMap`: Use `sourceMap.vendor` instead
- `profile`: Use `NG_BUILD_PROFILING` environment variable instead
2020-04-27 15:08:15 -07:00
Charles Lyding
254994db85 fix(@angular-devkit/build-angular): ensure webpack tilde resolve behavior for stylesheet resources 2020-04-27 11:07:58 -07:00
Charles Lyding
c034477dc5 feat(@angular-devkit/build-angular): rebase relative stylesheet assets when using preprocessors
Previously, when using a preprocessor, resources (e.g., `url(./my-image.jpg)`) referenced in a stylesheet that was imported into another stylesheet would retain the exact URL.  This would be problematic as the resource would not be at the relative location within the new combined stylesheet.  With this change the resource URLs will now be adjusted to reference the origin location of the resource.  This allows the resources to be found without any additional changes to the application or build process.
CSS and Less already functioned in this manner. This change brings Sass and Stylus to parity.

Fixes: #12797
2020-04-27 11:07:58 -07:00
Charles Lyding
06e9955743 test(@angular-devkit/build-angular): ensure autoprefixed global CSS imports 2020-04-27 11:07:58 -07:00
Alan Agius
710cf5656e fix(@angular-devkit/build-angular): retain css declarations order when using extractCss and @import rule
Relevant code:
239e43d1f3/src/plugins/postcss-import-parser.js (L9)

239e43d1f3/src/index.js (L132-L150)

Fixes #9475
2020-04-10 09:56:55 -07:00
Alan Agius
10e7eb2c24 test: change browserslist file name to .browserslistrc 2020-04-06 09:58:42 -07:00
Alan Agius
b7a612f14a feat(@schematics/angular): change browserslist file name to .browserslistrc
Closes: #15961
2020-04-06 09:58:42 -07:00
Alan Agius
ea11c5549a feat(@angular-devkit/build-angular): show warnings when depending on CommonJS.
Depending on CommonJS modules is know to cause optimization bailouts. With this change when running a browser build and scripts optimization is enabled we display a warning.

To suppress the warning for a particular package, users can use the `allowedCommonJsDepedencies` builder options.

Example:
```
"build": {
  "builder": "@angular-devkit/build-angular:browser",
  "options": {
    ...
    "allowedCommonJsDepedencies": ["bootstrap"]
  },
}
```

Reference: TOOL-1328
2020-03-23 14:20:21 -07:00
Wojciech Okoński
237bade5d5 fix(@angular-devkit/build-angular): add missing styles extensions in anyComponentStyle budget
Make anyComponentStyle budged work with all style extensions. Previously it was working only with css styles. Files with other extensions were ignored.
2020-03-16 21:43:44 -07:00
Alan Agius
d29d40370a fix(@angular-devkit/build-angular): fix autoprefixer comments support in scss
Change Scss output style to `expanded` as otherwise sass will remove comments that are needed for autoprefixer when webpack is in prod mode because of the following implementation in `sass-loader`:
See: 45ad0be172/src/getSassOptions.js (L68-L70)

Fixes #17041
2020-02-24 12:52:12 -08:00
Alan Agius
9b7b2f0047 fix(@ngtools/webpack): add local dts file as dependencies
We now add non node_modules `.d.ts` as a dependency of the main chunk. This is important under Ivy, because NG metadata is now part of the declarations files ex:

```ts
export declare class FooComponent implements OnInit {
    constructor();
    ngOnInit(): void;
    static ɵfac: i0.ɵɵFactoryDef<FooComponent>;
    static ɵcmp: i0.ɵɵComponentDefWithMeta<FooComponent, "lib-foo", never, {}, {}, never>;
}
```

Previously such files were not being added as dependency and such files didn't get invalidated when changed.

Closes #16920 and closes #16921
2020-02-18 12:44:31 -08:00
Jonathan Garvey
d6c9693952 feat(@angular-devkit/build-angular): pass "grep" and "invertGrep"
Pass the "grep" and "invertGrep" flags through to the Angular Protractor
builder as "jasmineNodeOpts" so that individual specs within an E2E test
file can be targeted.

Fixes #13020
2020-02-18 10:53:27 -08:00
Charles Lyding
6091879428 fix(@angular-devkit/build-angular): generate correct filenames when targeting ESNext
Fixes: #16906
2020-02-12 12:01:42 -08:00
Alan Agius
c3aa081ef7 fix(@angular-devkit/build-angular): add crossorigin attribute to lazy chunks
Fixes #16801
2020-02-03 17:29:58 -08:00
Filipe Silva
d463166461 fix(@ngtools/webpack): correctly determine resource dependencies
Fix #16569
2020-01-23 18:01:03 -08:00
Charles Lyding
9a7d8e3877 fix(@angular-devkit/build-angular): ensure output is ASCII only
Fixes: #16721
2020-01-23 18:00:04 -08:00
Alan Agius
bcfccc93f8 test: refactor web-worker to wait for filesystem to be fully settled 2020-01-16 14:48:23 -08:00
Alan Agius
f1ffb106b2 fix(@angular-devkit/build-angular): emit error when a script is not found
While we currently invoke the `callback` with the error in d4f1ff82c5/packages/angular_devkit/build_angular/src/angular-cli-files/plugins/scripts-webpack-plugin.ts (L163) this is not bubbled up to the main webpack compilation due to the usage of `thisCompilation`.

Closes #16659
2020-01-15 11:31:09 -08:00
Alan Agius
e9897de7ae fix(@angular-devkit/build-angular): change css optimizer from clean-css with cssnano
Closes #16123 and closes #13854
2020-01-13 09:46:15 -08:00
Alan Agius
0659cf09e3 fix(@angular-devkit/build-angular): add externalDependencies to server builders
Certain node packages depend on native bindings which cannot be bundled, with this fix we add a way to exclude these from being processed by the bundler.

Closes: #16348
2019-12-05 18:53:08 -08:00
Alan Agius
0a7ace3595 fix(@angular-devkit/build-angular): allow bundleDependencies to be a boolean 2019-12-05 18:53:08 -08:00
Filipe Silva
3079b06bd0 test: re-enable ivy aot rebuild test 2019-12-02 12:50:14 -08:00
FDIM
2c0efd834b fix(@angular-devkit/build-angular): mocked context in single test transform matches webpack API 2019-11-23 10:35:45 +02:00
Charles Lyding
cfc0aa4780 fix(@angular-devkit/build-angular): properly process es2016+ targets with differential loading
A target of es2015 was previously assumed when using differential loading.  This could result in erroneously downleveling an es2016+ output file instead of generating a new es5 output file.
2019-11-20 13:21:58 -08:00
Filipe Silva
bf39e74e7f fix(@ngtools/webpack): fix rebuilds for transitive and global type deps
Fix #15856
2019-11-19 11:40:58 -08:00
Filipe Silva
8a0f92bd83 fix(@ngtools/webpack): recursive look up unused files
Fix #15626
2019-11-12 11:48:41 -08:00
Filipe Silva
9b91163c52 fix(@ngtools/webpack): don't warn on unused ngsummary
Fix https://github.com/angular/angular-cli/issues/15626#issuecomment-551632356
2019-11-12 11:48:41 -08:00
Filipe Silva
d438cf0f45 test: increase debounce time for rebuild tests 2019-11-05 16:40:37 -08:00
Alan Agius
0f3587173a test: verify that link in outputpath is not deleted at source
Closes: #15183
2019-11-05 16:39:14 -08:00
Alan Agius
588baa5737 fix(@angular-devkit/build-angular): i18n app shell with Ivy 2019-10-30 09:36:14 -07:00
Alan Agius
77a4fba45f fix(@angular-devkit/build-angular): don't emit CSS resources during a server build
The server should serve the assets emitted by the browser builder. In fact the nguniversal schematics are configured to serve the assets from the browser folder
a0cc9ab97a/modules/express-engine/schematics/install/files/__serverFileName%40stripTsExtension__.ts (L26)

Closes #12878
2019-10-29 20:21:24 -07:00