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

fix: The `remoteEntryChunk` should use the base path from the Vite co…

Open baijunjie opened this issue 1 year ago • 3 comments

…nfig.

Fixes #629

Description

Under normal circumstances, the reference paths for resource files built by a plugin should align with the base path specified in the Vite config.

Additional context

The filename of the exposed remote module usually doesn't include a hash because it's the entry point for remote modules and needs to be accessible by external applications. Therefore, it is typically deployed separately on Nginx, while other resources are placed on a CDN. If a relative path is used, it can cause a bug where files can't be found.

What is the purpose of this pull request?

  • [X] Bug fix
  • [ ] New Feature
  • [ ] Documentation update
  • [ ] Other

Before submitting the PR, please make sure you do the following

  • [x] Read the Code of Conduct and follow the Commit Convention guidelines.
  • [X] Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • [X] Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • [X] Ideally, include relevant tests that fail without this PR but pass with it.

baijunjie avatar Sep 20 '24 07:09 baijunjie

It seems that the CI didn't pass. Is there anything else you need me to do?

baijunjie avatar Sep 24 '24 16:09 baijunjie

It looks like the test fails, does it work locally for you? pnpm test

Jiannan-dev avatar Sep 27 '24 01:09 Jiannan-dev

It looks like the test fails, does it work locally for you? pnpm test

These errors don’t seem related to my changes. I also couldn’t pass the tests when running pnpm test on the main branch.

image

baijunjie avatar Oct 01 '24 02:10 baijunjie

What is the hold up for this to get merged? I would really need this fix asap.

stigzelm avatar Nov 29 '24 10:11 stigzelm

@stigzelm Hi friend, I believe the author has abandoned maintaining this project. However, there seems to be a better alternative now: @module-federation/vite. That said, it has the same issue—failing to use the base configured in vite.config as the final path for the output. If you’re also hoping to see this issue fixed, please follow this issue: https://github.com/module-federation/vite/issues/217.

baijunjie avatar Dec 09 '24 09:12 baijunjie

fixed in version 1.3.7? After build in remoteEntry.js file for expose component contains path ./assets. ("./assets/__federation_expose_List-lzjzMw57.js")

How the solve problem?

In vite.config.ts for remote mf set propertiy build: { target: 'esnext', assetsDir: '', }

because, if is default assets for assetsDir, remoteEntry.js from expose component for remote mf app expects to be found in ./assets/assets/_federation_expose.....js

agale92 avatar Jan 04 '25 22:01 agale92

fixed in version 1.3.7? After build in remoteEntry.js file for expose component contains path ./assets. ("./assets/__federation_expose_List-lzjzMw57.js")

How the solve problem?

In vite.config.ts for remote mf set propertiy build: { target: 'esnext', assetsDir: '', }

because, if is default assets for assetsDir, remoteEntry.js from expose component for remote mf app expects to be found in ./assets/assets/_federation_expose.....js

+1

hdwong avatar Jan 08 '25 05:01 hdwong