@@ -54,20 +54,32 @@ const openHtmlEditor = async (code: string, options?: EditorOptions) => {
5454 options ?. includeIonContent ? 'html/index.withContent.html' : 'html/index.html' ,
5555 'html/variables.css' ,
5656 'html/package.json' ,
57+ 'html/tsconfig.json' ,
58+ 'html/vite.config.ts' ,
5759 ] ,
5860 options . version
5961 ) ;
6062
63+ const package_json = JSON . parse ( defaultFiles [ 3 ] ) ;
64+
65+ if ( options ?. dependencies ) {
66+ package_json . dependencies = {
67+ ...package_json . dependencies ,
68+ ...options . dependencies ,
69+ } ;
70+ }
71+
6172 const indexHtml = 'index.html' ;
6273 const files = {
74+ 'package.json' : JSON . stringify ( package_json , null , 2 ) ,
6375 'index.ts' : defaultFiles [ 0 ] ,
6476 [ indexHtml ] : defaultFiles [ 1 ] ,
6577 'theme/variables.css' : defaultFiles [ 2 ] ,
78+ 'tsconfig.json' : defaultFiles [ 4 ] ,
79+ 'vite.config.ts' : defaultFiles [ 5 ] ,
6680 ...options ?. files ,
6781 } ;
6882
69- const package_json = defaultFiles [ 3 ] ;
70-
7183 files [ indexHtml ] = defaultFiles [ 1 ] . replace ( / { { T E M P L A T E } } / g, code ) . replace (
7284 '</head>' ,
7385 `
@@ -82,23 +94,11 @@ const openHtmlEditor = async (code: string, options?: EditorOptions) => {
8294`
8395 ) ;
8496
85- let dependencies = { } ;
86- try {
87- dependencies = {
88- ...dependencies ,
89- ...JSON . parse ( package_json ) . dependencies ,
90- ...options ?. dependencies ,
91- } ;
92- } catch ( e ) {
93- console . error ( 'Failed to parse package.json contents' , e ) ;
94- }
95-
9697 sdk . openProject ( {
97- template : 'typescript ' ,
98+ template : 'node ' ,
9899 title : options ?. title ?? DEFAULT_EDITOR_TITLE ,
99100 description : options ?. description ?? DEFAULT_EDITOR_DESCRIPTION ,
100101 files,
101- dependencies,
102102 } ) ;
103103} ;
104104
0 commit comments