vite-plugin-federation
vite-plugin-federation copied to clipboard
run build, there is a issue, like Emitted chunks need to have a valid string id, received "undefined"
Versions
"@originjs/vite-plugin-federation": "^1.1.5", "vue": "^3.2.6",
- originjs:
- node: v17.0.0
Reproduction
import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import path from 'path' import federation, { VitePluginFederationOptions, } from '@originjs/vite-plugin-federation' const resolve = (dir: string) => path.resolve(__dirname, dir) import viteCompression from 'vite-plugin-compression'
const Options: VitePluginFederationOptions = { name: 'settings', filename: 'remoteEntry.js', exposes: { './Head': './src/components/Head.vue', }, shared: ['vue'], } // https://vitejs.dev/config/ export default defineConfig({ plugins: [federation(Options), vue(), viteCompression()], server: { port: 4200, fs: { // Allow serving files from one level up to the project root allow: [], strict: false, }, }, build: { terserOptions: { compress: { drop_console: true, drop_debugger: true, }, }, outDir: 'dist/frame', minify: false, }, resolve: { alias: { '@': resolve('src'), }, }, })
Additional Details
Steps to reproduce
What is Expected?
build success
What is actually happening?
thanks , but could you provide a reproduction repository? I cant reproduce the problem with reference to your configuration
Try putting the configuration of vite-plugin-federation after vue()
, I'm not sure if this is the cause of the problem, but theoretically the plugin is best run after vue()
plugins: [vue(),federation(Options), viteCompression()],
i try it agian as what you say :plugins: [vue(),federation(Options), viteCompression()], bu it does't work, because this is a company project ,so i can't provide reproduction repository, and one more things , this is a parent application of qiankun, i am not sure that this will cause problems
I had the same problem. In my case I wrote incorrectly the components path on exposes property.
Hi @huntJs
One tip that here occurred, same as @UrielJavier ...
can you verify if ./src/components/Head.vue
really exists with exact name os paths, included H
for Head.vue
?
Maybe we can make some improvements. Instead of the current confusing error message, we could give a tip when a configuration error occurs.