130 Commits

Author SHA1 Message Date
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
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
Filipe Silva
3079b06bd0 test: re-enable ivy aot rebuild test 2019-12-02 12:50:14 -08: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
Charles Lyding
dd4bc23a48 fix(@angular-devkit/build-angular): keep licenses if extraction is disabled 2019-10-25 15:22:26 -07:00
Alan Agius
f943d3a8dc refactor(@angular-devkit/build-angular): rename ngModuleDef to ɵmod 2019-10-16 05:56:23 -07:00
Alan Agius
e847ee5c83 fix(@angular-devkit/build-angular): change the ngComponentDef to ɵcmp
Related to 64fd0d6db9
2019-10-16 05:56:23 -07:00
Alan Agius
d9bf2dbbda fix(@angular-devkit/build-angular): avoid attempting to copy directories
Avoid copying directly directories, also which this change we cache `fs.existsSync` to optimize copying when a lot of file are being copied to the same destination.

Closes: #15816
2019-10-11 13:53:48 -07:00
Filipe Silva
47490527ff feat(@angular-devkit/build-angular): add experimentalRollupPass (#15690)
In applications that make heavy use of lazy routes and ES2015 libraries, this option can improve bundle sizes. It might also break your bundles in ways we don't understand fully, so please test and report any problems you find.

NOTE: the following are known problems with experimentalRollupPass
- vendorChunk, commonChunk, namedChunks: these won't work, because by the time webpack sees the chunks, the context of where they came from is lost.
- webWorkerTsConfig: workers must be imported via a root relative path (e.g.`app/search/search.worker`) instead of a relative path (`/search.worker`) because of the same reason as above.
- loadChildren string syntax: doesn't work because rollup cannot follow the imports.
2019-10-10 12:39:38 -07:00
Alan Agius
2c8b12f45c feat(@angular-devkit/build-angular): update sass-loader to 8.0.0
Full list of changes https://github.com/webpack-contrib/sass-loader/blob/master/CHANGELOG.md#800-2019-08-29
2019-09-05 00:24:32 +05:30
Filipe Silva
77cb0d3f41 test: add issue for disabled Ivy AOT rebuild test 2019-08-30 22:53:46 +05:30
Filipe Silva
430e75978a test: re-enable lazy route error tests for Ivy 2019-08-30 22:53:46 +05:30
Filipe Silva
45155dc489 test: fix external source map test for Ivy 2019-08-30 22:53:46 +05:30
Filipe Silva
60f9b19ecd test: use Ivy by default, opt-in to VE 2019-08-28 22:54:52 +05:30
Alan Agius
09d2f04d1b fix(@angular-devkit/build-angular): update worker-plugin to 3.2.0 (#15456)
includes this fix https://github.com/GoogleChromeLabs/worker-plugin/pull/35 which solves the below issues.

Fixes #15188 and fixes #14582
2019-08-28 00:10:26 -07:00
Alan Agius
0111693271 Ivy build_ng_packagr (#15262)
* test: update ng-packagr builder tests to work on Windows

* build: add ng packagr test large for ivy

* test: fix web-worker test in ivy

Previously, we were not testing web workers under Ivy as we were overriding tsconfig.app.json entirely without including enableIvy.

When enabling Ivy we are getting warning of files that are part of the compilation which causing a warning to show and break the test.

* build: update ng-packagr to `^5.4.0`

* test: display ivy mode message once
2019-08-12 10:20:02 -07:00
Charles Lyding
1c6f665c4f feat(@angular-devkit/build-angular): implement bundle level downleveling to support differential loading 2019-08-08 08:26:15 -07:00
Alan Agius
9478ee9c47 fix(@ngtools/webpack): gracefully show error when compiling broken component styles
Fixes #15240
2019-08-05 18:01:53 -07:00
Alan Agius
f4be0ba677 fix(@ngtools/webpack): display unused file warning once per file 2019-08-05 18:00:13 -07:00
Alan Agius
607e6f7cfd test: increase/add debounceTime to reduce flakiness 2019-07-29 15:06:10 -07:00
vikerman
07780b9272 style: clean up existing lint errors 2019-07-24 23:28:49 -07:00
Alan
6649483d86 fix(@ngtools/webpack): delete all virtual files for styles on change
Fixes #15143
2019-07-24 19:07:10 -07:00
Alan
0224d2b92e fix(@angular-devkit/build-angular): fix sourcemaps for vscode breakpoints
`namespace` is always empty which is breaking sourcemaps since when sources start with `/` vscode will not be able to resolve them unless users configure `sourceMapPathOverrides`.

Fixes #15116
2019-07-24 19:05:43 -07:00
Alan
bcf250c94d feat(@angular-devkit/build-angular): add bundle budget for component styles
It’s very easy to inadvertently import toplevel css in component styles. Since component css is standalone and self-contained, it will never be shared between components and remains as a single large bundle for each component. This in turn adds a large amount of code that must be processed and increases bundle size.

Related to: TOOL-949
2019-07-24 19:05:00 -07:00
Alan
28bd5493a7 fix(@ngtools/webpack): retain child compilation warnings and errors
At the moment child compilation warnings and errors are being lost as they are not passed to the root compilation.  This means that any errors that are being set by clean-css for component styles are being lost.
2019-07-24 19:05:00 -07:00
Alan Agius
4f8e349033 fix(@angular-devkit/build-angular): only add module script types to actual module scripts
Fixes #15102
2019-07-24 19:04:31 -07:00
Alan Agius
63f0049e43 feat(@ngtools/webpack): show warning when a TS compilations contains unused files
When a tsconfig without `includes` or `files` all files under the `rootDir` will be included in the compilation. This results in redundant files to inserted as part of the ts compilation which in some cases might reduce the compilation drastically.

Related to: TOOL-949
2019-07-24 19:03:35 -07:00
Charles
6d4f8a249c test: remove material-design-icons package as a development dependency (#15096)
The package is quite large at 33MB (46MB on disk).  The package is also only used in one test that is already covered by an E2E test.  The E2E test does not require the package to be present for development as the test installs it within a generated project during execution.  This also has the benefit of testing the icons package in a more real world use case; as well as allowing the test to serve as a guide for a user to add the package to their own application.
2019-07-16 14:41:59 -07:00
Alan Agius
0551360035 fix(@schematics/angular): exclusively list the files in tsconfigs (#15030)
* test: update tests to work with new stricter tsconfig file inclusions

* fix(@schematics/angular): exclusively list the files in tsconfigs

With the omission of `includes` or `files` in tsconfig files tsc will pick up all the files under the rootDir and make them as part of the compilation. In certain cases, redundant files will be picked up which will cause a slower compilations.

Related to: TOOL-949
2019-07-16 11:04:29 -07:00
Charles
f8a58213eb feat(@angular-devkit/build-angular): add defer attributes to classic scripts (#15087)
This change synchronizes the behavior of classic scripts and module scripts (`type="module"`).  Module scripts are deferred by default.  Also, certain injected scripts are not considered module scripts even in a ES2015+ build due to the strict mode behavior of module scripts.  Deferring such scripts also ensures consistent execution in those scenarios.
2019-07-16 09:58:19 -07:00
Alan
885005241e build: update webpack to version 4.35.3 2019-07-11 01:21:18 +08:00
Charles Lyding
8e97df3888 feat(@angular-devkit/build-angular): allow control of index output path
This allows the output path of an application's index HTML file to be controlled independently of the input file.  The output path for the file will be considered relative to the application's configured output path.  This allows an application to contain multiple input index files for different configurations and allow the output file to remain constant.  This also enables the placement of the index file in a subdirectory within the output path or change the name of the output index file neither of which was previously possible.
2019-07-10 04:34:20 +08:00
Alan Agius
86266a39fa fix(@ngtools/webpack): resources path normalizations
Compiler host `readResource` is always called with POSIX seperators. However the `denormalizePath` method doesn't convert forward slashes to back slashes which causes `getModifiedResourceFiles` to return an empty `Set`.

We were also assuming that `_changedFiles` is an FS path which was not the case as it's original type is `Path`

Fix #15012
2019-07-10 04:17:05 +08:00
Alan
2b367be1c3 feat(@angular-devkit/build-angular): deprecate scripts and styles lazy option in favor ofinject
The lazy option inside the script and style option is confusing as this option doesn't lazy load a bundle but rather it doesn't inject/reference the script in the HTML. While this option is an enabler for lazy loading, the users will still need to handle on how how this bundle will be lazy loaded. There are also potential use cases beyond lazy loading for the option.

Closes #14814
2019-07-02 11:05:51 -07:00
Charles Lyding
99fa7bd71f test: add initial ivy large test support 2019-07-02 10:04:09 -07:00
Alan Agius
68227565ce feat(@angular-devkit/build-angular): add crossorigin options
This options allows to define the crossorigin attribute setting of elements that provide CORS support

Closes #14743
2019-06-27 15:12:43 -07:00