@@ -54,20 +54,32 @@ const openHtmlEditor = async (code: string, options?: EditorOptions) => {
54
54
options ?. includeIonContent ? 'html/index.withContent.html' : 'html/index.html' ,
55
55
'html/variables.css' ,
56
56
'html/package.json' ,
57
+ 'html/tsconfig.json' ,
58
+ 'html/vite.config.ts' ,
57
59
] ,
58
60
options . version
59
61
) ;
60
62
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
+
61
72
const indexHtml = 'index.html' ;
62
73
const files = {
74
+ 'package.json' : JSON . stringify ( package_json , null , 2 ) ,
63
75
'index.ts' : defaultFiles [ 0 ] ,
64
76
[ indexHtml ] : defaultFiles [ 1 ] ,
65
77
'theme/variables.css' : defaultFiles [ 2 ] ,
78
+ 'tsconfig.json' : defaultFiles [ 4 ] ,
79
+ 'vite.config.ts' : defaultFiles [ 5 ] ,
66
80
...options ?. files ,
67
81
} ;
68
82
69
- const package_json = defaultFiles [ 3 ] ;
70
-
71
83
files [ indexHtml ] = defaultFiles [ 1 ] . replace ( / { { T E M P L A T E } } / g, code ) . replace (
72
84
'</head>' ,
73
85
`
@@ -82,23 +94,11 @@ const openHtmlEditor = async (code: string, options?: EditorOptions) => {
82
94
`
83
95
) ;
84
96
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
-
96
97
sdk . openProject ( {
97
- template : 'typescript ' ,
98
+ template : 'node ' ,
98
99
title : options ?. title ?? DEFAULT_EDITOR_TITLE ,
99
100
description : options ?. description ?? DEFAULT_EDITOR_DESCRIPTION ,
100
101
files,
101
- dependencies,
102
102
} ) ;
103
103
} ;
104
104
0 commit comments