electerious / basicScroll

Standalone parallax scrolling for mobile and desktop with CSS variables.
https://basicscroll.electerious.com
MIT License
3.63k stars 148 forks source link

Console error after Webpack uglify #13

Closed MWDelaney closed 6 years ago

MWDelaney commented 6 years ago

Hi, I'm trying to include basicScroll in a Roots/Sage project and I'm getting a console error after building my assets for production.

TypeError: l is not a function. (In 'l(t,c,f,h)', 'l' is 4)

I'm not the most webpack savvy user, so my troubleshooting is limited. The library works great when the assets aren't uglified, but throw the above error in the browser console when the webpack bundle is uglified.

I've tried separating basicScroll into its own separate script file (still uglified) with the same result. I've also tried a fresh copy of Sage with no other (non-default) dependencies, also with the same result.

I'm happy to try any more troubleshooting steps you can suggest. Thank you for your time and for this awesome library.

vasilisakarelova commented 6 years ago

I had the exact same problem! The quick solution that i found so far, to make it at least work was (i have a React SPA) i added to my html file script with this code - https://raw.githubusercontent.com/electerious/basicScroll/master/dist/basicScroll.min.js - and in my components assigned a variable like const basicScroll = window.basicScroll. That worked for me. Try it yourself.

electerious commented 6 years ago

Are you using uglify or uglify-es? It might be a bug with the newest version (uglify-es) as re-minifying works with fine for me with uglify.

It would be great if someone could open an issue on the tool causing the issues.

electerious commented 6 years ago

I've opened an issue in the uglify-es repository as uglifyjs-webpack-plugin relies on uglify-es: https://github.com/mishoo/UglifyJS2/issues/3109

@MWDelaney @aaronwaldon Recompressing basicScroll.min.js with uglify-es works fine, too. Can you please show us how you're using and importing basicScroll?

aaronwaldon commented 6 years ago

I believe the issue was caused by using the webpack.optimize.UglifyJsPlugin in Webpack 3. I have since migrated to Webpack 4 and switched to the TerserPlugin, and everything seems to be working as expected. Thank you for the help and guidance!

electerious commented 6 years ago

Good to hear :) I will close the issue as I have no clue what's causing it. Will reopen when necessary.