React-spring: React-spring > 8.0.5 stopped working in IE 11

Created on 18 Feb 2019  路  7Comments  路  Source: pmndrs/react-spring

I am getting Syntax error in console which points to this line, probably due to defining variables withlet
annotation 2019-02-18 100805

Most helpful comment

The Common JS bundle should support IE11. Try updating your imports to

import { useSpring } from 'react-spring/web.cjs'

Or add a Webpack alias

  resolve: {
    alias: {
      'react-spring$': 'react-spring/web.cjs',
      'react-spring/renderprops$': 'react-spring/renderprops.cjs'
    },
  }

Not entirely sure but not ie11 has been in the babelrc config since very long ago so the fact that IE11 support broke in 8.0.5 could be due to unrelated changes making Rollup actually picking up the babel config properly for the default esm bundle.

All 7 comments

The Common JS bundle should support IE11. Try updating your imports to

import { useSpring } from 'react-spring/web.cjs'

Or add a Webpack alias

  resolve: {
    alias: {
      'react-spring$': 'react-spring/web.cjs',
      'react-spring/renderprops$': 'react-spring/renderprops.cjs'
    },
  }

Not entirely sure but not ie11 has been in the babelrc config since very long ago so the fact that IE11 support broke in 8.0.5 could be due to unrelated changes making Rollup actually picking up the babel config properly for the default esm bundle.

Thanks, I also found a note in the docs about it!

oye...not ideal to import the commonjs module :\

Also FWIW the let is fine, its the arrow function on that line e=>"undefined"!=typeof window... that is causing the syntax error

@ammmze fwiw, we'll eventually split each platform into its own package so that the .cjs extension is no longer needed.

Note: In the latest beta, you can import the platform-specific package if you don't like adding .cjs.js to every import statement:

import { useSpring } from '@react-spring/native'

For the web platform, you can actually import react-spring normally, because its main module is equal to the .cjs.js path already:

import { useSpring } from 'react-spring'

@Chetan-k Importing react-use-gesture/web.cjs.js is not necessary, because the main module of react-use-gesture is that path already (see here). Also, useSprings does not depend on react-use-gesture in any way.

Unfortunately, the previous tricks don't work for me, my build is still broken for IE11. Only solution that I have found for now is to stick with 8.0.4...

unfortunatly didnt work for me either.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Oba-One picture Oba-One  路  3Comments

BertCh picture BertCh  路  3Comments

jmcruzmanalo picture jmcruzmanalo  路  4Comments

sakhisheikh picture sakhisheikh  路  3Comments

mkhoussid picture mkhoussid  路  3Comments