Open moravkin opened 2 days ago
I have the exact same error after upgrading to Angular v19. The error occurs in angular-esbuild-adapter.ts @ line 275 where it is referencing createCompilerPlugin. The parameters need updating for this to work with Angular v19.
@AlanGRutter I do some further investigations, it seems like we need to construct object of type ComponentStylesheetBundler located at @angular\build\src\tools\esbuild\angular\component-stylesheets.js. Looking into @angular\build package maintained by Google i don't see this module exported, thus it is not visible to native-federation plugin, am I correct?
I received below error with Module Federation after upgrading to ng19
⠙ Generating browser application bundles (phase: setup)...D:\thanhnlh\sample-mfe\fe-apps\node_modules\webpack\lib\container\ModuleFederationPlugin.js:58 throw new TypeError( ^
TypeError: The 'compilation' argument must be an instance of Compilation
at ModuleFederationPlugin.getCompilationHooks (D:\thanhnlh\sample-mfe\fe-apps\node_modules\webpack\lib\container\ModuleFederationPlugin.js:58:10)
at D:\thanhnlh\sample-mfe\fe-apps\node_modules\webpack\lib\container\HoistContainerReferencesPlugin.js:36:33
at Hook.eval [as call] (eval at create (D:\thanhnlh\sample-mfe\fe-apps\node_modules\tapable\lib\HookCodeFactory.js:19:10),
@moravkin I am not hugely familiar with the inner workings of Angular. I did find the file you referenced and I did not see it listed in the private exports or the index.ts file, perhaps Google forgot to add it to the private exports. We will need to wait for the package maintainers (@manfredsteyer) to comment on this issue.
@thanhnlh - your issue is not related to this one. I believe the correct procedure is for you to create a new issue.
@AlanGRutter i agree, this should be propagated further.
As a temporary workaround to test Angular 19 with native-federation you can proceed following steps:
const cs_1 = require("..\..\..\..\@angular\\build\\src\\tools\\esbuild\\angular\\component-stylesheets.js");
plugins: plugins || [ (0, private_1.createCompilerPlugin)(pluginOptions.pluginOptions, new cs_1.ComponentStylesheetBundler(pluginOptions.styleOptions, builderOptions.inlineStyleLanguage)
@thanhnlh This issue was related to native-federation using esbuild builder. Your issue arise with module-federation using webpack. I suggest you to create another issue related to different micro-frontend approach
@moravkin - I'm not sure how to upgrade and build the project and reference it locally. Do you have an output that you can attach with instructions on how to use?
@AlanGRutter i am not building plugin locally, I updated code inside node_modules/@angular_architects of my standalone angular project, then i just run ng build (or ng serve)
With what library do you have an issue?
native-federation
Reproduction of the bug/regression with instructions
After upgrading to Angular 19, application build did not pass.
ng build
Error:
TypeError: stylesheetBundler.bundleFile is not a function at Object.transformStylesheet (...................................\node_modules\@angular\build\src\tools\esbuild\angular\compiler-plugin.js:149:72) at MessagePort.
(....................................\node_modules\@angular\build\src\tools\angular\compilation\parallel-compilation.js:42:18)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:820:20)
at MessagePort. (node:internal/per_context/messageport:23:28)
compiler-plugin.js (version 18.x), line 49 define function function createCompilerPlugin(pluginOptions, styleOptions)
compiler-plugin.js (version 19.x), line 49 define function function createCompilerPlugin(pluginOptions, stylesheetBundler)
Seems like native-federation build try to invoke function with wrong argument styleOptions. Angular 19 requires argument styleSheetBundler (which contains styleOption as inner attribute when debugging pure Angular 19 build)
Expected behavior
Build should pass without error
Versions of Native/Module Federation, Angular, Node, Browser, and operating system
Native Federation: ^18.2.2 Angular: 19.0.0 OS: Windows
Other information
No response
I would be willing to submit a PR to fix this issue