@@ -113,11 +113,14 @@ viteProcess.on('close', (code) => {
113113
114114 const tsconfigNodeJSONPath = resolve ( cwd , 'tsconfig.node.json' )
115115 const tsconfigNodeJSON = readFileSync ( tsconfigNodeJSONPath , 'utf-8' )
116- const modifiedTsconfigNodeJSON = tsconfigNodeJSON . replace (
117- '"compilerOptions": {' ,
118- '"compilerOptions": {\n "lib": ["ESNext"],'
119- )
120- writeFileSync ( tsconfigNodeJSONPath , modifiedTsconfigNodeJSON , 'utf8' )
116+
117+ if ( ! tsconfigNodeJSON . includes ( '"lib": ["ESNext"],' ) ) {
118+ const modifiedTsconfigNodeJSON = tsconfigNodeJSON . replace (
119+ '"compilerOptions": {' ,
120+ '"compilerOptions": {\n "lib": ["ESNext"],'
121+ )
122+ writeFileSync ( tsconfigNodeJSONPath , modifiedTsconfigNodeJSON , 'utf8' )
123+ }
121124 }
122125
123126 // patching the vite.config.ts to make socket:* modules external
@@ -126,11 +129,14 @@ viteProcess.on('close', (code) => {
126129
127130 const viteConfigTSPath = resolve ( cwd , 'vite.config.ts' )
128131 const viteConfigTS = readFileSync ( viteConfigTSPath , 'utf-8' )
129- const modifiedViteConfigTS = viteConfigTS . replace (
130- 'defineConfig({' ,
131- 'defineConfig({\n build: {\n rollupOptions: {\n external(id) {\n return id.startsWith(\'socket:\')\n }\n }\n },'
132- )
133- writeFileSync ( viteConfigTSPath , modifiedViteConfigTS , 'utf8' )
132+
133+ if ( ! viteConfigTS . includes ( 'external(id)' ) ) {
134+ const modifiedViteConfigTS = viteConfigTS . replace (
135+ 'defineConfig({' ,
136+ 'defineConfig({\n build: {\n rollupOptions: {\n external(id) {\n return id.startsWith(\'socket:\')\n }\n }\n },'
137+ )
138+ writeFileSync ( viteConfigTSPath , modifiedViteConfigTS , 'utf8' )
139+ }
134140 }
135141
136142 process . stdout . write ( `\nDone!\n\nBuild and run your app with:\nssc build -r ${ projectName } ` )
0 commit comments