@@ -4,6 +4,7 @@ import type MonacoTypes from 'monaco-editor';
4
4
import type { EditorProps , EditorStore } from './editor' ;
5
5
import type { ReplStore } from './types' ;
6
6
import { getColorPreference } from '../components/theme-toggle/theme-toggle' ;
7
+ import { bundled , getNpmCdnUrl } from './bundled' ;
7
8
8
9
export const initMonacoEditor = async (
9
10
containerElm : any ,
@@ -26,7 +27,6 @@ export const initMonacoEditor = async (
26
27
noEmit : true ,
27
28
skipLibCheck : true ,
28
29
target : ts . ScriptTarget . Latest ,
29
- typeRoots : [ 'node_modules/@types' ] ,
30
30
} ) ;
31
31
32
32
ts . javascriptDefaults . setDiagnosticsOptions ( {
@@ -199,9 +199,10 @@ export const addQwikLibs = async (version: string) => {
199
199
200
200
const deps = await loadDeps ( version ) ;
201
201
deps . forEach ( ( dep ) => {
202
- if ( dep && typeof dep . code === 'string' && typeof dep . path === 'string' ) {
202
+ if ( dep && typeof dep . code === 'string' ) {
203
203
typescriptDefaults . addExtraLib (
204
- `declare module '${ dep . pkgName } ${ dep . import } ' { ${ dep . code } }`
204
+ `declare module '${ dep . pkgName } ${ dep . import } ' { ${ dep . code } }` ,
205
+ `/node_modules/${ dep . pkgName } ${ dep . pkgPath } `
205
206
) ;
206
207
}
207
208
} ) ;
@@ -217,31 +218,27 @@ const loadDeps = async (qwikVersion: string) => {
217
218
pkgVersion : qwikVersion ,
218
219
pkgPath : '/core.d.ts' ,
219
220
import : '' ,
220
- path : '/node_modules/@types/builder.io__qwik/index.d.ts' ,
221
221
} ,
222
222
// JSX runtime
223
223
{
224
224
pkgName : '@builder.io/qwik' ,
225
225
pkgVersion : qwikVersion ,
226
226
pkgPath : '/jsx-runtime.d.ts' ,
227
227
import : '/jsx-runtime' ,
228
- path : '/node_modules/@types/builder.io__qwik/jsx-runtime.d.ts' ,
229
228
} ,
230
229
// server API
231
230
{
232
231
pkgName : '@builder.io/qwik' ,
233
232
pkgVersion : qwikVersion ,
234
233
pkgPath : '/server.d.ts' ,
235
234
import : '/server' ,
236
- path : '/node_modules/@types/builder.io__qwik/server.d.ts' ,
237
235
} ,
238
236
// build constants
239
237
{
240
238
pkgName : '@builder.io/qwik' ,
241
239
pkgVersion : qwikVersion ,
242
240
pkgPath : '/build/index.d.ts' ,
243
241
import : '/build' ,
244
- path : '/node_modules/@types/builder.io__qwik/build/index.d.ts' ,
245
242
} ,
246
243
] ;
247
244
@@ -258,7 +255,6 @@ const loadDeps = async (qwikVersion: string) => {
258
255
pkgName : dep . pkgName ,
259
256
pkgVersion : dep . pkgVersion ,
260
257
pkgPath : dep . pkgPath ,
261
- path : dep . path ,
262
258
import : dep . import ,
263
259
} ;
264
260
monacoCtx . deps . push ( storedDep ) ;
@@ -278,7 +274,7 @@ const loadDeps = async (qwikVersion: string) => {
278
274
} ;
279
275
280
276
const fetchDep = async ( cache : Cache , dep : NodeModuleDep ) => {
281
- const url = getCdnUrl ( dep . pkgName , dep . pkgVersion , dep . pkgPath ) ;
277
+ const url = getNpmCdnUrl ( bundled , dep . pkgName , dep . pkgVersion , dep . pkgPath ) ;
282
278
const req = new Request ( url ) ;
283
279
const cachedRes = await cache . match ( req ) ;
284
280
if ( cachedRes ) {
@@ -336,12 +332,8 @@ const monacoCtx: MonacoContext = {
336
332
tsWorker : null ,
337
333
} ;
338
334
339
- const getCdnUrl = ( pkgName : string , pkgVersion : string , pkgPath : string ) => {
340
- return `https://cdn.jsdelivr.net/npm/${ pkgName } @${ pkgVersion } ${ pkgPath } ` ;
341
- } ;
342
-
343
335
const MONACO_VERSION = '0.45.0' ;
344
- const MONACO_VS_URL = getCdnUrl ( 'monaco-editor' , MONACO_VERSION , '/min/vs' ) ;
336
+ const MONACO_VS_URL = getNpmCdnUrl ( bundled , 'monaco-editor' , MONACO_VERSION , '/min/vs' ) ;
345
337
const MONACO_LOADER_URL = `${ MONACO_VS_URL } /loader.js` ;
346
338
347
339
const CLIENT_LIB = `
@@ -373,7 +365,6 @@ interface NodeModuleDep {
373
365
pkgPath : string ;
374
366
import : string ;
375
367
pkgVersion : string ;
376
- path : string ;
377
368
code ?: string ;
378
369
promise ?: Promise < void > ;
379
370
}
0 commit comments