Search code examples
javascriptreactjsrollupjsemotionframer-motion

Rollup with framer-motion, isPropValid emotion function error


I'm trying to bundlize my custom react components UI library with Rollup.

Some of my components using framer-motion to animate them

I've installed my lib with NPM on my project.

But when I try to use one of my components of my library, if this component is animated with Motion I got an error :

TypeError: emotionIsPropValid_1 is not a function

isPropValid
node_modules/myRepo/myLib/build/index.esm.js:8471

I'm using Rollup v2.34.1 and I tried to specify custom named export but it doesn't work.

commonjs({
      include: 'node_modules/**',
      namedExports: {
        'node_modules/react-is/index.js': ['isValidElementType'],
        'node_modules/@emotion/is-prop-valid/dist/is-prop-valid.cjs.js': [
          'isPropValid'
        ]
      }
    }),

I don't know how can I solve my problem

Thanks !


Solution

  • Finally fixed my problem by replacing rollup with TSDX