module-federation / module-federation-examples

Implementation examples of module federation , by the creators of module federation
https://module-federation.io/
MIT License
5.61k stars 1.74k forks source link

[angular11-microfrontends] ng build prod shell not working #520

Closed dsozzi closed 3 years ago

dsozzi commented 3 years ago

Hi,

trying to build the angular applications but the shell application is not working. I noticed that the npm command is not correct and I've already opened a Pull request to fix that

from "build:shell": "ng build shell --prod", to "build:shell": "ng build mdmf-shell --prod",

but even with this change the shell doesn't compile with the following error:

An unhandled exception occurred: Unexpected identifier

and this message in the logged file

SyntaxError: Unexpected identifier
    at compileFunction (<anonymous>)
    at wrapSafe (internal/modules/cjs/loader.js:1116:16)
    at Module._compile (internal/modules/cjs/loader.js:1164:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)
    at Object.<anonymous> (/Users/d.sozzi/Projects/module federation/module-federation-examples/angular11-microfrontends/projects/mdmf-shell/webpack.prod.config.js:1:18)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)
    at transforms.<computed> (/Users/d.sozzi/Projects/module federation/module-federation-examples/angular11-microfrontends/node_modules/ngx-build-plus/src/utils/index.js:56:38)
ydmitry commented 3 years ago

Hello, I see ngx-build-plus mentioned, but in the example there is also @angular-builders/custom-webpack: https://github.com/module-federation/module-federation-examples/blob/master/angular11-microfrontends/package.json#L32 and in the end in angular.json there is only ngx-build-plus used.

You can try this example: https://github.com/ydmitry/angular11-webpack-module-federation-custom-webpack-builder (maybe I should to contribute this as existing example works with ngx-build-plus)

dsozzi commented 3 years ago

omg, I have no idea how but there was a character in the webpack.config.js that was breaking the build. My mistake. Still the package.json example has the wrong command

thanks!