diff --git a/src/index.ts b/src/index.ts index 0221a07..5719afe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -107,16 +107,17 @@ function moduleType( 'es2020', 'es2022', 'esnext', - 'node16', - 'nodenext', 'none', ] as const if (es6Modules.includes(module as any)) { return 'es6' } - const packageJson = getPackageJson(cwd) - if (packageJson?.type === 'module') { + const nodeModules = [ + 'node16', + 'nodenext', + ] as const + if (nodeModules.includes(module as any) && getPackageJson(cwd)?.type === 'module') { return 'es6' } diff --git a/test/fixtures/tsconfig-with-package-json/tsconfig.json b/test/fixtures/tsconfig-with-package-json/tsconfig.json index a8cbd69..f62eeb6 100644 --- a/test/fixtures/tsconfig-with-package-json/tsconfig.json +++ b/test/fixtures/tsconfig-with-package-json/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "module": "node16", "target": "esnext", "strict": true }