Skip to content

Commit 0e2c1a0

Browse files
iahuacao
andauthored
fix: monaco-graphql worker issue, es module config should use esNext (#1979)
* fix: fix failed to create graphql worker * Update workerManager.ts Co-authored-by: Rikki Schulte <[email protected]>
1 parent afaa36c commit 0e2c1a0

File tree

6 files changed

+25
-6
lines changed

6 files changed

+25
-6
lines changed

.changeset/afraid-nails-trade.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"graphql-language-service": patch
3+
"monaco-graphql": patch
4+
---
5+
6+
fix: export `monaco-graphql` esm with esm modules, also fix issues with worker manager, resolves #1706 & #1791

packages/graphql-language-service/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
},
3232
"dependencies": {
3333
"graphql-language-service-interface": "^2.8.2",
34-
"graphql-language-service-types": "^1.8.0"
34+
"graphql-language-service-parser": "^1.9.2",
35+
"graphql-language-service-types": "^1.8.2",
36+
"graphql-language-service-utils": "^2.5.3"
3537
},
3638
"devDependencies": {
3739
"graphql": "experimental-stream-defer"

packages/monaco-graphql/src/GraphQLWorker.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,14 @@ export class GraphQLWorker {
124124
return '';
125125
}
126126
}
127+
128+
export default {
129+
GraphQLWorker,
130+
};
131+
132+
export function create(
133+
ctx: worker.IWorkerContext,
134+
createData: ICreateData,
135+
): GraphQLWorker {
136+
return new GraphQLWorker(ctx, createData);
137+
}

packages/monaco-graphql/src/monaco.contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
modeConfigurationDefault,
1414
} from './api';
1515

16-
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
16+
import * as monaco from 'monaco-editor';
1717

1818
export * from './typings';
1919

packages/monaco-graphql/src/workerManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import { editor as monacoEditor } from 'monaco-editor/esm/vs/editor/editor.api';
8+
import { editor as monacoEditor } from 'monaco-editor';
99
import { LanguageServiceAPI } from './api';
1010
import { GraphQLWorker } from './GraphQLWorker';
1111

@@ -68,7 +68,7 @@ export class WorkerManager {
6868
if (!this._client) {
6969
this._worker = monacoEditor.createWebWorker<GraphQLWorker>({
7070
// module that exports the create() method and returns a `GraphQLWorker` instance
71-
moduleId: 'vs/language/graphql/graphqlWorker',
71+
moduleId: 'monaco-graphql/esm/GraphQLWorker.js',
7272

7373
label: this._defaults.languageId,
7474
// passed in to the create() method
@@ -86,7 +86,7 @@ export class WorkerManager {
8686
try {
8787
this._client = await this._worker.getProxy();
8888
} catch (error) {
89-
throw Error('Error loading serviceworker proxy');
89+
// throw Error(error);
9090
}
9191
}
9292
return this._client as GraphQLWorker;

packages/monaco-graphql/tsconfig.esm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "../../resources/tsconfig.base.esm.json",
33
"compilerOptions": {
4-
"module": "amd",
4+
"module": "ESNext",
55
"moduleResolution": "node",
66
"baseUrl": ".",
77
"rootDir": "./src",

0 commit comments

Comments
 (0)