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

@sushantdhiman sushantdhiman commented Apr 26, 2020

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 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
3 of 4 checks passed
@sushantdhiman sushantdhiman deleted the remove-import-helper branch Apr 26, 2020
@papb papb added breaking change type: refactor labels Apr 26, 2020
@MichielDeMey
Copy link

@MichielDeMey MichielDeMey commented May 18, 2020

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 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

@MichielDeMey MichielDeMey commented May 19, 2020

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 added this to the v6 milestone May 19, 2020
@papb papb removed this from the v6 milestone May 19, 2020
@roychri
Copy link

@roychri 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 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

@machine-gurning machine-gurning commented Apr 18, 2022

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

@ephys
Copy link
Member

@ephys 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 type: refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants