Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build Angular 17 PWA fails with Data path "/serviceWorker" must be boolean #404

Open
jdalysgfy opened this issue Feb 2, 2024 · 0 comments

Comments

@jdalysgfy
Copy link

jdalysgfy commented Feb 2, 2024

Describe the bug

I am unable to build an Angular 17 Project after adding @angular/pwa followed by @angular-architects/module-federation.

Running ng build after adding @angular-architects/module-federation results in the below error:

Error: Schema validation failed with the following errors:
  Data path "/serviceWorker" must be boolean.

Error seems to be a result of the serviceWorker field in angular.json now accepting string values.

angular.json (Angular 16)

"serviceWorker": true,
"ngswConfigPath": "ngsw-config.json"

angular.json (Angular 17)

"serviceWorker": "ngsw-config.json",

Workaround

Set the serviceWorker value in angular.json back to how it was in Angular 16 PWA:

"serviceWorker": true,
"ngswConfigPath": "ngsw-config.json"

How to Reproduce

ng new Angular17Project
ng add @angular/pwa
ng build
ng add @angular-architects/module-federation
ng build

angular.json (Angular 17)

{
	"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
	"version": 1,
	"newProjectRoot": "projects",
	"projects": {
		"Angular17Project": {
			"projectType": "application",
			"schematics": {
				"@schematics/angular:component": {
					"style": "scss"
				}
			},
			"root": "",
			"sourceRoot": "src",
			"prefix": "app",
			"architect": {
				"build": {
					"builder": "ngx-build-plus:browser",
					"options": {
						"outputPath": "dist/angular17-project",
						"index": "src/index.html",
						"polyfills": [
							"zone.js"
						],
						"tsConfig": "tsconfig.app.json",
						"inlineStyleLanguage": "scss",
						"assets": [
							"src/favicon.ico",
							"src/assets",
							"src/manifest.webmanifest"
						],
						"styles": [
							"src/styles.scss"
						],
						"scripts": [],
						"main": "src/main.ts",
						"extraWebpackConfig": "webpack.config.js",
						"commonChunk": false
					},
					"configurations": {
						"production": {
							"budgets": [
								{
									"type": "initial",
									"maximumWarning": "500kb",
									"maximumError": "1mb"
								},
								{
									"type": "anyComponentStyle",
									"maximumWarning": "2kb",
									"maximumError": "4kb"
								}
							],
							"outputHashing": "all",
							"serviceWorker": "ngsw-config.json",
							"extraWebpackConfig": "webpack.prod.config.js"
						},
						"development": {
							"optimization": false,
							"extractLicenses": false,
							"sourceMap": true
						}
					},
					"defaultConfiguration": "production"
				},
				"serve": {
					"builder": "ngx-build-plus:dev-server",
					"configurations": {
						"production": {
							"buildTarget": "Angular17Project:build:production",
							"extraWebpackConfig": "webpack.prod.config.js"
						},
						"development": {
							"buildTarget": "Angular17Project:build:development"
						}
					},
					"defaultConfiguration": "development",
					"options": {
						"port": 4201,
						"publicHost": "http://localhost:4201",
						"extraWebpackConfig": "webpack.config.js"
					}
				},
				"extract-i18n": {
					"builder": "ngx-build-plus:extract-i18n",
					"options": {
						"buildTarget": "Angular17Project:build",
						"extraWebpackConfig": "webpack.config.js"
					}
				},
				"test": {
					"builder": "@angular-devkit/build-angular:karma",
					"options": {
						"polyfills": [
							"zone.js",
							"zone.js/testing"
						],
						"tsConfig": "tsconfig.spec.json",
						"inlineStyleLanguage": "scss",
						"assets": [
							"src/favicon.ico",
							"src/assets",
							"src/manifest.webmanifest"
						],
						"styles": [
							"src/styles.scss"
						],
						"scripts": []
					}
				}
			}
		}
	}
}

Expected Behaviour

Should build successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant