angular-architects / module-federation-plugin

MIT License
688 stars 187 forks source link

production build is nested into browser folder #483

Open asollberger opened 3 months ago

asollberger commented 3 months ago

With @angular-architects/native-federation 17.0.x and angular.json

"esbuild": {
    "builder": "@angular-devkit/build-angular:browser-esbuild",
    "options": {
        "outputPath": "dist/server",

the build was generated into dist/server directly

With @angular-architects/native-federation 17.1.x and angular.json

"esbuild": {
    "builder": "@angular-devkit/build-angular:application",
    "options": {
        "outputPath": "dist/server",

it is generated into dist/server/browser

My workaround for the moment is to move the files out of the folder after the build, but I think the build files should be directly in the request ed output path.

I think PR #455 (issue #446) would not solve this problem either

My suggestion would be to add no additional folder when the output path is simply a string (the way it was before)

manfredsteyer commented 3 months ago

Thanks for pointing this out. Yes, currently native federation for Angular uses dist/project/browser as the output directory, as this is the default directory used by new angular applications.

How would we have to modify PR #455 to solve this issue at hand?

asollberger commented 3 months ago

I tried it out today and after some more testing realized, that the behavior has changed for angular. Fixing the native federation path would not solve my issue since angular also adds the browser folder to the output path.

After playing with it a bit I found that PR #455 can actually solve my issue: before: "outputPath": "dist/server" after:

"outputPath": {
    "base": "dist",
    "browser": "server"
},

If someone absolutely needed just dist as a folder one could do the following (not super, but it should work):

"outputPath": {
    "base": ".",
    "browser": "dist"
},

So my recommendation is to merge that PR and publish it. Looks fine to me.

Muntazir86 commented 2 months ago

i was trying to build my application with native federation then i make outputPath as object i got error.

An unhandled exception occurred: The "path" argument must be of type string. Received an instance of Object See "C:\Users\GHULAM~1.SHA\AppData\Local\Temp\ng-Ci9Inz\angular-errors.log" for further details.

i inspected builder.js of native federation and found this. (version: 17.1.7 )

const outputPath = path.join(options.outputPath, 'browser');

i think PR 455 is merged but not published.

Kindly publish this PR.