2768 Commits

Author SHA1 Message Date
Charles Lyding
0ac5f27146 refactor(@angular-devkit/build-angular): support in-memory results for esbuild builder
To provide support for development server integration, the esbuild-based builder can now
be setup to provide in-memory file results at the completion of a build.  This applies to
both watch and non-watch modes. The result output object structure is not currently considered
part of the public API and is currently only intended to be used by other builders within the
package.
2023-03-27 13:43:22 +00:00
Alan Agius
c9e84d0243 feat(@schematics/angular): remove generation of BrowserModule.withServerTransition
This commit removes generation of `.withServerTransition` in the universal schematic as is deprecated.

 DEPRECATED: the `app-id` option in the app-shell and universal schematics has been deprecated without replacement. See: https://github.com/angular/angular/pull/49422 for more information about the rational of this change.
2023-03-24 20:37:32 +00:00
Alan Agius
428fc0f4b2 build: update ng-packagr to 16.0.0-next.2 2023-03-24 18:31:29 +00:00
cexbrayat
202e9a50f6 fix(@schematics/angular): remove compileComponents from component test schematic
`compileComponents` is not necessary when using the CLI (as the templates are inlined) and just adds boilerplate code. So we can remove it from the test schematic and make it independent from `async/await` (only place we would have it in the CLI generated code, and in most Angular apps).
2023-03-24 18:30:26 +00:00
Charles Lyding
52969db6bd feat(@angular-devkit/build-angular): initial tailwindcss support for CSS in esbuild builder
When using the experimental esbuild-based browser application builder, CSS stylesheets will
now be processed by tailwindcss if a tailwind configuration file is present and the `tailwindcss`
package has been installed in the project. This provides equivalent behavior to the use of tailwind
with the current default Webpack-based build system. Currently, only CSS stylesheets are processed.
Preprocessor support including Sass and Less will be added in a future change.
2023-03-22 18:23:54 +00:00
Angular Robot
3b815e168a build: update all non-major dependencies 2023-03-21 17:24:06 +00:00
Charles Lyding
78239901bc refactor(@angular-devkit/build-angular): consolidate result file writes in esbuild builder
As a preparation step to allow for in-memory build outputs to support the development server,
The output result files of the build are now written to the file system in one location. This
includes the generated files from the bundling steps as well as any assets and service worker
files.
2023-03-21 17:21:52 +00:00
Kristiyan Kostadinov
ff5ebf9b12 feat(@angular-devkit/build-angular): add CSP support for inline styles
Companion change to https://github.com/angular/angular/pull/49444. Adds an HTML processor that finds the `ngCspNonce` attribute and copies its value to any inline `style` tags in the HTML. The processor runs late in the processing pipeline in order to pick up any `style` tag that might've been added by other processors (e.g. critical CSS).
2023-03-20 18:24:31 +00:00
Kristiyan Kostadinov
5a171ddff6 build: update to TypeScript 5 and drop support for TypeScript 4.8
Bumps up the dev dependency to TS 5 and narrows the required version to exclude 4.8.

BREAKING CHANGE:
* TypeScript 4.8 is no longer supported.
2023-03-17 13:15:52 +00:00
Angular Robot
c90e7c7c33 build: update all non-major dependencies 2023-03-16 08:53:12 +00:00
Angular Robot
0082446375 build: update all non-major dependencies 2023-03-15 09:27:35 +00:00
Charles Lyding
f04859d161 feat(@angular-devkit/build-angular): initial autoprefixer support for CSS in esbuild builder
When using the experimental esbuild-based browser application builder, CSS stylesheets
will now be processed by the postcss autoprefixer plugin. The autoprefixer plugin will only
be used if the browsers provided by browserslist require prefixes to be added. This avoids
unnecessary stylesheet parsing and processing if no additional prefixes are needed.
Currently, only CSS stylesheets are processed. Preprocessor support including Sass and Less
will be added in a future change.
2023-03-15 09:27:18 +00:00
Alan Agius
2908020601 feat(@angular-devkit/build-angular): support standalone app-shell generation
This commit adds support for generating an app-shell for a standalone application.

The `main.server.ts`, will need to export a bootstrapping function that returns a `Promise<ApplicationRef>`.

Example
```ts
export default () => bootstrapApplication(AppComponent, {
  providers: [
    importProvidersFrom(ServerModule),
    provideRouter([{ path: 'shell', component: AppShellComponent }]),
  ],
});
```
2023-03-14 12:59:28 +00:00
Alan Agius
04274afc15
fix(@angular-devkit/build-angular): set public class fields as properties (#24849)
* fix(@angular-devkit/build-angular): set public class fields as properties

Configure Babel to use `setPublicClassFields: true`. As when shipping Angular packages without `"useDefineForClassFields": false` will increase the bundle size of an ng-new app
by ~2Kb when `useDefineForClassFields`  is not false. due to the additional `_defineProperty`, which will be added on every class property.

See: https://babeljs.io/docs/babel-plugin-proposal-class-properties

* fixup! fix(@angular-devkit/build-angular): set public class fields as properties

Co-authored-by: Charles <19598772+clydin@users.noreply.github.com>

---------

Co-authored-by: Charles <19598772+clydin@users.noreply.github.com>
2023-03-14 07:37:57 +00:00
Angular Robot
5b62fd1045 build: update all non-major dependencies 2023-03-14 07:37:27 +00:00
Charles Lyding
afc8704623 test(@angular-devkit/build-angular): add esbuild test for TS resolveJsonModule option
The experimental esbuild-based browser application builder now contains a test to ensure
that the TypeScript `resolveJsonModule` option works as expected.
2023-03-10 21:02:57 +00:00
Alan Agius
4d82e0d104 fix(@angular-devkit/build-angular): correct wrap ES2022 classes with static properties
Prior to this commit, we only wrapped classes with static properties that were marked with `/*@__PURE__*/` comment due to a bug in the `adjust-static-class-members` Babel plugin were we did not call the `Identifier` name text to the `canWrapProperty` function.
2023-03-10 14:41:23 +00:00
Angular Robot
56ab513273 build: update all non-major dependencies 2023-03-09 22:54:49 +00:00
Charles Lyding
f2cba37327 refactor(@angular-devkit/build-angular): move dev-server builder logic out of index file
The `index.ts` file for the `dev-server` builder was becoming quite large and it was not
obvious what was exported for external usage and what was exported to support testing.
This change also allows for future extension of the development server without bringing in
all of the Webpack-specific functionality.
2023-03-07 19:54:47 +00:00
Alan Agius
3978891a46 fix(@angular-devkit/build-angular): build optimizer support for non spec-compliant ES2022 class static properties
The build optimizer's static field pass will now additionally wrap classes that contain side effect free TypeScript ES2022 static class properties.

This is needed to update APF to ship ES2022, which have `useDefineForClassFields` set to `false`.
2023-03-07 15:35:05 +00:00
Angular Robot
31d35b4daf build: update all non-major dependencies 2023-03-07 14:16:21 +00:00
Kristiyan Kostadinov
f3070f2e93 build: update to TypeScript 5.0
Updates the repo to TypeScript 5.0.0-beta. The remaining usages in tests and schematics will be updated once the 5.0 final version is released.
2023-03-02 18:59:49 +00:00
Alan Agius
a99018cd7b refactor(@angular-devkit/build-angular): remove deprecated outputPaths and outputPath Builder output
Remove the deprecated `outputPath` and `outputPaths` from the server and browser builder.

BREAKING CHANGE:

Deprecated `outputPath` and `outputPaths` from the server and browser builder have been removed from the builder output. Use `outputs` instead.

Note: this change does not effect application developers.
2023-02-24 19:22:59 +00:00
Alan Agius
d4c450829d fix(@angular-devkit/build-angular): improve parsing of error messages
Webpack errors can sometimes be several hundred of thousands of characters long as it may contain the entire bundle. This can cause a ReDoS. This change improves the way we parse and remove stack traces from error messages.

Closes #24771
2023-02-24 19:13:16 +00:00
Angular Robot
34b3982ddf build: update all non-major dependencies 2023-02-23 11:49:53 +00:00
Alan Agius
759ae92aaa fix(@angular-devkit/build-angular): update peer dependencies to support version 16
This commit fixes the peer deps to support version 16.
2023-02-23 10:26:07 +00:00
Angular Robot
b564b9afb8 build: update all non-major dependencies 2023-02-22 13:06:18 +00:00
Charles Lyding
4c53c8f274 test(@angular-devkit/build-angular): additional unit tests for esbuild builder
The following unit tests have been ported over to test the experimental esbuild-based
browser application builder:
* `baseHref` option
* `crossOrigin` option
* TypeScript path mapping behavior
2023-02-21 10:02:52 +00:00
Angular Robot
54cc8d4e7d build: update all non-major dependencies 2023-02-21 10:01:33 +00:00
Angular Robot
15fdb2a20c build: update all non-major dependencies 2023-02-17 15:11:36 +00:00
Charles Lyding
2435b46560 fix(@angular-devkit/build-angular): allow empty scripts to be optimized
When using the internal JavaScript optimizer plugin for Webpack with an
empty script file provided via the `scripts` option, the build would fail.
This was because of a safety check that was checking whether the terser
result was falsy. Since an empty string is considered falsy, the build
considered the result to be an error. The safety check now will only trigger
if the terser result is not a string value to avoid this case.
2023-02-16 19:11:34 +00:00
Alan Agius
8095268fa4 build: update to rxjs 7
G3 is now using RXJS version 7 which makes it possible for the CLI to also be updated to RXJS 7.

NB: this change does not remove all usages of the deprecated APIs.

Closes #24371
2023-02-16 14:59:40 +00:00
Alan Agius
f6624b974f feat(@angular-devkit/core): update SchemaRegistry compile to return Promise
Use promise based methods to reduce RXJS usage and boiler-platting.

BREAKING CHANGE: Several changes to the `SchemaRegistry`.
- `compile` method now returns a `Promise`.
- Deprecated `flatten` has been removed without replacement.
2023-02-15 21:03:30 +00:00
Angular Robot
70fcd37b58 build: update all non-major dependencies 2023-02-15 15:28:49 +00:00
Alan Agius
d9fed6a517 build: update parse5-html-rewriting-stream to version 7
This fixes an issue were the HTML is truncated if it's 128Kb or greater.

Closes #24707
2023-02-14 15:23:09 +00:00
Charles Lyding
f91696063c test(@angular-devkit/build-angular): port additional unit tests to esbuild builder
The following unit tests have been ported over to test the experimental esbuild-based
browser application builder:
* `extractLicenses` option
* `main` option
* `optimization.styles.inlineCritical` option
* `styles` option
* `subresourceIntegrity` option

Several individual tests involving file output logging have been temporarily disabled
until build and file output logging has been implemented for the builder.
2023-02-14 15:05:11 +00:00
Alan Agius
1e52863262 perf(@angular-devkit/build-angular): reduce rebuilt times when using the scripts option
In some cases, using the `scripts` option caused a lot of `DescriptionFileUtils.loadDescriptionFile` calls which caused a bottleneck during build times.

The why to this is still unknown, but a workaround is to use the resolver from the Webpack compilation instead of the compiler.

Closes #24634
2023-02-14 14:59:37 +00:00
Angular Robot
d439cb9727 build: update all non-major dependencies 2023-02-13 14:16:12 +00:00
Charles Lyding
421417a36b fix(@angular-devkit/build-angular): avoid CommonJS warning for zone.js in esbuild
The `zone.js` package is currently built into a module structure form that resembles
UMD-like output. This causes the CommonJS checker within the experimental esbuild-based
browser application builder to issue a warning for `zone.js` usage. Until the packaging
of `zone.js` is updated to become fully ESM, the `zone.js` package is automatically allowed
when performing the CommonJS module check.
2023-02-13 14:14:41 +00:00
Angular Robot
2a42f24ced build: update all non-major dependencies to v0.17.7 2023-02-10 20:39:11 +00:00
Alan Agius
d3f255087f fix(@angular-devkit/build-angular): correctly copy safety-worker.js contents
Previously, `safety-worker.js` and `worker-basic.min.js` contained incorrect data due to an incorrect path.

Closes #24678
2023-02-10 20:18:17 +00:00
Charles Lyding
8356240dda fix(@angular-devkit/build-angular): use babel default export helper in build optimizer
Within the build optimizer's static member optimization pass, a class that is directly
default exported must be split into two statements: the class declaration and the
default export. This is because the pass can wrap classes in a pure annotated IIFE which
results in a variable declaration replacement and variable declarations can not be directly
default exported. Previously, the pass did this splitting manually but this was causing
later babel plugins to fail. In addition to updating the AST in this case, scoping information
also needed to be updated. To support this, a babel helper package is now used that handles
the details of the statement split operation.
2023-02-10 20:16:20 +00:00
Alan Agius
c65b026e2f fix(@angular-devkit/build-angular): update the ECMA output warning message to be more actionable
Update the `TypeScript compiler options "target" and "useDefineForClassFields" are set to "ES2022"` warning message to be more actionable.

Closes: #24697
2023-02-10 20:13:35 +00:00
Angular Robot
4c69b27816 build: update all non-major dependencies 2023-02-08 19:11:07 +00:00
Charles Lyding
a658464f71 test(@angular-devkit/build-angular): enable inlineStyleLanguage unit tests for esbuild
With the additional of JIT mode and initial Less stylesheet support, the unit tests for the
`inlineStyleLanguage` build option can now be enabled for the experimental esbuild-based
browser application builder.
2023-02-08 19:10:30 +00:00
Charles Lyding
01b3bcf898 feat(@angular-devkit/build-angular): add Less stylesheet support to experimental esbuild-based builder
When using the experimental esbuild-based browser application builder, stylesheets written in the Less
stylesheet language can now be used throughout an application. The support allows Less stylesheets to
be used in all locations where CSS and/or Sass can be used. This includes global stylesheets and both
inline and external component styles. When using inline component styles, the `inlineLanguageStyle`
build option must be set to `less`.
Currently, import resolution within a Less stylesheet is limited to default Less behavior which does not
include full node package resolution. Full resolution behavior will be added in a future change.
2023-02-08 19:10:30 +00:00
Angular Robot
56423f0a37 build: update all non-major dependencies 2023-02-07 19:30:22 +00:00
Charles Lyding
bfc0facedd fix(@angular-devkit/build-angular): build optimizer support for spec-compliant downlevel class properties
The build optimizer's static class field pass will now additionally wrap
classes that contain side effect free class properties. This allows optimizers and
bundlers further along in the build pipeline to downlevel that class properties while
still retaining the ability to tree-shake the class if unused. The class properties
may need to be downleveled for a variety of reasons such as lack of browser support,
browser bugs with certain code structures, or to ensure spec-compliant runtime behavior.
2023-02-07 19:29:43 +00:00
Charles Lyding
6cc7459289 test(@angular-devkit/build-angular): port several unit tests to esbuild builder
The following unit tests have been ported over to test the experimental esbuild-based
browser application builder:

* `assets` option
* `outputHashing` option
* browser support behavior (`browserslist`)

Several small modifications were necessary to accommodate output file differences such
as no runtime chunk. Additionally, two tests are temporarily disabled for the `outputHashing`
tests pending implementation in the builder. These tests are the same stylesheet resource handling
file name test and no hashing of non-injected styles test.
2023-02-07 19:29:25 +00:00
Charles Lyding
64d8c473be test(@angular-devkit/build-angular): reduce harness usage of deprecated TestProjectHost
The Builder test harness previously used the deprecated `TestProjectHost` to perform a
variety of file operations during builder unit tests. However, the `TestProjectHost` is
deprecated and uses several layers of rxjs to perform the file operations. The test harness
now uses the Node.js `fs` builtin to directly perform the file operations. This removes several
layers of indirection between the harness and the actual underlying file operations. The removal
of the rxjs operation chaining also reduces stack traces and makes debugging test issues less
complicated.
2023-02-07 19:29:25 +00:00