esperantojs/esperanto

export { default } from '...' causing parse error in IE8.

Closed this issue · 6 comments

This is an issue in ember-wormhole, and liquid-fire. When directly exporting a component with export { default } from 'somewhere/component-name' It outputs exports.default = component-name.default; which causes a parse error in IE8.

The current solution courtesy of @rwjblue is found

// change 
export { default, measure } from "liquid-fire/components/liquid-measured";
// which outputs:
exports.default = liquid_measured.default; // IE8 Parse Error
exports.measure = liquid_measured.measure;

// to 
import LiquidMeasured, { measure } from 'liquid-fire/components/liquid-measured';

export default LiquidMeasured;
export { measure };
// which outputs 
exports['default'] = liquid_measured['default'] // works in IE8.
exports.measure = liquid_measured.measure;

@stefanpenner suggested in a PR that this was a issue with esperanto and to report here.

The current version seems to output as you expect. What version of esperanto are you using? Perhaps you need to update?

ember-cli has a ^0.7.2 dep, so it should drift up correctly -> https://github.com/ember-cli/broccoli-es6modules/blob/master/package.json#L15

Ah, that is a recent change. I suspect an ember-cli release will be needed: ember-cli/broccoli-es6modules@5d8d3d1

XrXr commented

@eventualbuddha I just tried with esperanto 0.7.3

var es = require('esperanto')

console.log(es.toCjs("export { default} from 'foo';",  {
  strict: true,
  _evilES3SafeReExports: true
}).code);

outputs

'use strict';

var foo = require('foo');

exports.default = foo.default;

Which version works?

'use strict';

var foo = require('foo');

exports.default = foo.default;

this doesn't look like AMD

XrXr commented

@stefanpenner my mistake. Should of called .toAmd()

var es = require('esperanto')

console.log(es.toAmd("export { default } from 'foo';",  {
  strict: true,
  _evilES3SafeReExports: true
}).code);

outputs

define(['exports', 'foo'], function (exports, foo) {

    'use strict';



    exports.default = foo.default;

});
XrXr commented

@eventualbuddha I dug into it a bit more and came up with a PR for it :) #176