Open danielt69 opened 1 year ago
Could you provide more information here. What bundler did you use here ? Is it a nexjs, vite or react-native project ?
You should probably use an asynchronous fetcher (apiPost). However, I feel as if you have made multiple 'weird' design choices in this example.
It is an asynchronous fetcher. What do you mean by "weird design choices"?
It is an asynchronous fetcher. What do you mean by "weird design choices"?
Well, of course, I am not really sure what you intended exactly. I guess that you should just not resolve the fetch API with json, but it would be easier to determine the problem if you could provide some more information as promer94 has previously suggested.
I also use Module Federation if it makes any difference.
I also use Module Federation if it makes any difference.
Could you provide a (minimal) reproduction of the problem in something like codesandbox?
https://github.com/webpack/webpack/issues/16125
It's webpack's issue. I am sorry but i don't know any workaround for this
@danielt69 https://github.com/webpack/webpack/issues/16125#issuecomment-1210447191 This seems like a workaround, give it a try.
Eventually, I managed to workaround it by adding the following settings to the Webpack config:
const path = require('path');
const packageJson = require(path.join(process.cwd(), 'package.json'));
const deps = packageJson.dependencies;
const excludePackages = ['swr'];
const shared = Object.keys(deps).reduce((acc, curr) => {
if (excludePackages.find((o) => o === curr)) {
return { ...acc };
} else {
return {
[curr]: deps[curr],
...acc,
};
}
}, {});
module.exports = {
name: 'ModuleBoilerplate',
exposes: {
index: path.join(process.cwd(), 'src/index.js'),
},
shared,
};
Could you try it again with v2.2.5?
Could you try it again with v2.2.5?
Tested on ModuleFederation with swr version of 2.2.5. It is working.
Bug report
Description / Observed Behavior
I get
useSWR is not a function
every time I useconst { trigger, data, error } = useSWRMutation('email-step', apiPost)
Expected Behavior
to work as expected in the docs - return me those values:
{ trigger, data, error }
Repro Steps / Code Example
Additional Context
SWR version: "2.2.0" I used a custom webpack config. Nodejs version 14.15.0