diff --git a/examples/monaco-graphql-webpack/src/editors.ts b/examples/monaco-graphql-webpack/src/editors.ts index 59aaa86b772..1c56e7436dd 100644 --- a/examples/monaco-graphql-webpack/src/editors.ts +++ b/examples/monaco-graphql-webpack/src/editors.ts @@ -1,25 +1,7 @@ import * as monaco from 'monaco-editor'; -// NOTE: using loader syntax because Yaml worker imports editor.worker directly and that -// import shouldn't go through loader syntax. -// @ts-expect-error -import GraphQLWorker from 'monaco-graphql/esm/graphql.worker'; // eslint-disable-line import/default - const GRAPHQL_LANGUAGE_ID = 'graphql'; -// @ts-expect-error -window.MonacoEnvironment = { - getWorker(_workerId: string, label: string) { - if (label === GRAPHQL_LANGUAGE_ID) { - return new GraphQLWorker(); - } - if (label === 'json') { - return new Worker('/json.worker.js'); - } - return new Worker('/editor.worker.js'); - }, -}; - const operationString = localStorage.getItem('operations') ?? ` diff --git a/examples/monaco-graphql-webpack/webpack.config.js b/examples/monaco-graphql-webpack/webpack.config.js index da8b894b426..1a176ecef10 100644 --- a/examples/monaco-graphql-webpack/webpack.config.js +++ b/examples/monaco-graphql-webpack/webpack.config.js @@ -75,6 +75,15 @@ const resultConfig = { new MonacoWebpackPlugin({ languages: ['json', 'graphql'], publicPath: '/', + customLanguages: [ + { + label: 'graphql', + worker: { + id: 'graphql', + entry: require.resolve('monaco-graphql/esm/graphql.worker.js'), + }, + }, + ], }), ], resolve: {