Skip to content

Commit

Permalink
simplify monaco webpack example
Browse files Browse the repository at this point in the history
  • Loading branch information
acao committed Feb 24, 2023
1 parent f801221 commit 04c876b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
18 changes: 0 additions & 18 deletions examples/monaco-graphql-webpack/src/editors.ts
Original file line number Diff line number Diff line change
@@ -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') ??
`
Expand Down
9 changes: 9 additions & 0 deletions examples/monaco-graphql-webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 04c876b

Please sign in to comment.