Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Chunk Paths in remoteEntry.js After Upgrading to @originjs/vite-plugin-federation 1.3.7 #658

Open
aryaglekshmi opened this issue Jan 2, 2025 · 1 comment

Comments

@aryaglekshmi
Copy link

Versions

  • vite-plugin-federation: 1.3.7
  • vite: ^6.0.3

Reproduction

import { defineConfig } from "vite";
import federation from "@originjs/vite-plugin-federation";
import basicSsl from '@vitejs/plugin-basic-ssl';
import vue from "@vitejs/plugin-vue";

export default defineConfig(() => {
  return {
    plugins: [
      vue(),
      basicSsl(),
      federation({
        name: "remote-app",
        filename: "remoteEntry.js",
        exposes: {
          "./services": "./src/@services/index.ts",
        },
        shared: ["vue", "vue-router"],
      }),
    ],
    base: "./",

    build: {
      rollupOptions: {
        input: {
          main: "index.html",
        },
        output: {
          dir: "dist",
          entryFileNames: "entry-[name].[hash].js",
          chunkFileNames: "chunks/chnk-[name].[hash].js",
          manualChunks: undefined,
          assetFileNames: `assets/[name].[ext]`,
        },
      },
      target: "esnext",
      minify: false,
      cssCodeSplit: false,
      modulePreload: false,
    },
  };
});

// Host app
federation({
  name: "host-app",
  remotes: {
    remoteapp: `https://localhost:5151/assets/remoteEntry.js`, // Correct path to place remoteEntry.js at the root
  },
  shared: ["vue", "vue-router"],
}),

What is Expected?

The paths in remoteHostEntry.js should correctly reference the chunks from the chunks directory, not from assets/chunks.

What is actually happening?

After upgrading to @originjs/vite-plugin-federation version 1.3.7, the paths in remoteHostEntry.js are incorrectly pointing to assets/chunks instead of the correct chunks directory. This issue is due to the update that makes the remote entry chunk use the base path from the Vite config.

original path of the file : dist > chunks > chnk-__federation_expose_Services.js
Path inside remoteEntry.js : "
./services":()=>{
return __federation_import('./assets/../chunks/chnk-__federation_expose_Services.js').then(module =>Object.keys(module).every(item => exportSet.has(item)) ? () => module.default : () => module)},

@Mrwang1234567
Copy link

Yes, hope to improve soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants