daviferreira/react-viewport-slider

Problem with a dependency using CRA.

saeta-eth opened this issue · 1 comments

Hi @daviferreira!

I'm having trouble using CRA when I want to build it.
To build, I have to run a task of my package.
My task doing: react-scripts build

But I have the following message:

Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file: 

 	./node_modules/scroll-to-y/index.js:19 

Read more here: http://bit.ly/2tRViJ9

Can you help me with that?
Thanks.

Hey @slorenzo,

I ran into same problem you did, exact same error for the scroll-to-y package.
If you go into your node_modules/scroll-to-y/index.js and at line 19 replace it with this:

  window.requestAnimFrame = (function(){
    return window.requestAnimationFrame     ||
      window.webkitRequestAnimationFrame ||
      window.mozRequestAnimationFrame  ||
      function( callback ) {
        window.setTimeout(callback, 1000 / 60);
      };
  })();

npm run build will then bypass the error on line 17, but throw you another one for line 47
So replace the broken code with:

var PI_D2 = Math.PI / 2,
  easingEquations = {
    easeOutSine: function(pos) {
      return Math.sin(pos * (Math.PI / 2));
    },
    easeInOutSine: function(pos) {
      return (-0.5 * (Math.cos(Math.PI * pos) - 1));
    },
    easeInOutQuint: function(pos) {
      if ((pos /= 0.5) < 1) {
        return 0.5 * Math.pow(pos, 5);
      }
      return 0.5 * (Math.pow((pos - 2), 5) + 2);
    }
  };

Hope that works for you!
I'll submit a pull request for the scroll-to-y package.