File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,12 @@ export function initMonaco(store: Store) {
41
41
initted = true
42
42
}
43
43
44
+ export class WorkerHost {
45
+ onFetchCdnFile ( uri : string , text : string ) {
46
+ getOrCreateModel ( Uri . parse ( uri ) , undefined , text )
47
+ }
48
+ }
49
+
44
50
let disposeVue : undefined | ( ( ) => void )
45
51
export async function reloadLanguageTools ( store : Store ) {
46
52
disposeVue ?.( )
@@ -74,6 +80,7 @@ export async function reloadLanguageTools(store: Store) {
74
80
const worker = editor . createWebWorker < LanguageService > ( {
75
81
moduleId : 'vs/language/vue/vueWorker' ,
76
82
label : 'vue' ,
83
+ host : new WorkerHost ( ) ,
77
84
createData : {
78
85
tsconfig : store . getTsConfig ?.( ) || { } ,
79
86
dependencies,
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import {
12
12
createVueLanguagePlugin ,
13
13
resolveVueCompilerOptions ,
14
14
} from '@vue/language-service'
15
- import type { WorkerMessage } from './env'
15
+ import type { WorkerHost , WorkerMessage } from './env'
16
16
import { URI } from 'vscode-uri'
17
17
18
18
export interface CreateData {
@@ -36,7 +36,7 @@ self.onmessage = async (msg: MessageEvent<WorkerMessage>) => {
36
36
37
37
worker . initialize (
38
38
(
39
- ctx : monaco . worker . IWorkerContext ,
39
+ ctx : monaco . worker . IWorkerContext < WorkerHost > ,
40
40
{
41
41
tsconfig,
42
42
// TODO
@@ -58,7 +58,12 @@ self.onmessage = async (msg: MessageEvent<WorkerMessage>) => {
58
58
tsconfig . vueCompilerOptions || { } ,
59
59
)
60
60
61
- activateAutomaticTypeAcquisition ( env , { asFileName } )
61
+ activateAutomaticTypeAcquisition ( env , { asFileName } , ( path , content ) => {
62
+ ctx . host . onFetchCdnFile (
63
+ asUri ( '/node_modules/' + path ) . toString ( ) ,
64
+ content ,
65
+ )
66
+ } )
62
67
63
68
return createTypeScriptWorkerService ( {
64
69
typescript : ts ,
You can’t perform that action at this time.
0 commit comments