-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Cannot resolve swiper@7 with next@10 #238
Comments
Can you paste here the whole log? (Enabling the |
Thank you for the timly response!! Is this good?
|
I also tried
|
I believe the problem comes from your setup. The error comes from your component, are you sure you installed swiper or swiper is available from the component your required it from? On my setup, this is the problem I get: which is a SSR error (a HMR makes it work), some Swiper gets correctly imported on my side. |
To fix the SSR issue, you will need to add
Regarding your app failing to import the component, the problem is in your setup ;) Webpack/Next.js is just saying it cannot find the library, but it's not related to |
I didn't see what you saw actually... let me share the repro: https://github.com/neo/swiper7-in-next10 |
hi! trying to resurface this a bit, or should I open another issue? |
As I said, it's not a problem related to A quick research in I checked the Swiper repo and I found thiis: nolimits4web/swiper#4871 |
As a sidenote, I think this is a problem for the Next.js team, not for here :) This might help: vercel/next.js#9607 |
Maybe something like this would help (forcing the module resolution manually with Webpack) const withTM = require("next-transpile-modules")(
["swiper", "ssr-window", "dom7"],
{
resolveSymlinks: false,
debug: true,
}
);
const path = require("path");
module.exports = withTM({
webpack: (config, options) => {
if (options.isServer) {
config.externals = ["swiper", ...config.externals];
}
config.resolve.alias["swiper/react"] = path.resolve(
__dirname,
".",
"node_modules",
"swiper",
"react",
"swiper-react.js"
);
config.resolve.alias["swiper"] = path.resolve(
__dirname,
".",
"node_modules",
"swiper",
"swiper-bundle.js"
);
return config;
},
}); This is not a complete solution but this might be a step in the right direction (basically, tell Webpack where to find those modules) |
Ok thank you!! I was just afraid that you didn't see and try out the repro repo, because it was not showing the errors you described previously. And I def agree with you that it's the lib + next issues, because next 11 has (experimental) ESM support, and swiper 6 had commonjs support; thus next10 + swiper7 is an awkward combination. I just thought this package would solve all the nextjs ESM issues... Thanks again! |
What's the flag to enable esm support? I know it exists but I can't find it :( |
well it only exists in next 11 but unfortunately not 10 😭 |
(nice! I like this haha)
Are you trying to transpile a local package or an npm package?
If an npm package, which one?
[email protected]
Describe the bug
A clear and concise description of what the bug is (don't forget the logs if applicable).
It says cannot resolve the package:
To Reproduce
Steps to reproduce the behavior (a reproduction is even better):
Install
next@10
andswiper@7
, and try to import fromswiper/react
Expected behavior
A clear and concise description of what you expected to happen.
It should import and run without problems
Setup
10.2.3
next-transpile-modules
version:7.3.0
15.8.0
npm
/yarn
version:1.22.11
11.5.2
4
Additional context
Add any other context about the problem here.
We used to do the following when swiper was at version 6:
and now swiper is at version 7: https://swiperjs.com/migration-guide, I tried either of this and was not able to make it work:
or
Thank you!! 🙏
The text was updated successfully, but these errors were encountered: