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
Swiper v6 claims "sideEffects: false" but actually HAS side effects #3708
Comments
Some minimal reproduction repo? I agree to add styles to side effects as proposed in #3673. But example with Dom lib seems not valid to me. This file is imported and used (called) almost in every file. So dropping it out of bundle seems like bundler issue for me |
Thanks for quick response. Just tried to play around webpack and terser and can't reproduce the issue indeed. However when I install new Angular app and integrate Swiper into it then the issue persist: Swiper just can't see any methods of dom7 ('children' is not a function) Please don't close the issue so far. I will try to figure out whether it is Angular or Webpack is the source of problem and come back. Not sure that my knowledge will be enough to figure it out though |
Dom7 uses Array subclassing, (e.g. Same issue with Vue (vuejs/vue#9259) but it is solved with proposed there code snippet |
Well I created issue on angular CLI but they insist that dom.js HAS a top-level side effect. Technically it's true Webpack's definition of "side effect":
Please see the last comment of the issue I created (already closed) |
@nolimits4web I ran into the same issue. I made a minimal reproduction repo https://github.com/ierehon1905/swiper-minimal-repo. Hope it helps. |
Hi, I have the same problem with a Gatsby project: in the development all works fine but when I build the project the styles are excluded. import style from "swiper/swiper-bundle.css"
console.log(style) |
require('swiper/swiper-bundle.css'); Using require instead of import inside webpack project can be used as a temporary solution.
|
I get an error in the javascript console when using swiper and Vue in the same <script> const addressPageVue = Vue.createApp({ }).mount('#content') Instacing Swiper like this var slider = new Swiper(".swiper", { navigation: { }) |
This is a:
Environment:
What you did
Updated Swiper from 5 to 6.
Expected Behavior
The library should work
Actual Behavior
While the library is working perfectly locally, it is completely broken when building for Production (w/ Tree Shaking)
After some investigations I found out these side effects that are cut off by webpack:
swiper/src/utils/dom.js
Lines 80 to 82 in 9ed4c97
Adding this particular file to array of sideEffects in library's package.json solved my problem but there are other files that have similar side effects. For example, this one:
swiper/src/swiper.js
Lines 10 to 18 in 1b08355
...and styles mentioned in #3673
Possible solutions
sideEffects: false
inpackage.json
can be considered as short-term solution to ensure everything is working finesideEffects: [...]
after reviewing each source file...The text was updated successfully, but these errors were encountered: