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

[Module Federation] Failing to determine SWR version #2356

Closed
Erazihel opened this issue Jan 9, 2023 · 15 comments
Closed

[Module Federation] Failing to determine SWR version #2356

Erazihel opened this issue Jan 9, 2023 · 15 comments

Comments

@Erazihel
Copy link

Erazihel commented Jan 9, 2023

Bug report

Description / Observed Behavior

Failing to determine what SWR version to use with Module Federation based on Webpack & SWR 2.0.

Expected Behavior

No warning nor error should be displayed / thrown when using SWR with Module Federation.

Additional Context

Everything was working great with SWR 1.3.0.

Here is the prompted warning:

WARNING in shared module swr -> .../node_modules/swr/core/dist/index.mjs

No version specified and unable to automatically determine one. No version in description file (usually package.json).
Add version to description file .../node_modules/swr/core/package.json, or manually specify version in shared config.

(Note that the version is already specified in the shared config)

And this is the error thrown:

Uncaught (in promise) Error: Unsatisfied version 0 from micro-frontends of shared singleton module swr (required =2.0.0)

After manually adding a version to the node_modules/swr/core/package.json file, it seems that everything is working as expected but this is not a viable fix.

@hongkiulam
Copy link

+1

1 similar comment
@wjkawecki
Copy link

+1

@Matikun
Copy link

Matikun commented Mar 15, 2023

+1
i tried this : After manually adding a version to the node_modules/swr/core/package.json file, it seems that everything is working as expected but this is not a viable fix.
However, I'm still getting the warnings.

@martinbobbio
Copy link

+1

@nicolaswww
Copy link

Any news on this request? thank you!

@WizzApp
Copy link

WizzApp commented Apr 17, 2023

We are having this problem as well, this makes SWR essentially unusable with a Webpack Module Federation setup for us.
I have a bit of time on my hands right now and could probably create a PR to fix this, if this is ok.

@francosalcedo
Copy link

+1

1 similar comment
@kobayuri
Copy link

+1

@kobayuri
Copy link

As a fast fix/unblock:

      swr: {
        singleton: true,
        strictVersion: true,
        requiredVersion: '0', // Dumb fix
      };

@chaos1ee
Copy link

chaos1ee commented Aug 2, 2023

+1

@yamaoto
Copy link

yamaoto commented Feb 4, 2024

Also you can temporary fix it with https://www.npmjs.com/package/patch-package

For error:

WARNING in shared module swr -> .../node_modules/swr/core/dist/index.mjs

No version specified and unable to automatically determine one. No version in description file (usually package.json).
Add version to description file .../node_modules/swr/core/package.json, or manually specify version in shared config.
  1. Open .../node_modules/swr/core/package.json for edit
  2. Manually write version from your dependency
{
  "main": "./dist/index.js",
  "module": "./dist/index.esm.js",
  "types": "./dist/index.d.ts",
+ "version": "2.2.4",
  1. Generate patch file:
npx patch-package swr
  1. Install patch-package in devDependencies
  2. Add new script in your package.json
 "scripts": {
+  "postinstall": "patch-package"
 }

This script will run for every package installation and you can share this patch for your team

@koba04
Copy link
Collaborator

koba04 commented Feb 9, 2024

We updated our bundle convention at #2865.
Unfortunately, this hasn't been released yet, but the change might solve this problem.
I haven't tested this, I might be wrong.

@koba04
Copy link
Collaborator

koba04 commented Feb 16, 2024

Could you try v2.2.5? This includes #2356 (comment)

@yamaoto
Copy link

yamaoto commented Feb 16, 2024

@koba04
Tried to test on my project with Module Federation on the new v2.2.5 everything works great and without any hacks in .
Thank you very much for the notification.

@koba04
Copy link
Collaborator

koba04 commented Feb 16, 2024

I'll close this as fixed. Please reopen this if you still have a problem with v2.2.5

@koba04 koba04 closed this as completed Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests