@@ -11,6 +11,8 @@ import { OutputModes } from './output/types'
11
11
12
12
const defaultMainFile = 'App.vue'
13
13
14
+ export const importMapFile = 'import-map.json'
15
+
14
16
const welcomeCode = `
15
17
<script setup>
16
18
import { ref } from 'vue'
@@ -206,7 +208,7 @@ export class ReplStore implements Store {
206
208
207
209
serialize ( ) {
208
210
const files = this . getFiles ( )
209
- const importMap = files [ 'import-map.json' ]
211
+ const importMap = files [ importMapFile ]
210
212
if ( importMap ) {
211
213
const { imports } = JSON . parse ( importMap )
212
214
if ( imports [ 'vue' ] === this . defaultVueRuntimeURL ) {
@@ -216,9 +218,9 @@ export class ReplStore implements Store {
216
218
delete imports [ 'vue/server-renderer' ]
217
219
}
218
220
if ( ! Object . keys ( imports ) . length ) {
219
- delete files [ 'import-map.json' ]
221
+ delete files [ importMapFile ]
220
222
} else {
221
- files [ 'import-map.json' ] = JSON . stringify ( { imports } , null , 2 )
223
+ files [ importMapFile ] = JSON . stringify ( { imports } , null , 2 )
222
224
}
223
225
}
224
226
return '#' + utoa ( JSON . stringify ( files ) )
@@ -255,10 +257,10 @@ export class ReplStore implements Store {
255
257
}
256
258
257
259
private initImportMap ( ) {
258
- const map = this . state . files [ 'import-map.json' ]
260
+ const map = this . state . files [ importMapFile ]
259
261
if ( ! map ) {
260
- this . state . files [ 'import-map.json' ] = new File (
261
- 'import-map.json' ,
262
+ this . state . files [ importMapFile ] = new File (
263
+ importMapFile ,
262
264
JSON . stringify (
263
265
{
264
266
imports : {
@@ -292,7 +294,7 @@ export class ReplStore implements Store {
292
294
293
295
getImportMap ( ) {
294
296
try {
295
- return JSON . parse ( this . state . files [ 'import-map.json' ] . code )
297
+ return JSON . parse ( this . state . files [ importMapFile ] . code )
296
298
} catch ( e ) {
297
299
this . state . errors = [
298
300
`Syntax error in import-map.json: ${ ( e as Error ) . message } `
@@ -305,7 +307,7 @@ export class ReplStore implements Store {
305
307
imports : Record < string , string >
306
308
scopes ?: Record < string , Record < string , string > >
307
309
} ) {
308
- this . state . files [ 'import-map.json' ] ! . code = JSON . stringify ( map , null , 2 )
310
+ this . state . files [ importMapFile ] ! . code = JSON . stringify ( map , null , 2 )
309
311
}
310
312
311
313
async setVueVersion ( version : string ) {
0 commit comments