Skip to content

New babel update breaks sequelize imports #4881

@alexschneider

Description

@alexschneider

The recent babel 6 update caused models written in es6 to fail to import. The reason being is because Babel killed support for CommonJS's default export behavior (default export behavior is if the default export is the only export in a file, module.exports = exports["default"];). Since babel doesn't do this anymore, the default export is only available as require('modulename').default.

Since sequelize does a require when you import a model, it is impossible to import a model transformed by babel without a hack (adding module.exports = exports["default"]; to the end of your model).

Is there any way sequelize can check for require(path).default for the defineCall function? Something like defineCall = defineCall.default || defineCall; or if (typeof defineCall === 'object' && defineCall.default) { defineCall = defineCall.default; }?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugDEPRECATED: replace with the "bug" issue type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions