default to esm when running in deno
This commit is contained in:
parent
458e6c81fe
commit
26c13a28bf
|
|
@ -289,10 +289,16 @@ export function fileIsModule(file: string): boolean {
|
||||||
|
|
||||||
function folderIsModule(folder: string): boolean {
|
function folderIsModule(folder: string): boolean {
|
||||||
const packageJsonPath = getPackageJsonPath(folder);
|
const packageJsonPath = getPackageJsonPath(folder);
|
||||||
|
// deno is ESM unless package.json specifies otherwise
|
||||||
|
const isDeno = typeof process.versions.deno === 'string';
|
||||||
if (!packageJsonPath)
|
if (!packageJsonPath)
|
||||||
|
return isDeno;
|
||||||
|
const type = require(packageJsonPath).type;
|
||||||
|
if (type === 'module')
|
||||||
|
return true;
|
||||||
|
if (type === 'commonjs')
|
||||||
return false;
|
return false;
|
||||||
// Rely on `require` internal caching logic.
|
return isDeno;
|
||||||
return require(packageJsonPath).type === 'module';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const packageJsonMainFieldCache = new Map<string, string | undefined>();
|
const packageJsonMainFieldCache = new Map<string, string | undefined>();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue