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

Adds a workaround for a safari bug when loading modules async

Open Tiagoperes opened this issue 1 year ago • 1 comments

Description

Safari currently has a bug where, if the same module is imported twice or more simultaneously, it fails with a reference error.

This is actually a Webkit bug and is registered here: https://github.com/WebKit/WebKit/pull/24122

We don't know when this bug will be fixed, but we can work around it with a simple modification that prevents the same remote module from being imported twice. This PR implements this modification.

I'm not familiar with the source code of this lib, so I altered the function __federation_import everywhere I found it. Please, check.

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).
  • [ ] Ideally, include relevant tests that fail without this PR but pass with it.

Tiagoperes avatar Jul 19 '24 13:07 Tiagoperes

It seems that this change is harmless, I will review the test issue when I have time

Jiannan-dev avatar Jul 26 '24 01:07 Jiannan-dev