Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New babel update breaks sequelize imports #4881

Closed
alexschneider opened this issue Nov 19, 2015 · 2 comments
Closed

New babel update breaks sequelize imports #4881

alexschneider opened this issue Nov 19, 2015 · 2 comments

Comments

@alexschneider
Copy link
Contributor

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; }?

@mickhansen
Copy link
Contributor

That would probably be a fine fix. You are probably most equipped to attempt a fix since you are running ES6 in your environment, PR welcome :)

alexschneider added a commit to alexschneider/sequelize that referenced this issue Nov 19, 2015
alexschneider added a commit to alexschneider/sequelize that referenced this issue Dec 4, 2015
Fix tests and description based on feedback
mickhansen added a commit that referenced this issue Dec 4, 2015
@BerndWessels
Copy link

Hi, is there a npm release with babel 6 support out there already?

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

No branches or pull requests

3 participants