Git Product home page Git Product logo

Comments (2)

evanfrawley avatar evanfrawley commented on August 26, 2024 2

I was getting this same issue too. Here are the steps that I used to get this library to work with react-scripts / webpack / babel. Note: this should similarly work for any other webpack configuration as long as you use babel-loader.

  1. yarn eject -- Unfortunately, to add a babel loader to the webpack config, I had to eject the react-scripts support from my project. Though a bit cumbersome, you get much more control over how your project is compiled.
  2. yarn add --dev babel-plugin-transform-object-rest-spread so that you can get the babel plugin that will fix the Unexpected Token error that is being encountered.
    This will change your devDependencies in the package.json file to look something like:
  "devDependencies": {
    ...
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    ...
  },
  1. Lastly, in the webpack.config.dev.js and webpack.config.prod.js, I changed two things. First, I added the babel-loader entry to include the animateplus node module and I added the plugin that we added above. My babel-loader entry now looks like:

webpack.config.dev.js

    ...
          // Process JS with Babel.
          {
            test: /\.(js|jsx|mjs)$/,
            include: [paths.appSrc, `${paths.appNodeModules}/animateplus`],
            loader: require.resolve('babel-loader'),
            options: {
              
              // This is a feature of `babel-loader` for webpack (not Babel itself).
              // It enables caching results in ./node_modules/.cache/babel-loader/
              // directory for faster rebuilds.
              cacheDirectory: true,
              plugins: ["transform-object-rest-spread"],
            },
          },
    ...

webpack.config.prod.js

    ...
          // Process JS with Babel.
          {
            test: /\.(js|jsx|mjs)$/,
            include: [paths.appSrc, `${paths.appNodeModules}/animateplus`],
            loader: require.resolve('babel-loader'),
            options: {
                plugins: ["transform-object-rest-spread"],
                compact: true,
            },
          },
    ...

Other notes:
Here are the other babel deps that may or may not be necessary:

"dependencies": {
    ...
    "babel-core": "6.26.0",
    "babel-eslint": "7.2.3",
    "babel-jest": "20.0.3",
    "babel-loader": "7.1.2",
    "babel-preset-react-app": "^3.1.1",
    "babel-runtime": "6.26.0",
   ...
}

from animateplus.

bendc avatar bendc commented on August 26, 2024

Hi! Closing as this is related to your Babel/Webpack config, not this library.

FYI, this is not a spread operator but object rest properties.

from animateplus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.