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

Use angular native federation with builder configuration: "@angular-devkit/build-angular:browser-esbuild" #28837

Open
1 task
elio1fiore opened this issue Nov 11, 2024 · 2 comments
Labels
needs: more info Reporter must clarify the issue

Comments

@elio1fiore
Copy link

elio1fiore commented Nov 11, 2024

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

HI,

Using the angular-architects/native-federation library and initializing with the command ng g @angular-architects/native-federation:init --type host the microfrontend will change the angular.json file by adding the esbuild configuration in architect. The esbuild configuration pre-configured the builder with the angular-devkit/build-angular:application option. If I run ng serve with this configuration the microfrontend works, but unfortunately I would need the browser-esbuild option and this is where the problem arises.
So by configuring angular-devkit/build-angular:browser-esbuild and changing the key from options.browser to options.main and then starting ng serve I get the error:

Error: Schema validation failed with the following errors:
Data path "" must have required property 'browser'.

Changing again from options.main to options.browser (not noticing that it warns you by saying: the browser property is not allowed.) and running ng serve again gives me:

Error: Schema validation failed with the following errors:
Data path "" must have required property 'main'.

Another test I performed is deleting the options.main/options.browser key and running ng serve again gives me the error:

Error: Schema validation failed with the following errors:
Data path "" must have required property 'main'.

Even initializing the microfrontend with --type remote gives the same problem

Minimal Reproduction

reproducing this error is simple:

  • make a new app
  • install @angular-architects/native-federation library (my version is 18.2.2)
  • initialize the microfrontend with ng g @angular-architects/native-federation:init --type host
  • change in angular.json file architect.esbuild.builder: "@angular-devkit/build-angular:browser-esbuild"
  • change from options.browser to options.main
  • ng serve

Exception or Error

Error: Schema validation failed with the following errors:
  Data path "" must have required property 'browser'.

Your Environment

Angular CLI: 18.2.11
Node: 22.0.0
Package Manager: npm 10.5.1
OS: win32 x64

Angular: 18.2.11
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1802.11
@angular-devkit/build-angular   18.2.11
@angular-devkit/core            18.2.11
@angular-devkit/schematics      18.2.11
@schematics/angular             18.2.11
rxjs                            7.8.1
typescript                      5.5.4
zone.js                         0.14.10

Anything else relevant?

No response

@elio1fiore elio1fiore reopened this Nov 11, 2024
@elio1fiore elio1fiore changed the title Use angular federation with build configuration: "@angular-devkit/build-angular:browser-esbuild" Use angular federation with builder configuration: "@angular-devkit/build-angular:browser-esbuild" Nov 11, 2024
@elio1fiore elio1fiore changed the title Use angular federation with builder configuration: "@angular-devkit/build-angular:browser-esbuild" Use angular native federation with builder configuration: "@angular-devkit/build-angular:browser-esbuild" Nov 11, 2024
@clydin
Copy link
Member

clydin commented Nov 11, 2024

The browser-esbuild builder is intended solely as a compatibility bridge for migrating from the browser builder. Its only behavioral difference from application is that it transforms the browser builder options into application options.

Can you provide additional details on your project's use cases for browser-esbuild?

@clydin clydin added the needs: more info Reporter must clarify the issue label Nov 11, 2024
@elio1fiore
Copy link
Author

We may need the browser-esbuild configuration when using the library like:
https://github.com/AuScope/angular-cesium

If we look in the projects folder of this library, we find the demo project configured with the :browser settings. Indeed, if I do NOT initialize the project with the command ng g @angular-architects/native-federation:init and by setting :browser, the project compiles and is exposed on localhost.

Currently, if I create MFEs with the ng g @angular-architects/native-federation:init command, the library no longer works. It definitely introduces an additional layer of complexity that I am trying to understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: more info Reporter must clarify the issue
Projects
None yet
Development

No branches or pull requests

2 participants