Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Reserved keywords as properties of module.exports are transpiled into named exports, which causes "unexpected token" errors. #116

Closed
lxe opened this issue Sep 20, 2016 · 2 comments

Comments

@lxe
Copy link
Contributor

lxe commented Sep 20, 2016

Consider:

module.exports.delete = 'foo';

This will get transpiled into:

var delete = 'foo';

var mycjsmodule = {
    delete: delete
};

export default mycjsmodule;
export { mycjsmodule as __moduleExports };
export { delete };

Which will cause a SyntaxErrors on var delete = 'foo'; and export { delete };

Since it's impossible to do import { delete } from './mycjsmodule' anyways, it would be safe to not create named exports for reserved-keyword properties of module.exports. EDIT: Apparently it's possible to import a reserved keyword like that, as long as it's destructured, at least according to babel! Not sure if that's desired behavior.

@lxe
Copy link
Contributor Author

lxe commented Sep 20, 2016

According to babel, this is valid es2015:

import { this } from 'wat'

const foo = 'wat';
export { lol as const };

This is madness!

@Rich-Harris
Copy link
Contributor

This is madness!

Seconded! In any case, this should be fixed now in 6.0.0. Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants