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

refactor: remove sequelize.import helper #12175

Merged
merged 1 commit into from
Apr 26, 2020
Merged

Conversation

sushantdhiman
Copy link
Contributor

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you update the typescript typings accordingly (if applicable)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

Closes #11739

@codecov
Copy link

codecov bot commented Apr 26, 2020

Codecov Report

Merging #12175 into master will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12175      +/-   ##
==========================================
- Coverage   96.34%   96.33%   -0.01%     
==========================================
  Files          95       95              
  Lines        9190     9179      -11     
==========================================
- Hits         8854     8843      -11     
  Misses        336      336              
Impacted Files Coverage Δ
lib/sequelize.js 95.87% <ø> (-0.14%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 541d2fa...3dfb46c. Read the comment docs.

@sushantdhiman sushantdhiman merged commit f1e451e into master Apr 26, 2020
@sushantdhiman sushantdhiman deleted the remove-import-helper branch April 26, 2020 11:56
@papb papb added breaking change For issues and PRs. Changes that break compatibility and require a major version increment. type: refactor For issues and PRs. Things that improve the code readability, maintainability, testability, etc. labels Apr 26, 2020
@MichielDeMey
Copy link

I noticed that .import has been deprecated in beta6, is there an upgrade path or best practices on how to migrate existing code?

The upgrade guide only mentions that the function has been deprecated, but offers no other directions. 😅

@papb
Copy link
Member

papb commented May 18, 2020

Hi @MichielDeMey, thanks for the comment, we should improve that part of the docs. Can you tell me more about your situation? Can you give an example of code snippet that you have using import?

Does your case stem from this issue in the CLI or is it something else?

@MichielDeMey
Copy link

Yep, looks like the code was originally generated by the CLI.
We can follow up on that issue regarding the deprecated import method. 👍

@papb papb modified the milestone: v6 May 19, 2020
@roychri
Copy link

roychri commented Jul 9, 2020

For those coming here and tryign that old issue with CLI which is now gone, here's how you can migrate.

From:

sequelize.import(path.join(__dirname, '', filename));

To:

require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);

@mdodge-ecgrow
Copy link

mdodge-ecgrow commented Jun 7, 2021

I switched over to using the require line and am now getting this error (using Node 14 and Sequelize 6):

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\.....\models\Permissions.js
require() of ES modules is not supported.
require() of C:\.....\models\Permissions.js from C:\.....\models\index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename Permissions.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\.....\package.json.

I don't want to rename all my models to .cjs and I don't want to remove "type":"module", so I'm wondering what my options are here. I can't be the only one trying to do this on Node 14 and Sequelize 6.

@machine-gurning
Copy link

@mdodge-ecgrow did you find a solution? I have the same problem

@ephys
Copy link
Member

ephys commented Apr 18, 2022

you need to use import instead of require

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change For issues and PRs. Changes that break compatibility and require a major version increment. type: refactor For issues and PRs. Things that improve the code readability, maintainability, testability, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

change: remove import helper
7 participants