diff --git a/src/npm/package.ts b/src/npm/package.ts index 33aab59c..5818669a 100644 --- a/src/npm/package.ts +++ b/src/npm/package.ts @@ -253,16 +253,22 @@ export async function writePackageJson(data: PackageData, options: InjectOptions license: license ? license.id : 'UNLICENSE', } + let source = flags.typescript ? './src/index.ts' : './src/index.js' + // account for existing (j|t)sx + if (prev?.source?.endsWith('x')) { + source += 'x' + } + const manifest: PackageJson = { ...alwaysOnTop, // Use already configured values by default ...(prev || {}), // but we override these to enforce standardization - source: flags.typescript ? './src/index.ts' : './src/index.js', + source, exports: { '.': { ...(flags.typescript ? {types: './lib/src/index.d.ts'} : {}), - source: './src/index.ts', + source, import: './lib/index.esm.js', require: './lib/index.js', default: './lib/index.js',