Skip to content

Commit db8fb02

Browse files
clydinatscott
authored andcommitted
docs: initial update of application builder migration instructions for v18 (angular#55699)
The application migration instructions and information page now contains updated information related to the v18 release. This includes a reordering of the migration section to mention the automatic migration first as well as mention that `ng update` will now ask to perform the migration for v18. PR Close angular#55699
1 parent eb31f2c commit db8fb02

File tree

1 file changed

+37
-22
lines changed

1 file changed

+37
-22
lines changed

adev/src/content/tools/cli/esbuild.md

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Getting started with the Angular CLI's new build system
1+
# Migrating to the new build system
22

33
In v17 and higher, the new build system provides an improved way to build Angular applications. This new build system includes:
44

@@ -20,18 +20,50 @@ New applications will use this new build system by default via the `application`
2020

2121
## For existing applications
2222

23-
For existing projects, you can opt-in to use the new builder on a per-application basis with two different options.
23+
Both automated and manual procedures are available dependening on the requirements of the project.
24+
Starting with v18, the update process will ask if you would like to migrate existing applications to use the new build system via the automated migration.
25+
26+
HELPFUL: Remember to remove any CommonJS assumptions in the application server code if using SSR such as `require`, `__filename`, `__dirname`, or other constructs from the [CommonJS module scope](https://nodejs.org/api/modules.html#the-module-scope). All application code should be ESM compatible. This does not apply to third-party dependencies.
27+
28+
### Automated migration (Recommended)
29+
30+
The automated migration will adjust both the application configuration within `angular.json` as well as code and stylesheets to remove previous Webpack-specific feature usage.
31+
While many changes can be automated and most applications will not require any further changes, each application is unique and there may be some manual changes required.
32+
After the migration, please attempt a build of the application as there could be new errors that will require adjustments within the code.
33+
The errors will attempt to provide solutions to the problem when possible and the later sections of this guide describe some of the more common situations that you may encounter.
34+
When updating to Angular v18 via `ng update`, you will be asked to execute the migration.
35+
This migration is entirely optional for v18 and can also be run manually at anytime after an update via the following command:
36+
37+
<docs-code language="shell">
38+
39+
ng update @angular/cli --name use-application-builder
40+
41+
</docs-code>
42+
43+
The migration does the following:
44+
45+
* Converts existing `browser` or `browser-esbuild` target to `application`
46+
* Removes any previous SSR builders (because `application` does that now).
47+
* Updates configuration accordingly.
48+
* Merges `tsconfig.server.json` with `tsconfig.app.json` and adds the TypeScript option `"esModuleInterop": true` to ensure `express` imports are [ESM compliant](#esm-default-imports-vs-namespace-imports).
49+
* Updates application server code to use new bootstrapping and output directory structure.
50+
* Removes any Webpack-specific builder stylesheet usage such as the tilde or caret in `@import`/`url()` and updates the configuration to provide equivalent behavior
51+
* Converts to use the new lower dependency `@angular/build` Node.js package if no other `@angular-devkit/build-angular` usage is found.
52+
53+
### Manual migration
54+
55+
Additionally for existing projects, you can manually opt-in to use the new builder on a per-application basis with two different options.
2456
Both options are considered stable and fully supported by the Angular team.
2557
The choice of which option to use is a factor of how many changes you will need to make to migrate and what new features you would like to use in the project.
2658

2759
- The `browser-esbuild` builder builds only the client-side bundle of an application designed to be compatible with the existing `browser` builder that provides the preexisting build system. It serves as a drop-in replacement for existing `browser` applications.
2860
- The `application` builder covers an entire application, such as the client-side bundle, as well as optionally building a server for server-side rendering and performing build-time prerendering of static pages.
2961

3062
The `application` builder is generally preferred as it improves server-side rendered (SSR) builds, and makes it easier for client-side rendered projects to adopt SSR in the future.
31-
However it requires a little more migration effort, particularly for existing SSR applications.
63+
However it requires a little more migration effort, particularly for existing SSR applications if performed manually.
3264
If the `application` builder is difficult for your project to adopt, `browser-esbuild` can be an easier solution which gives most of the build performance benefits with fewer breaking changes.
3365

34-
### Using the `browser-esbuild` builder
66+
#### Manual migration to the compatibility builder
3567

3668
A builder named `browser-esbuild` is available within the `@angular-devkit/build-angular` package that is present in an Angular CLI generated application.
3769
You can try out the new build system for applications that use the `browser` builder.
@@ -61,7 +93,7 @@ Changing the `builder` field is the only change you will need to make.
6193
...
6294
</docs-code>
6395

64-
### Using the `application` builder
96+
#### Manual migration to the new `application` builder
6597

6698
A builder named `application` is also available within the `@angular-devkit/build-angular` package that is present in an Angular CLI generated application.
6799
This builder is the default for all new applications created via `ng new`.
@@ -117,23 +149,6 @@ The `application` builder now provides the integrated functionality for all of t
117149
The `ng update` process will automatically remove usages of the `@nguniversal` scope packages where some of these builders were previously located.
118150
The new `@angular/ssr` package will also be automatically added and used with configuration and code being adjusted during the update.
119151
The `@angular/ssr` package supports the `browser` builder as well as the `application` builder.
120-
To convert from the separate SSR builders to the integrated capabilities of the `application` builder, run the experimental `use-application-builder` migration.
121-
122-
<docs-code language="shell">
123-
124-
ng update @angular/cli --name use-application-builder
125-
126-
</docs-code>
127-
128-
The migration does the following:
129-
130-
* Converts existing `browser` or `browser-esbuild` target to `application`
131-
* Removes any previous SSR builders (because `application` does that now).
132-
* Updates configuration accordingly.
133-
* Merges `tsconfig.server.json` with `tsconfig.app.json` and adds the TypeScript option `"esModuleInterop": true` to ensure `express` imports are [ESM compliant](#esm-default-imports-vs-namespace-imports).
134-
* Updates application server code to use new bootstrapping and output directory structure.
135-
136-
HELPFUL: Remember to remove any CommonJS assumptions in the application server code such as `require`, `__filename`, `__dirname`, or other constructs from the [CommonJS module scope](https://nodejs.org/api/modules.html#the-module-scope). All application code should be ESM compatible. This does not apply to third-party dependencies.
137152

138153
## Executing a build
139154

0 commit comments

Comments
 (0)