vite-plugin-federation
vite-plugin-federation copied to clipboard
Shared modules send error
Versions
- originjs: 1.1.6
- node: v16.14.0
Steps to reproduce
npm init vue@latest

my config vite.config.ts
import { fileURLToPath, URL } from "url";
import federation from "@originjs/vite-plugin-federation";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
// https://vitejs.dev/config/
export default defineConfig({
server: {
port: 8003,
},
plugins: [
vue(),
federation({
name: "ff_payment_service",
filename: "remoteEntry.js",
exposes: {
"./AboutView.vue": "./src/views/AboutView.vue",
},
shared: ["vue"], // <- error
}),
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
});
What is Expected?
build without problem
What is actually happening?

error during build:
Error: Transform failed with 1 error:
assets/__federation_expose_AboutViewVue.js:3:74: ERROR: Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2019", "firefox78", "safari13.1")
at failureErrorWithLog (./temp/node_modules/esbuild/lib/main.js:1605:15)
at ./temp/node_modules/esbuild/lib/main.js:1394:29
at ./temp/node_modules/esbuild/lib/main.js:666:9
at handleIncomingPacket (./temp/node_modules/esbuild/lib/main.js:763:9)
at Socket.readFromStdout (./temp/node_modules/esbuild/lib/main.js:632:7)
at Socket.emit (node:events:520:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
Federation uses a Top-level await
, which is supported by the following browsers. Change your config build.target
to next
or a similar value.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#browser_compatibility
@ygj6 A lot of thanks
build: {
target: ["chrome89", "edge89", "firefox89", "safari15"],
},
and
build: {
target: "esnext",
},
I think need to add it to README.md https://github.com/originjs/vite-plugin-federation for other people and close this issue
You may want to see this comment https://github.com/originjs/vite-plugin-federation/pull/213#issuecomment-1180018123