From ec3fe9d5e79bb97752ed108bc7d95507006e175d Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 16 Oct 2024 05:52:59 -0700 Subject: [PATCH] fix: support for "module": "node16"/"nodenext" (#24) --- src/index.ts | 9 +++++---- test/fixtures/tsconfig-with-package-json/tsconfig.json | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) 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 }