manfredsteyer / ngx-build-plus

Extend the Angular CLI's default build behavior without ejecting, e. g. for Angular Elements
1.19k stars 136 forks source link

Data path "" must have required property 'main'. Angular 17 (maybe sinceAngular 16?) #405

Open brabenetz opened 9 months ago

brabenetz commented 9 months ago

Problem:

A new generated angular-project with angular-cli 17 cannot automatically updated with ng add ngx-build-plus.

It is reproducible with following commands:

# create an angular project with an dummy-app project
npx -p @angular/cli@17 ng new dummy-spa --create-application=false --skip-git --ssr=false
cd dummy-spa
npm run ng -- generate application dummy-app --style=scss --minimal --routing=false --ssr=false
# install ngx-build-plus and patch the dummy-app project
npm install ngx-build-plus@17 --save-dev
npm run ng -- add ngx-build-plus --project=dummy-app --skip-confirmation

Now run npm run build returns the Error Data path "" must have required property 'main' image

Details & manual fix:

Angular 17 uses the "builder": "@angular-devkit/build-angular:application" now. Which will be replaced with ngx-build-plus: "builder": "ngx-build-plus:browser", The "@angular-devkit/build-angular:application" uses the "browse" property instead of the "main" property "ngx-build-plus:browser" only supports the "main" property

image

Possible Solution

I think "ngx-build-plus:application" has to be implemented and used instead of "ngx-build-plus:browser"?

Okairi commented 1 month ago

Thanks, changing it to main helped me.