Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.
This repository was 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

Description

@lxe

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions