38 Commits

Author SHA1 Message Date
Charles Lyding
810d213e18 feat(@angular/build): introduce new official build system package
The `@angular/build` package has been introduced to house the esbuild/Vite-based
build system that was newly introduced as stable in v17. The existing
`@angular-devkit/build-angular` package will continue to contain the Webpack-based
build system and to ensure backwards compatibility it will also provide aliases
for the esbuild/Vite-based build system. The changes here are the first stage
of the builder transition and moves the `application` builder into the new package.
The application builder can now be accessed when this package is installed directly
via `@angular/build:application`.

No changes are required for existing projects.
2024-04-18 17:24:23 +02:00
Charles Lyding
dcee94b282 refactor(@angular-devkit/build-angular): split Webpack-specific functionality from i18n option creation
The i18n option creation for a project, which is a combination of the `i18n` project field and the `localize`
build option, is now in a separate file from the Webpack specific i18n configuration setup.
This allows the i18n option creation to be used without loading anything Webpack specific.
2024-04-11 13:40:18 -04:00
Alan Agius
6530aa11be feat(@schematics/angular): replace assets with public directory
The `assets` directory is confusing for the users and commonly users place "assets" which are not meant to be copied but instead processed by the build system. This causes some files both bundled and copied.

With this change we rename the `assets` directory to `public` and also move the `favicon.ico` inside this newly created directory.
2024-03-25 17:10:29 +01:00
Alan Agius
9ca3a54503 feat(@angular-devkit/build-angular): add deployUrl to application builder
This commit adds the deployUrl option ot the application builder.

Closes #26411
2024-03-04 16:24:30 +01:00
Charles "Demurgos" Samborski
fa146b8e86 fix(@angular-devkit/build-angular): allow mts and cts file replacement
Updates the `fileReplacement` pattern to allow `.mts` and `.cts` files.
This enables support for TypeScript files with explicit ESM support.

Closes #27124
2024-02-21 14:20:43 -08:00
Alan Agius
1011f3185d build: update all non-major dependencies 2024-02-02 09:56:02 -05:00
Alan Agius
2b5409b4a5 refactor(@angular-devkit/build-angular): update deleteOutputDir to use FS promise APIs
As per commit title.
2023-11-13 08:29:10 +01:00
Alan Agius
8f9a0d70cd feat(@angular-devkit/build-angular): support standalone apps route discovery during prerendering
This fixes an issue were routes could not be discovered automatically in a standalone application.

This is a total overhaul of the route extraction process as instead of using `guess-parser` NPM package, we now use the Angular Router. This enables a number of exciting possibilities for the future which were not possible before.

# How it works?
The application is bootstrapped and through DI injection we get the injector and router config instance and recursively build the routes tree.
2023-09-18 22:26:06 +02:00
Alan Agius
466d86dc8d refactor(@angular-devkit/build-angular): update code base structure to facilitate future builders
This commit updates the code base structure in preparation for future works.
2023-06-09 16:02:14 +02:00
Alan Agius
a416b4eff5 fix(@angular-devkit/build-angular): provide option to run build-optimizer on server bundles
This commit adds the option to run build-optimizer on the server bundles.

This is needed as in some cases, there can be restrictions on the size of
server bundles that can be executed. One of these cases is CloudFlare workers
 which by default does not work with an `ng-new` application due to the size of the
 bundle mainly due to the retention of the `@angular/compiler`.
2023-04-26 15:58:53 +00:00
Alan Agius
688bb2db7b fix(@angular-devkit/build-angular): display warning when preserveWhitespaces is set in the tsconfig provided to the server builder
This commits add a check to display a warning when `preserveWhitespaces` is configured in `tsconfig.server.json`, as potentially this could cause issue with hydration.
2023-04-19 22:28:09 +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
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
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
f35e9908c0 fix(@angular-devkit/build-angular): print server builder errors and warnings
Previously server builder errors and warnings were not being printed in the console correctly.

Closes #24612
2023-01-26 14:37:38 +00:00
Alan Agius
c29df69546 feat(@angular-devkit/build-angular): add assets option to server builder
This commits adds the `assets` option to the server builder. This can be useful to copy server specific assets such as config files.

Closes #24203
2022-11-18 11:03:15 -08:00
Alan Agius
11bb8ce26f perf(@angular-devkit/build-angular): add vendor chunking to server builder
With this change we add the `vendorChunk` option in the server builder. This option should only be used in development as it is intended to be used to improve the incremental re-build time.

This improves the rebuild time as Webpack will have less modules to analyse during a change in the application. Below, we can see the impact this change has in a `ng new` application.

Without vendor chunking
```
$ ng run ssr-vendor:server:development --watch --no-vendor-chunk
Build at: 2022-11-14T08:42:27.089Z - Hash: 0325905b63e43ddb - Time: 15357ms
Build at: 2022-11-14T08:42:37.565Z - Hash: 05cb180a02524656 - Time: 2498ms
Build at: 2022-11-14T08:42:40.325Z - Hash: c5a6996ed1924088 - Time: 1862ms
Build at: 2022-11-14T08:42:43.043Z - Hash: 92ce99f38a769c19 - Time: 1516ms
```

With vendor chunking
```
$ ng run ssr-vendor:server:development --watch --vendor-chunk
Build at: 2022-11-14T08:43:13.631Z - Hash: 28bdfea879d01a31 - Time: 15561ms
Build at: 2022-11-14T08:43:19.396Z - Hash: cc95e2b6cb403111 - Time: 1705ms
Build at: 2022-11-14T08:43:21.296Z - Hash: 204138490668a16c - Time: 848ms
Build at: 2022-11-14T08:43:23.835Z - Hash: 4fa294b261917944 - Time: 824ms
```
2022-11-15 10:14:02 -08:00
Alan Agius
d754b72d4e fix(@angular-devkit/build-angular): only add @angular/platform-server/init when package is installed.
This commit fixes an issue where `@angular/platform-server/init` was added as an entry-point during the server build even when this was not installed.

Closes #24188
2022-11-07 19:04:26 +01:00
Charles Lyding
717bd03de6 fix(@angular-devkit/build-angular): account for package.json exports fields with CSS import statements
The `postcss-imports` package was previously used to support `@import` within CSS files. Unfortunately,
the package does not account for `package.json` exports fields. This prevents imports defined within that
field from working when used within a build.  The `css-loader` package does provide this functionality and
is now used to provide support for CSS `@import` instead of `postcss-imports`. This change does not affect
preprocessors that provide their own import behavior.
2022-10-14 09:36:08 +02:00
Alan Agius
639a3071c3 refactor: migrate analytics collector to use GA4
This change updates the analytics collector collector to use GA4 instead of UA. The motivation behind this change is that UA will stop collecting data in 2023.

BREAKING CHANGE:

`analyticsSharing` option in the global angular configuration has been
removed without replacement. This option was used to configure the Angular CLI to  access to your own users' CLI usage data.

If this option is used, it can be removed using `ng config --global cli.analyticsSharing undefined`.
2022-10-11 18:52:30 +02:00
Alan Agius
9c13fce162 feat(@angular-devkit/build-angular): remove bundleDependencies from server builder
This commit removes the usages of `bundleDependencies` which does not correctly work as webpack will use `require` to import ESM module since we configure the server bundle to be outputted in CJS. Migrating fully to ESM is also currently not viable due to the lack of support from Domino.
Even if full ESM was possible, using this option would have resulted in a runtime overhead as Angular libraries would be linked during runtime instead of compile time.

BREAKING CHANGE:
The server builder `bundleDependencies` option has been removed. This option was used pre Ivy. Currently, using this option is unlikely to produce working server bundles.

The `externalDependencies` option can be used instead to exclude specific node_module packages from the final bundle.

Closes #23905
2022-09-23 15:41:30 -04:00
Alan Agius
1e5d4a7508 feat(@angular-devkit/build-angular): use Browserslist to determine ECMA output
With this change we reduce the reliance on the TypeScript target compiler option to output a certain ECMA version. Instead we now use the browsers that are configured in the Browserslist configuration to determine which ECMA features and version are needed. This is done by passing the transpiled TypeScript to Babel preset-env.

**Note about useDefineForClassFields**: while setting this to `false` will output JavaScript which is not spec compliant, this is needed because TypeScript introduced class fields many years before it was ratified in TC39. The latest version of the spec have a different runtime behavior to TypeScript’s implementation but the same syntax. Therefore, we opt-out from using upcoming ECMA runtime behavior to better support the ECO system and libraries that depend on the non spec compliant output. One of biggest case is usages of the deprecated `@Effect` decorator by NGRX and potentially other existing code as well which otherwise would cause runtime failures. Dropping `useDefineForClassFields` will be considered in a future major releases. For more information see: https://github.com/microsoft/TypeScript/issues/45995.

BREAKING CHANGE: Internally the Angular CLI now always set the TypeScript `target` to `ES2022` and `useDefineForClassFields` to `false` unless the target is set to `ES2022` or later in the TypeScript configuration. To control ECMA version and features use the Browerslist configuration.
2022-09-21 11:23:35 -04:00
Alan Agius
15d3fc6dc3 feat(@angular-devkit/build-angular): export @angular/platform-server symbols in server bundle
This commit adds an internal file to export needed symbols from `@angular/platform-server` when building a server bundle. This is needed.  This is needed so that DI tokens can be referenced and set at runtime outside of the bundle.

Also, it adds a migration to remove these exports from the users files as otherwise an export collision would occur due to the same symbol being exported multiple times.
2022-09-20 10:24:29 -04:00
Alan Agius
12931ba8c3 refactor(@angular-devkit/build-angular): remove deprecated ES5 support
Remove deprecated support for ES5 output.

BREAKING CHANGE: Producing ES5 output is no longer possible. This was needed for Internet Explorer which is no longer supported. All browsers that Angular supports work with ES2015+
2022-09-16 11:39:02 -07:00
Alan Agius
7f1017e60f refactor(@angular-devkit/build-angular): remove old bundleDependencies enum logic
BREAKING CHANGE: server builder `bundleDependencies` option now only accept a boolean value.
2022-09-08 18:59:26 +02: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
433b6b4931 docs: remove redundant default empty strings values
(cherry picked from commit 3d928c01c8196b1caba7b373eec870540ecda79e)
2022-03-04 16:58:55 +01:00
Charles Lyding
f0daa8c3bf refactor(@angular-devkit/build-angular): remove unneeded JsonObject type casting
The use of the `@angular-devkit/core` `JsonObject` type is no longer needed to satisfy the type requirements of `@angular-devkit/architect` package builder creation functions.
2022-02-25 13:35:14 -05:00
Alan Agius
0a1cd584d8 refactor(@angular-devkit/build-angular): remove deprecated showCircularDependencies browser and server builder option
BREAKING CHANGE:

The deprecated `showCircularDependencies` browser and server builder option has been removed. The recommended method to detect circular dependencies in project code is to use either a lint rule or other external tools.
2022-01-31 11:34:58 -08:00
Alan Agius
6d2087b8f8 fix(@angular-devkit/build-angular): automatically purge stale build cache entries
With every build-angular release, previously created cache entries get stale and are no longer used. This causes the cache to keep growing as older files are not purged.

With this change we automatically purge entries that have been created with older version of build-angular and can no longer be used with the current installed version.

Closes #22323
2022-01-12 09:46:03 -08:00
minijus
cbe028e37c feat(@angular-devkit/build-angular): expose i18nDuplicateTranslation option of browser and server builders
Closes #22201
2022-01-10 16:14:14 -08:00
Alan Agius
d526e87506 refactor(@angular-devkit/build-angular): clean up webpack configurations
With this change we remove the worker and typescript configuration.
2021-11-03 08:23:34 +01:00
Alan Agius
5a2a2fc297 refactor(@angular-devkit/build-angular): unify webpack configurations
With this change we unify most of the webpack configuration into the common configuration. A number of lengthy functions and code portions have been moved into a seperate file to make the configuration easier to follow.
2021-10-28 18:04:57 +02:00
Charles Lyding
2a1f4ee0d8 refactor(@angular-devkit/build-angular): remove unneeded core JsonObject type usage
The architect runtime no longer requires builder options to include the JsonObject in its type definition when calling `createBuilder`. The remaining cases in this package have been removed.
2021-08-10 21:40:57 +02:00
Alan Agius
e95ecb8ab0 feat(@angular-devkit/build-angular): deprecate deployUrl
With this change we deprecate deployUrl which in many case causes unexpected and undesired behaviour. Such as #12322, #21432 and #6666. This is because one of the drawbacks of deploy Url is that this url needs to be injected all over the bundles.

This option was previously introduced to handle application that only assets are hosted on a CDN. This setup is now mostly considered as legacy as it is recommended that the entire application is hosted on a CDN. That said, this legacy behaviour can still be achieved by setting the `baseHref` to the CDN address, while setting the `APP_BASE_HREF` to the application address.

Closes #12322 and closes #6666
2021-08-10 19:17:19 +02:00
Charles Lyding
c4baba4459 refactor(@angular-devkit/build-angular): reduce repeat TypeScript configuration loading
An application's TypeScript configuration was previously being loaded multiple times in several different aspects of the build setup process. These aspects need to access specific compiler options relevant to that particular area of the setup. However, loading the configuration can be expensive due to the process also calculating the root files for the TypeScript compilation which can result in a large amount of file access. To improve the setup performance, the number of times the TypeScript configuration will be loaded has now been reduced with further reductions possible with additional refactorings.
2021-08-09 14:15:13 +02:00
Charles Lyding
3bcb729a33 refactor(@angular-devkit/build-angular): remove unneeded ivy enabled checks
Applications can now only be built with Ivy. However, several checks were still present in the code to determine if Ivy was enabled. Since Ivy is always enabled these checks have since become unused code and can be removed.
2021-08-09 14:15:13 +02:00
Charles Lyding
0afdff028c refactor(@angular-devkit/build-angular): move all builders into a builders subdirectory
All Angular builders are now located within one subdirectory of the `src` directory. This organization provides better discovery of the builders and will allow builder specific code to be stored in a single area.
2021-08-05 06:49:55 +02:00