2471 Commits

Author SHA1 Message Date
Charles Lyding
248860ad67 feat(@angular-devkit/build-angular): add Sass file support to experimental esbuild-based builder
This change adds support for using Sass stylesheets within an application built with the experimental
esbuild-based browser application builder. Global stylesheets (`styles` build option) and component
stylesheets (`@Component({ styleUrls: [...], ...})`) with Sass can now be used.
The `stylePreprocessorOptions.includePaths` option is also available for Sass stylesheets.
Both the default format (`.scss`) and the indented format (`.sass`) are supported.
Inline component stylesheet support is not yet available with the esbuild-based builder.
2022-07-11 11:52:34 -07:00
Alan Agius
d2bbcd7b68 fix(@angular-devkit/build-angular): improve detection of CommonJS dependencies
With this change we include `CommonJsSelfReferenceDependency` and `CommonJsExportsDependency` in the CJS checks.

Closes #23505
2022-07-06 16:33:21 +02:00
Angular Robot
9fe380cbbb build: update all non-major dependencies 2022-07-04 15:25:32 +02:00
Charles Lyding
53e9c459d6 fix(@angular-devkit/build-angular): support hidden component stylesheet sourcemaps with esbuild builder
The hidden stylesheet option was incorrectly being ignored for component
stylesheets when using the experimental esbuild-based browser application
builder. The hidden option will now correctly not include the stylesheet
comment within the stylesheet text for components.
2022-07-01 11:43:39 -04:00
Alan Agius
88701115c6 fix(@angular-devkit/build-angular): don't override base-href in HTML when it's not set in builder
With this change we fix a regression were we  set the base-href to `/` when the browser builder `baseHref` option is not set.

Closes #23475
2022-06-30 09:07:00 -04:00
Alan Agius
7a24609143 fix(@angular-devkit/build-angular): disable glob mounting for patterns that start with a forward slash
By default, a glob pattern starting with a forward slash will be "mounted" onto the system root. This causes globs to escape the workspace root.

With this change we configure disable glob "mounting" and also change the root to the same setting of the `cwd`.

Closes #23467
2022-06-30 08:41:12 -04:00
Alan Agius
ab8ab30c87 fix(@schematics/angular): use sourceRoot instead of src in universal schematic
With this change we remove the usage of hard coded `src` directory and instead infer this from the `sourceRoot` project option.

We also remove the `angularCompilerOptions.entryModule` property in the server tsconfig as this is no longer needed with Ivy.

Closes #12104
2022-06-29 08:56:11 -04:00
renovate[bot]
8048ed0820 build: update all non-major dependencies 2022-06-29 07:57:45 -04:00
Alan Agius
43f495d57b fix(@angular-devkit/build-angular): set base-href in service worker manifest when using i18n and app-shell
Previously, the base href was not set when using the app-shell builder and i18n.

Closes #22389
2022-06-28 16:33:17 -04:00
Alan Agius
2b962549d3 fix(@angular-devkit/build-angular): exit localized builds when CTRL+C is pressed
When using localization we setup `SIGINT` signal to delete the temporary directory. In some cases this resulted in delaying the process from exiting a couple of seconds.

Closes #22216
2022-06-28 10:22:15 -04:00
Alan Agius
3153f7c496 ci: remove flakey test behaviour
During testing architect isn't spawned as a new process therefore we the global state can be tained from previous runs.

`es5TargetWarningsShown` which was saved in the global state caused flakiness.
2022-06-28 09:43:08 -04:00
Alan Agius
a69000407c refactor: clean up old ansi-colors castings
This has been fixed in https://github.com/doowb/ansi-colors/pull/44
2022-06-28 08:49:44 -04:00
renovate[bot]
b0a08ea841 build: update all non-major dependencies 2022-06-28 08:14:04 -04:00
Alan Agius
b40aeed441 fix(@angular-devkit/build-angular): hide stacktraces from webpack errors
In many cases Webpack will output errors with stacktraces even when `errorStack` is configured to false which bloats the terminal and makes the actual error harder to find.

With this change we output stacktraces only when using the `verbose` option.

Before
```
$ ng build

./src/styles.scss.webpack[javascript/auto]!=!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].rules[0].oneOf[0].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[5].rules[0].oneOf[0].use[2]!./node_modules/resolve-url-loader/index.js??ruleSet[1].rules[5].rules[1].use[0]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].rules[1].use[1]!./src/styles.scss - Error: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
  ╷
1 │ @import "invalid";
  │         ^^^^^^^^^
  ╵
  src/styles.scss 1:9  root stylesheet

./src/styles.scss - Error: Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
HookWebpackError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
  ╷
1 │ @import "invalid";
  │         ^^^^^^^^^
  ╵
  src/styles.scss 1:9  root stylesheet
    at tryRunOrWebpackError (/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/webpack/lib/HookWebpackError.js:88:9)
    at __webpack_require_module__ (/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/webpack/lib/Compilation.js:5051:12)
    at __webpack_require__ (/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/webpack/lib/Compilation.js:5008:18)
    at /usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/webpack/lib/Compilation.js:5079:20
    at symbolIterator (/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/neo-async/async.js:3485:9)
    at done (/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/neo-async/async.js:3527:9)
    at Hook.eval [as callAsync] (eval at create (/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/tapable/lib/Hook.js:18:14)
    at /usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/webpack/lib/Compilation.js:4986:43
    at symbolIterator (/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/neo-async/async.js:3482:9)
-- inner error --
Error: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
  ╷
1 │ @import "invalid";
  │         ^^^^^^^^^
  ╵
  src/styles.scss 1:9  root stylesheet
    at Object.<anonymous> (/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].rules[0].oneOf[0].use[1]!/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[5].rules[0].oneOf[0].use[2]!/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/resolve-url-loader/index.js??ruleSet[1].rules[5].rules[1].use[0]!/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].rules[1].use[1]!/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/src/styles.scss:1:7)
    at /usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/webpack/lib/javascript/JavascriptModulesPlugin.js:441:11
    at Hook.eval [as call] (eval at create (/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1)
    at Hook.CALL_DELEGATE [as _call] (/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/tapable/lib/Hook.js:14:14)
    at /usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/webpack/lib/Compilation.js:5053:39
    at tryRunOrWebpackError (/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/webpack/lib/HookWebpackError.js:83:7)
    at __webpack_require_module__ (/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/webpack/lib/Compilation.js:5051:12)
    at __webpack_require__ (/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/webpack/lib/Compilation.js:5008:18)
    at /usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/webpack/lib/Compilation.js:5079:20
    at symbolIterator (/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/neo-async/async.js:3485:9)

Generated code for /usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].rules[0].oneOf[0].use[1]!/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[5].rules[0].oneOf[0].use[2]!/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/resolve-url-loader/index.js??ruleSet[1].rules[5].rules[1].use[0]!/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].rules[1].use[1]!/usr/local/xxxxxxx/cli-reproductions/showwcase-v14-rc0/src/styles.scss
1 | throw new Error("Module build failed (from ./node_modules/sass-loader/dist/cjs.js):\nSassError: Can't find stylesheet to import.\n  ╷\n1 │ @import \"invalid\";\n  │         ^^^^^^^^^\n  ╵\n  src/styles.scss 1:9  root stylesheet");
```

After
```
$ ng build

./src/styles.scss - Error: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
  ╷
1 │ @import "invalid";
  │         ^^^^^^^^^
  ╵
  src/styles.scss 1:9  root stylesheet

./src/styles.scss - Error: Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
HookWebpackError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
  ╷
1 │ @import "invalid";
  │         ^^^^^^^^^
  ╵
  src/styles.scss 1:9  root stylesheet
```
2022-06-27 09:08:54 -04:00
Alan Agius
4fcfc37cb9 fix(@angular-devkit/build-angular): exit dev-server when CTRL+C is pressed
Since version 4, webpack-dev-server by default will shutdown gracefully. This results in `CTRL+C` needed to be pressed multiple times to exit the process.

See: c76b6d11a3/lib/Server.js (L1801-L1827)

Closes #22216
2022-06-27 09:08:30 -04:00
renovate[bot]
04160c58ce build: update all non-major dependencies 2022-06-27 08:15:08 -04:00
Alan Agius
1fc7d4f56b fix(@angular-devkit/build-angular): ignore supported browsers during i18n extraction
Since extraction doesn't work on the browser we can ignore the `supportedBrowsers` configuration during message extraction.

Closes #23420
2022-06-23 09:56:59 -07:00
Alan Agius
a7709b718c feat(@angular-devkit/build-angular): add externalDependencies to the esbuild browser builder
This commit add a new `externalDependencies` option to the experimental browser builder.

Dependencies listed in this option will not be included in the final bundle, instead the user would need to provide them at runtime using import maps or another method.

Closes #23322
2022-06-21 12:21:53 -07:00
Alan Agius
0d50661fe6 build: add browser-esbuild test infra
This commit adds browser-esbuild infra.
2022-06-21 12:21:53 -07:00
Alan Agius
6677994235 fix(@angular-devkit/build-angular): fix incorrect glob cwd in karma when using --include option
Previously, we amended the project source root to the source root which resulted in an invalid path.

Closes #23396
2022-06-21 11:34:36 -07:00
Alan Agius
0f02b0011b fix(@angular-devkit/build-angular): handle codeCoverageExclude correctly in Windows
Previously, `codeCoverageExclude` didn't work correct on Windows

Closes #23403
2022-06-21 11:26:59 -07:00
Charles Lyding
b06ae55140 feat(@angular-devkit/build-angular): add service worker support to experimental esbuild builder
Service worker augmentation of an application is now supported when using the experimental
`browser-esbuild` application builder. Both the `serviceWorker` and `ngswConfigPath` options
are now available for use.
The implementation leverages the `augmentAppWithServiceWorker` internal function that is used
by the Webpack-based builder. This function currently reads the application files from the
filesystem after all the application files are written. With the `browser-esbuild`builder, all
application files are available in-memory. This can allow a future version of the service worker
code to avoid additional file access and further improve build time performance when using a
service worker. Future work will investigate the creation of an `augmentAppWithServiceWorker`
variant that supports accessing these in-memory files.
2022-06-14 19:47:12 +02:00
Charles Lyding
7431d1c256 refactor(@angular-devkit/build-angular): assert catch clause variable type before usage
Prepares the `@angular-devkit/build-angular` package for the eventual change of enabling the
TypeScript `useUnknownInCatchVariables` option. This option provides additional
code safety by ensuring that the catch clause variable is the proper type before
attempting to access its properties. Similar changes will be needed in the other
packages in the repository prior to enabling `useUnknownInCatchVariables`.
2022-06-14 11:28:21 +02:00
Renovate Bot
aa5ff8d860 build: update dependency source-map-loader to v4 2022-06-13 09:43:29 +02:00
Alan Agius
1f66edebcc fix(@angular-devkit/build-angular): replace fallback locale for en-US
Pre version 14, the locale for `en-US` was `en-US-POSIX`. now in version 14, this has changed to `en-US`.

List of all available locales 7033ea9b03/cldr-json/cldr-core/availableLocales.json (L64)

Closes #23334
2022-06-09 10:41:27 -04:00
Alan Agius
f0a0b08457 fix(@angular-devkit/build-angular): log modified and removed files when using the verbose option
With this change we print out the modified and removed files when running a build in verbose mode. This can be useful to debug builds that rebuilds multiple times without an apparent file change.
2022-06-08 12:10:56 -04:00
Renovate Bot
45b6954174 build: update angular 2022-06-03 15:15:13 -04:00
Renovate Bot
450074ff69 build: update all non-major dependencies 2022-06-03 14:54:21 -04:00
Charles Lyding
08bc86706a refactor(@angular-devkit/build-angular): remove unneeded TypeScript transforms with esbuild
Only the `replaceBootstrap` TypeScript transform is needed with the `browser-esbuild` builder.
The `replaceBootstrap` transform converts the default generated JIT bootstrap call into an AOT
bootstrap call within an application. The other transforms were used to remove the development
and JIT related metadata from the AOT compiler generated code. However, with the esbuild based
build pipeline, these will be automatically removed without the need for additional transforms
via the earlier usage of the `ngJitMode` and `ngDevMode` defines.
2022-06-03 14:51:05 -04:00
Alan Agius
9301699f7a fix(@angular-devkit/build-angular): replace dev-server socket path from /ws to /ng-cli-ws
In some cases `/ws` caused conflicts with local websocket connections. Hence we change the dev-server web socket path to something more specific to the Angular CLI.

Closes #23260
2022-06-02 13:01:28 -07:00
Renovate Bot
807444897f build: update all non-major dependencies 2022-06-01 08:44:38 -07:00
Alan Agius
ee2e75610b fix(@angular-devkit/build-angular): detect tailwind.config.cjs as valid tailwindcss configuration
`tailwind.config.cjs` is a valid tailwindcss configuration file as it's listed in 8845d112fb/src/util/resolveConfigPath.js (L46-L52) as such we should also take this filename into consideration.

Closes #23236
2022-05-27 14:08:47 -04:00
Renovate Bot
fb6ba6748c build: update all non-major dependencies 2022-05-26 11:39:17 -07:00
Charles Lyding
cba5f6c1bb fix(@angular-devkit/build-angular): add es2015 exports package condition to browser-esbuild
The `es2015` exports package condition is used by `rxjs` to allow bundlers to use the ES2015-based
ESM code instead of the default of ES5-based ESM code. The ES5-based ESM code is larger in size
and harder to optimize due to the downlevelled classes. This change results in a ~5Kb size reduction
for the main bundle of a new application (129920 -> 124183).
2022-05-26 11:37:06 -07:00
Renovate Bot
10077bec2c build: update dependency sass-loader to v13 2022-05-24 12:33:45 -07:00
Alan Agius
cd2250fe23 fix(@angular-devkit/build-angular): downlevel libraries based on the browserslist configurations
There is no standard for library authors to ship their library in different ES versions, which can result in vendor libraries to ship ES features which are not supported by one or more browsers that the user's application supports.

With this change, we will be downlevelling libraries based on the list of supported browsers which is configured in the browserslist configuration. Previously, we only downlevelled libraries when targeting ES5.

The TypeScript target option will not effect how the libraries get downlevelled.

Closes #23126
2022-05-24 10:02:17 -07:00
Renovate Bot
790a1711bf build: update all non-major dependencies 2022-05-24 09:59:55 -07:00
Alan Agius
432599515d fix(@angular-devkit/build-angular): better handle Windows paths in esbuild experimental builder
With this change we handle several esbuild path issues in Windows.

Closes #23154
2022-05-24 09:57:43 -07:00
Renovate Bot
a7d97c2698 build: update dependency stylus-loader to v7 2022-05-23 10:12:07 -07:00
Alan Agius
076b601c23 fix(@angular-devkit/build-angular): close dev-server on error
When running protractor, previously we didn't close the dev-server correctly when there was an error which caused the process to keep running following https://github.com/angular/angular-cli/pull/23166
2022-05-23 10:09:39 -07:00
Alan Agius
6cbb9413d0 fix(@angular-devkit/build-angular): add debugging and timing information in JavaScript and CSS optimization plugins
This can be useful to debug slow builds.

Example of output
```
LOG from build-angular.JavaScriptOptimizerPlugin
<t> optimize asset: runtime.ad5c30339e926c89.js: 221.959564 ms
<t> optimize asset: polyfills.ec3ffae5bac27204.js: 1071.080092 ms
<t> optimize asset: main.aa8a15155ca2133f.js: 3391.588635 ms
<t> optimize js assets: 3483.799739 ms

LOG from build-angular.CssOptimizerPlugin
<t> optimize asset: styles.d251c5bf54715558.css: 26.569907 ms
<t> optimize css assets: 34.441737 ms
```

```
LOG from build-angular.JavaScriptOptimizerPlugin
<i> polyfills.ec3ffae5bac27204.js restored from cache.
<i> runtime.ad5c30339e926c89.js restored from cache.
<t> optimize asset: main.69fb55a243b46bfa.js: 2618.5191210000003 ms
<t> optimize js assets: 2721.226144 ms

LOG from build-angular.CssOptimizerPlugin
<i> styles.d251c5bf54715558.css restored from cache.
<t> optimize css assets: 12.149169 ms
```
2022-05-20 11:40:36 -07:00
Renovate Bot
1140d73e15 build: update dependency postcss-loader to v7 2022-05-20 11:20:58 -07:00
Renovate Bot
688e32cd3d build: update dependency sass to v1.52.0 2022-05-20 11:20:41 -07:00
Renovate Bot
469d9ec246 build: update dependency copy-webpack-plugin to v11 2022-05-20 11:20:27 -07:00
Renovate Bot
92d365b879 build: update dependency less-loader to v11 2022-05-19 15:02:39 -07:00
Renovate Bot
0fc1c33a7c build: update all non-major dependencies 2022-05-19 15:00:48 -07:00
Alan Agius
b71608195b fix(@angular-devkit/build-angular): close compiler on Karma exit
The webpack compiler was never closed which caused Webpack's shutdown hook c71832f3a9/packages/angular_devkit/build_angular/src/webpack/configs/styles.ts (L113-L114) to never be called and in turn caused the Sass workers never to be termined.
2022-05-18 12:46:05 -04:00
Charles Lyding
b867714c3d build: update peer dependencies to support unreleased 14.1.x prerelease snapshots 2022-05-18 09:36:39 -04:00
Renovate Bot
9fd042dcce build: update all non-major dependencies 2022-05-16 09:13:32 -04:00
Renovate Bot
4be7cdce82 build: update all non-major dependencies 2022-05-12 09:43:13 -04:00