vite-plugin-federation icon indicating copy to clipboard operation
vite-plugin-federation copied to clipboard

run build, there is a issue, like Emitted chunks need to have a valid string id, received "undefined"

Open huntJs opened this issue 2 years ago • 5 comments

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?

image

huntJs avatar Apr 28 '22 01:04 huntJs

thanks , but could you provide a reproduction repository? I cant reproduce the problem with reference to your configuration

ruleeeer avatar Apr 28 '22 01:04 ruleeeer

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()],

ruleeeer avatar Apr 28 '22 02:04 ruleeeer

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

huntJs avatar Apr 28 '22 03:04 huntJs

I had the same problem. In my case I wrote incorrectly the components path on exposes property.

UrielJavier avatar Jul 04 '22 22:07 UrielJavier

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 ?

jeffdrumgod avatar Jul 13 '22 12:07 jeffdrumgod

Maybe we can make some improvements. Instead of the current confusing error message, we could give a tip when a configuration error occurs.

flyfishzy avatar Jan 17 '23 11:01 flyfishzy