File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change 1- import { writeFile } from 'node:fs/promises'
1+ import { readFile , writeFile } from 'node:fs/promises'
22import path from 'node:path'
33import { RE_DTS } from 'rolldown-plugin-dts/filename'
44import { slash } from '../utils/general'
@@ -61,14 +61,16 @@ export async function writeExports(
6161 updatedPkg . publishConfig . exports = publishExports
6262 }
6363
64- await writeFile (
65- pkg . packageJsonPath ,
66- `${ JSON . stringify (
67- { ...pkg , ...generated , packageJsonPath : undefined } ,
68- null ,
69- 2 ,
70- ) } \n`,
64+ const original = await readFile ( pkg . packageJsonPath , 'utf8' )
65+ let contents = JSON . stringify (
66+ updatedPkg ,
67+ null ,
68+ original . includes ( '\t' ) ? '\t' : 2 ,
7169 )
70+ if ( original . endsWith ( '\n' ) ) contents += '\n'
71+ if ( contents !== original ) {
72+ await writeFile ( pkg . packageJsonPath , contents , 'utf8' )
73+ }
7274}
7375
7476type SubExport = Partial < Record < 'cjs' | 'es' | 'src' , string > >
You can’t perform that action at this time.
0 commit comments