just-jeb / angular-builders

Angular build facade extensions (Jest and custom webpack configuration)
MIT License
1.14k stars 199 forks source link

custom-webpack:browser build failed @angular18:Schema validation failed.....: Data path "" must have required property 'main' #1831

Open hauxsoft opened 1 month ago

hauxsoft commented 1 month ago

Describe the Bug

I created a new ng project by @angular/cli(v18.1.0),and executed npm i -D @angular-builders/custom-webpack to install @angular-builders/custom-webpack 18.0.0。

Then I reset angular.json content, set project.[myAppName].architect.builder = "@angular-builders/custom-webpack:browser", accroding custom-webpack README.md

After all, I runned cmd ng build to build project, but got the following error response in cmd terminal : Error: Schema validation failed with the following errors: Data path "" must have required property 'main'.

Enviroment

"@angular-builders/custom-webpack": "^18.0.0", "@angular-devkit/build-angular": "^18.1.0", "@angular/cli": "^18.1.0", "node js": "22.0.0",

Expected Behavior

repair the bug in angular18, thanks.

just-jeb commented 1 month ago

Most likely you have some issue with dependencies (also known as dependency hell). You can check it by yarn why command (or its NPM alternative). Try to delete the lock file and node_modules and install the deps again. If that doesn't help then check that all the Angular libraries have a matching major version (in your case 18).

Anyways, the examples in this repo run just fine, so it's very unlikely the issue is with the package itself.

IsakEriksson commented 1 month ago

Just out of curiosity, did you check that you have the correct browser/main property in build.options? I got the same error when I used build.options.browser and should have used build.options.main.

manuelhumanescabrera commented 1 month ago

In Angular v17.3.7 and custom-webpack v17.0.2 im facing the same problem, when i changed browser to main in the angular.json file i had now another error: Data path "/serviceWorker" must be boolean.. That looks like the schema validation is not the same used by angular-devkit on the same version.

iamishver commented 1 month ago

I am facing the same issue.....

just-jeb commented 1 month ago

Please provide a clean reproduction. Otherwise I won’t be able to help.

iamishver commented 1 month ago

Install the Angular 18.1.1 and try to set up the .env configuration. you will find the issue.

Older angular versions use "main" as a configuration to specify the entry point of your application.

In the latest angular version, it is changed as "browser" to specify the entry point of your application,

image

just-jeb commented 1 month ago

Please provide a link to a minimal repository with clean reproduction.

isurendrasingh commented 3 weeks ago

Angular team made some changes related to builder. The default will be application builder for newly generated applications (both v18@latest & v17@latest).

New applications will use this new build system by default via the application builder. doc.

Since @angular-builders/custom-webpack provides [browser|server|karma|dev-server|extract-i18n] builders and not application builder, the schema validation fails during serve or build step.