es3ify
es3ify copied to clipboard
Default property with OR
I'm supporting IE8 (I know, I know) in a project, and using react hot loader in dev, then looking at swapping out Nerv or Preact in production to support older browsers. (Yup all sounds crazy). But anyway, the following line is causing an error:
Module parse failed: Unexpected token. You may need an appropriate loader to handle this file type.
at:
var reactHotLoader = (typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal : require('react-hot-loader')["default"];
I've create a simpler repro scenario to demonstrate the actual issue:
Repro steps
Run the following:
var transform = require('es3ify').transform;
console.log(transform(`(a || b).default`));
Expected result
(a || b)["default"]
Actual result
(a || b["default"]
// Note: missing closing bracket
Anyway, I think I can get round this using the babel-plugin-transform-es3-member-expression-literals plugin instead (similar to https://github.com/reduxjs/redux/pull/1688) but raising it here in case anyone else encounters the same problem.