You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 Closeangular#55699
Copy file name to clipboardExpand all lines: adev/src/content/tools/cli/esbuild.md
+37-22Lines changed: 37 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Getting started with the Angular CLI's new build system
1
+
# Migrating to the new build system
2
2
3
3
In v17 and higher, the new build system provides an improved way to build Angular applications. This new build system includes:
4
4
@@ -20,18 +20,50 @@ New applications will use this new build system by default via the `application`
20
20
21
21
## For existing applications
22
22
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-codelanguage="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.
24
56
Both options are considered stable and fully supported by the Angular team.
25
57
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.
26
58
27
59
- 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.
28
60
- 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.
29
61
30
62
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.
32
64
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.
33
65
34
-
###Using the `browser-esbuild` builder
66
+
#### Manual migration to the compatibility builder
35
67
36
68
A builder named `browser-esbuild` is available within the `@angular-devkit/build-angular` package that is present in an Angular CLI generated application.
37
69
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.
61
93
...
62
94
</docs-code>
63
95
64
-
###Using the `application` builder
96
+
#### Manual migration to the new`application` builder
65
97
66
98
A builder named `application` is also available within the `@angular-devkit/build-angular` package that is present in an Angular CLI generated application.
67
99
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
117
149
The `ng update` process will automatically remove usages of the `@nguniversal` scope packages where some of these builders were previously located.
118
150
The new `@angular/ssr` package will also be automatically added and used with configuration and code being adjusted during the update.
119
151
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-codelanguage="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.
0 commit comments