'use strict';

const { extname: extnamePath } = require('path');
const getPackageType = require('get-package-type');

// eslint-disable-next-line consistent-return
module.exports = function importOrRequire(file) {
    const ext = extnamePath(file);

    if (ext === '.mjs' || (ext === '.js' && getPackageType.sync(file) === 'module')) {
        return import(file);
    }
    require(file);
};

@@ -58,16 +58,58 @@
 path');%0A
+const %7B pathToFileURL %7D = require('url');%0A
 const ge
@@ -394,20 +394,40 @@
  import(
-file
+pathToFileURL(file).href
 );%0A    %7D

use `file://` URLs for dynamic `import()`