3

I use React, Webpack, Babel to build the project and wish it run in IE8, there is a problem that Object.defineProperty is not supported in IE8.

I didn't use this function but npm packages do it, like react-router. I have tried polyfill, es5-shim, es5-sham, and a lot of babel plugins, but unfortunately not work for me...

So what else can i do for this situation?

Truly appreciate.

Prometheus
  • 35
  • 3

1 Answers1

1

Generally for support of much older browsers, you'd want to use babel-preset-es2015-loose rather than babel-preset-es2015, which will stop most usage of Object.defineProperty.

loganfsmyth
  • 156,129
  • 30
  • 331
  • 251
  • Sorry for late reply. I already use the loose mode but there is an error in file es5.js. The detail is `if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!')`. Actually I don't know what code cause this error... thank you so much – Prometheus Jun 03 '16 at 11:48
  • 1
    `Object.defineProperty` can't be transpiled. Loose mode tells Babel to avoid using it where possible, but currently it can still crop up depending on your usage. For instance, `export * from 'foo';` will generate `Object.defineProperty` calls. You will need to debug your codebase and figure out where the calls to it are coming from. – loganfsmyth Jun 03 '16 at 15:38
  • I already refactor the code from `export default` and `export *` to `module.exports`, I promise there no problems in my code. It must be the third-party library error, but I couldn't positioning the it. But thank you also... – Prometheus Jun 06 '16 at 02:50