Greetings to all who are reading this,
I have created a React micro-frontend project using SPA v5.9, Webpack v5.75, Babel-loader v9.1, Ts-loader v9.4, and Yarn workspace v3.5. The project structure is very basic:
- Root SPA => Package Root
- Application SPA => Package App1
- Utils SPA => Package Utils1
- React lib Utils SPA => Package Utils2
My current challenge arises when running the app on Webpack dev server. If I add a new function to Utils1 and try to use it in App1, TypeScript throws an error stating that there is no existing export for this function.
The application runs without issues, so I suspect it's a misconfiguration of either Webpack, loaders, or TypeScript settings. Unfortunately, I am not well-versed in this specific setup and haven't been able to find a solution on Stack Overflow or GitHub repositories.
To see more details about the configuration used, you can visit my project here.
My main question is: How can I resolve the TypeScript error occurring when using Webpack?
I believe that sharing the solution from my repository could benefit others who are facing similar challenges in structuring their projects. So, it would be great to find and share a resolution :)
An interesting observation is that the updated d.ts files of Utils1 are successfully created in my dist directory by Ts-loader and emitted in App1 as assets by path ../../utils1
. However, this seems insufficient.
Here are some logs from the console when adding a new function:
...
And here is the error log when trying to utilize that function:
...