angular-architects / module-federation-plugin

MIT License
735 stars 203 forks source link

Ng serve issue with Angular new build system and module federation plug in #653

Open muqtharali opened 1 month ago

muqtharali commented 1 month ago

I am using Angular v17 and web pack module federation v17 plug in for micro frontend applications.

I am trying to migrate the existing application to Angular 18 which will use the Angular new build system Application builder.

During Angular 18 migration, getting this message

image

In my existing application, it is using ngx-build-plus builder so it is not migrating to new build system.

"builder": "ngx-build-plus:browser",

So I have migrated module federation to native federation using this migration guide

https://github.com/angular-architects/module-federation-plugin/blob/main/libs/native-federation/docs/migrate.md

After this migration, it is using native-federation builder as shown below

"builder": "@angular-architects/native-federation:build",

But when I run ng serve command getting the below error

**

An unhandled exception occurred: Configuration 'development' is not set in the workspace.

**

Please let me know, if I am doing anything wrong.

Also please let me know the process to migrate existing module federation project to angular v18 new build system.

manfredsteyer commented 1 month ago

Can you please check if your serve and build targets in angular.json have a development configuration?

muqtharali commented 1 month ago

@manfredsteyer Please find angular.json entries for build and serve after migrating to native federation from module federation

"architect": {
                "build": {
                    "builder": "@angular-architects/native-federation:build",
                    "options": {},
                    "configurations": {
                        "production": {
                            "target": "project-name:esbuild:production"
                        },
                        "development": {
                            "target": "project-name:esbuild:development",
                            "development": true
                        }
                    },
                    "defaultConfiguration": "production"
                },
                "serve": {
                    "builder": "@angular-architects/native-federation:build",
                    "options": {
                        "target": "project-name:serve-original:development",
                        "rebuildDelay": 0,
                        "development": true,
                        "port": 0
                    }
                }

            }
muqtharali commented 3 weeks ago

I have replaced "dev" with "development" in angular.json. Now I am getting the below error during ng serve command ( Ng build is working fine)

An unhandled exception occurred: Cannot read properties of undefined (reading 'base')

There is no base baseHref attribute in angular.json with Native federation plug in. I have created new angular 18 project with Native federation which is working fine but getting the above issue during the migration from module federation to native federation.

Anyone is facing similar issue during the migration? Please let me know if there is any solution.