angular-architects / module-federation-plugin

MIT License
729 stars 197 forks source link

Cannot read properties of undefined (reading 'browserTarget') when trying to remove module federation #631

Closed americoperez49 closed 1 month ago

americoperez49 commented 2 months ago

Hi everyone,

I just finished updating my Angular application to Angular 17.3

I am trying to go through the migration guide.

Upon running the following command: ng g @angular-architects/module-federation:remove --project dexvExtreme

I get the following error: Cannot read properties of undefined (reading 'browserTarget')

Anyone got any suggestions on what could be the issue?

Here is my package.json

{
  "name": "dev-extreme",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --base-href \"/BDT/\" --configuration production",
    "large-serve": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng serve",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "build-themes": "devextreme build",
    "postinstall": "npm run build-themes",
    "run:all": "node node_modules/@angular-architects/module-federation/src/server/mf-dev-server.js"
  },
  "private": true,
  "dependencies": {
    "@angular-architects/module-federation": "^18.0.4",
    "@angular-devkit/architect": "^0.1703.8",
    "@angular-devkit/core": "^17.3.8",
    "@angular-devkit/schematics": "^17.3.8",
    "@angular/animations": "17.3.12",
    "@angular/cdk": "^16.2.14",
    "@angular/common": "17.3.12",
    "@angular/compiler": "17.3.12",
    "@angular/core": "17.3.12",
    "@angular/forms": "17.3.12",
    "@angular/platform-browser": "17.3.12",
    "@angular/platform-browser-dynamic": "17.3.12",
    "@angular/router": "17.3.12",
    "@apollo/client": "^3.11.4",
    "@schematics/angular": "^15.2.11",
    "angular-expressions": "^1.2.1",
    "apollo-angular": "^6.0.0",
    "apollo-link-token-refresh": "^0.7.0",
    "bdt-comm-api": "^4.0.0",
    "devextreme": "^24.1.5",
    "devextreme-angular": "^24.1.5",
    "devextreme-schematics": "^1.0.13",
    "docx": "^5.5.0",
    "docxtemplater": "^3.21.2",
    "exceljs": "^1.15.0",
    "file-saver": "^2.0.5",
    "graphql": "^16.9.0",
    "html2canvas": "^1.0.0-rc.7",
    "js2xmlparser": "^4.0.1",
    "jspdf": "^2.5.1",
    "jspdf-autotable": "^3.8.2",
    "jwt-decode": "^3.1.2",
    "lodash": "^4.17.21",
    "mathjs": "^7.6.0",
    "pizzip": "^3.0.6",
    "rxjs": "~6.6.3",
    "tslib": "^2.0.0",
    "zone.js": "^0.14.10"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^17.3.8",
    "@angular/cli": "^17.3.8",
    "@angular/compiler-cli": "17.3.12",
    "@angular/language-service": "17.3.12",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "^2.0.13",
    "@types/jspdf": "^1.3.3",
    "@types/lodash": "^4.17.5",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "devextreme-cli": "^1.2.14",
    "devextreme-themebuilder": "^24.1.5",
    "jasmine-core": "^5.2.0",
    "jasmine-spec-reporter": "^7.0.0",
    "karma": "^6.3.4",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "^2.0.3",
    "karma-jasmine": "^5.1.0",
    "karma-jasmine-html-reporter": "^2.1.0",
    "ngx-build-plus": "^17.0.0",
    "protractor": "~7.0.0",
    "serve": "11.3.2",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "5.4.5"
  }
}

and my angular.json:

{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
        "devExtreme": {
            "projectType": "application",
            "schematics": {
                "@schematics/angular:component": {
                    "style": "scss",
                    "skipTests": true
                },
                "@schematics/angular:class": {
                    "skipTests": true
                },
                "@schematics/angular:directive": {
                    "skipTests": true
                },
                "@schematics/angular:guard": {
                    "skipTests": true
                },
                "@schematics/angular:module": {},
                "@schematics/angular:pipe": {
                    "skipTests": true
                },
                "@schematics/angular:service": {
                    "skipTests": true
                }
            },
            "root": "",
            "sourceRoot": "src",
            "prefix": "app",
            "architect": {
                "build": {
                    "builder": "ngx-build-plus:browser",
                    "options": {
                        "outputPath": "dist/devExtreme",
                        "index": "src/index.html",
                        "main": "src/main.ts",
                        "polyfills": "src/polyfills.ts",
                        "tsConfig": "tsconfig.app.json",
                        "assets": [
                            "src/favicon.ico",
                            "src/assets",
                            "src/web.config"
                        ],
                        "styles": [
                            "node_modules/devextreme/dist/css/dx.common.css",
                            "src/themes/generated/theme.base.css",
                            "src/themes/generated/theme.additional.css",
                            "src/dx-styles.scss",
                            "src/styles.scss",
                            {
                                "input": "node_modules/devextreme/dist/css/dx.light.css",
                                "bundleName": "generic.light"
                            },
                            {
                                "input": "node_modules/devextreme/dist/css/dx.dark.css",
                                "bundleName": "generic.dark"
                            }
                        ],
                        "scripts": [],
                        "vendorChunk": true,
                        "extractLicenses": false,
                        "buildOptimizer": false,
                        "sourceMap": true,
                        "optimization": false,
                        "namedChunks": true,
                        "extraWebpackConfig": "webpack.config.js",
                        "commonChunk": false
                    },
                    "configurations": {
                        "production": {
                            "fileReplacements": [
                                {
                                    "replace": "src/environments/environment.ts",
                                    "with": "src/environments/environment.prod.ts"
                                }
                            ],
                            "optimization": true,
                            "outputHashing": "all",
                            "sourceMap": false,
                            "namedChunks": false,
                            "extractLicenses": true,
                            "vendorChunk": false,
                            "buildOptimizer": true,
                            "aot": true,
                            "budgets": [
                                {
                                    "type": "initial",
                                    "maximumWarning": "15mb",
                                    "maximumError": "15mb"
                                },
                                {
                                    "type": "anyComponentStyle",
                                    "maximumWarning": "6kb",
                                    "maximumError": "10kb"
                                }
                            ],
                            "extraWebpackConfig": "webpack.prod.config.js"
                        }
                    }
                },
                "serve": {
                    "builder": "ngx-build-plus:dev-server",
                    "options": {
                        "browserTarget": "devExtreme:build",
                        "extraWebpackConfig": "webpack.config.js",
                        "port": 4200,
                        "publicHost": "http://localhost:4200"
                    },
                    "configurations": {
                        "production": {
                            "browserTarget": "devExtreme:build:production",
                            "extraWebpackConfig": "webpack.prod.config.js"
                        }
                    }
                },
                "extract-i18n": {
                    "builder": "ngx-build-plus:extract-i18n",
                    "options": {
                        "browserTarget": "devExtreme:build",
                        "extraWebpackConfig": "webpack.config.js"
                    }
                },
                "test": {
                    "builder": "ngx-build-plus:karma",
                    "options": {
                        "codeCoverage": true,
                        "codeCoverageExclude": [
                            "src/app/accessToken.module.ts",
                            "src/app/app.component.ts",
                            "src/app/menu-utils.ts",
                            "src/app/microfrontends/lookup.service.ts",
                            "src/app/shared/components/side-navigation-menu/side-navigation-menu.component.ts",
                            "src/app/shared/components/user-panel/user-panel.component.ts",
                            "src/app/shared/resolvers/token.resolver.ts",
                            "src/app/shared/services/screen.service.ts"
                        ],
                        "main": "src/test.ts",
                        "polyfills": "src/polyfills.ts",
                        "tsConfig": "tsconfig.spec.json",
                        "karmaConfig": "karma.conf.js",
                        "assets": [
                            "src/favicon.ico",
                            "src/assets"
                        ],
                        "styles": [
                            "src/styles.scss"
                        ],
                        "scripts": [],
                        "extraWebpackConfig": "webpack.config.js"
                    }
                },
                "e2e": {
                    "builder": "@angular-devkit/build-angular:protractor",
                    "options": {
                        "protractorConfig": "e2e/protractor.conf.js",
                        "devServerTarget": "devExtreme:serve"
                    },
                    "configurations": {
                        "production": {
                            "devServerTarget": "devExtreme:serve:production"
                        }
                    }
                }
            }
        }
    }
}
americoperez49 commented 1 month ago

I'm still having issues with this. Can anyone help?

manfredsteyer commented 1 month ago

Thanks for this information.

I just published a new version. can you please update to it and try again?