async function importModule(modulePath) {
  // JSON modules are still behind a flag. Fallback to require for now.
  // https://nodejs.org/api/esm.html#json-modules
  if (
    url.pathToFileURL &&
    !modulePath.endsWith('.json') &&
    (await supportsDynamicImport())
  ) {
    // 'import' expects a URL. (https://github.com/sequelize/cli/issues/994)
    return import(url.pathToFileURL(modulePath));
  }

  // mimics what `import()` would return for
  // cjs modules.
  return { default: require(modulePath) };
}
Imports a JSON, CommonJS or ESM module
based on feature detection.

@param modulePath path to the module to import
@returns {Promise<unknown>} the imported module.