question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v6: Improve support for ESM & CJS config files

See original GitHub issue

We currently search for config/config.json and config/config.js

We should also automatically look for extensions .cjs, and .mjs so specifying the config file location is not necessary.


We should do the same for .sequelizerc (https://github.com/sequelize/cli/blob/main/src/core/yargs.js#L7): load it using importHelper and support files: .sequelizerc (as js), .sequelizerc.js, .sequelizerc.cjs, .sequelizerc.mjs, .sequelizerc.json.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ephyscommented, May 13, 2022

Similarly to https://github.com/sequelize/cli/issues/960, we could detect the module type in package.json, and provide a --module cjs|esm option, and generate the right contents accordingly

0reactions
mariusacommented, May 9, 2022

This PR https://github.com/sequelize/cli/pull/987 includes docs update which says ESM configuration files are supported for Node versions that support ESM natively, either via passing `--config config/config.mjs`, or by setting the `type` to `module` in your `package.json`.

In a project using "type": "module",, newly generated migration files are still non ESM:

npx sequelize-cli migration:create --name test1

generates

'use strict'

module.exports = {
    async up(queryInterface, Sequelize) {
        /**
         * Add altering commands here.
         *
         * Example:
         * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
         */
    },

    async down(queryInterface, Sequelize) {
        /**
         * Add reverting commands here.
         *
         * Example:
         * await queryInterface.dropTable('users');
         */
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Bud v6.0.0 released - Roots Discourse
Upgrade guide · Keep your config file the same and use the .cjs extension · Update your config file to use ESM syntax...
Read more >
Publish ESM and CJS in a single package - Anthony Fu
A short tutorial of shipping both ESM and CJS dual formats in a single NPM package.
Read more >
StrykerJS v6.0: Expeditious Superior Mutations
From v6 onward, StrykerJS also supports your config as ESM. Either by adding { "type": "module" } to your package.json file, or by...
Read more >
How to transpile ES modules with webpack and Node.js
We have covered other ways — for example, using the .mjs or .cjs file formats and how these extensions are resolved as either...
Read more >
Gotchas - Remix
In our example here, we create a new file at utils/fs-extra.server.js : ... With major deployment platforms now supporting ESM server side, we're...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found