Skip to content

Commit

Permalink
fix: use jsx suffix if source already has it
Browse files Browse the repository at this point in the history
  • Loading branch information
snorrees committed Nov 2, 2022
1 parent f3414c1 commit 3f1a266
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/npm/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 3f1a266

Please sign in to comment.