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

fix: make importModels support non-default CJS exports #16844

Merged
merged 9 commits into from Feb 2, 2024

Conversation

ckvv
Copy link
Contributor

@ckvv ckvv commented Dec 7, 2023

Fixes #16843

@ephys
Copy link
Member

ephys commented Dec 12, 2023

Thank you for the PR!

Could you add a unit test that tries to import a CJS file with "named" exports? This should cover what is added in this PR

You can do that in import-models.test.ts

packages/core/src/import-models.ts Outdated Show resolved Hide resolved
packages/core/src/import-models.ts Outdated Show resolved Hide resolved
@ephys
Copy link
Member

ephys commented Feb 2, 2024

Made a tiny change to only spread plain objects (objects with either no prototype, or Object.prototype as the prototype). If the default export is a class, or a date, etc, we should not spread it

@ephys ephys enabled auto-merge February 2, 2024 21:32
@ephys ephys disabled auto-merge February 2, 2024 21:32
@ephys ephys changed the title fix: support nested default exports with using dynamic import fix: make importModels support non-default CJS exports Feb 2, 2024
@ephys ephys enabled auto-merge February 2, 2024 21:32
@ephys ephys added this pull request to the merge queue Feb 2, 2024
Merged via the queue into sequelize:main with commit bf53c9f Feb 2, 2024
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

importModels does not work as expected
3 participants