vite-plugin-federation
vite-plugin-federation copied to clipboard
Uncaught SyntaxError: Cannot use import statement outside a module (at remoteEntry.js:1:1)
I have a paths error.
Uncaught SyntaxError: Cannot use import statement outside a module (at remoteEntry.js:1:1)

Try to add type="module" to the script. For example:
<script type="module" src="/src/main.js"></script>
Doesn't work for me. I am experiencing the same problem.
The host in my case is a Webpack and the remote is using Vite.
Didn't find a solution. Changed Vite to Webpack
@js-lowes @ivankorobchuk123 did you find a solution?
Sorry, no)
Bot detected the issue body's language is not English, translate it automatically. π―ππ»π§βπ€βπ§π«π§πΏβπ€βπ§π»π©πΎβπ€βπ¨πΏπ¬πΏ
Sorry, no)
@js-lowes @ivankorobchuk123 did you find a solution?
Unfortunately not, but I have tried vite plugin federation in awhile. Best of luck.
This is pretty straightforward. Your remoteEntry.js from Vite is having import statements which are not allowed in browser unless the script tag has type="module" attribute. Just set the type module on the script tag and it will work fine.
Something like <script type="module" src="http://localhost:3000/assets/remoteEntry.js" />
@mjangir can you check my similar issue here? https://github.com/originjs/vite-plugin-federation/issues/576