-
Notifications
You must be signed in to change notification settings - Fork 12k
Description
Command
update
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
I'm unsure if the "update" schematic should leave the same structure and content as if you are creating a new app with Angular CLI v17, or if this should create a different but consistent state, but neither is happening right now. If you have an Angular v16 app, with the default configuration for nguniversal, and you try to update, the application will be broken.
- The update will modify the
server.ts
file with some code that will expect'./src/main.server'
to export a default function called bootstrap. However, the content of'./src/main.server'
is not being updated, and neither is another file being created with the expected content.
If you create a new application using the Angular CLI v17 with the option to use ssr, then a './src/main.server'
will be created with a default export of a bootstrap function.
You can review the same error being reported in this issue angular/angular#52998, however, in the issue is not mentioned that the default project created with Angular CLI v17 does create the expected file.
Minimal Reproduction
Using CLI
npx -p @angular/cli@16 ng new angular-ssr-migrated
npx ng add @nguniversal/express-engine
git commit -m "chore: add nguniversal"
npx ng update @angular/core@17 @angular/cli@17
Exception or Error
No response
Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 17.0.5
Node: 20.9.0
Package Manager: npm 10.1.0
OS: win32 x64
Angular: 17.0.5
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1700.5 (cli-only)
@angular-devkit/build-angular 17.0.5
@angular-devkit/core 17.0.5 (cli-only)
@angular-devkit/schematics 17.0.5
@schematics/angular 17.0.5
rxjs 7.8.1
typescript 5.2.2
zone.js 0.14.2
Anything else relevant?
Update 12/10/23: After some more code digging, it seems like main.server.ts
file should be updated to use a default export.
Update 12/04/23: From the schematic, seems like `isStandalone` is being considered true when evaluated in a migration.
import <% if (isStandalone) { %>bootstrap<% } else { %>AppServerModule<% } %> from './src/main.server';
If isStandalone
is evaluated as false, then the ./src/main.server.ts
file shouldn't be updated.
Even if isStandalone is evaluated as false, the ./src/main.server.ts
file should be updated to use a default export.
Original:
I guess the correct content of the './src/main.server'
file should be:
import { AppServerModule } from './app/app.server.module';
export default AppServerModule;
Considering this don't want to do too many updates to the code.