From 6ed73bf7ca9781d511458e70268deff203fd36cb Mon Sep 17 00:00:00 2001 From: Rikki Schulte Date: Sun, 19 Mar 2023 16:46:57 +0100 Subject: [PATCH] monaco example fixes, fix missing worker bug (#3093) * monaco example fixes, fix missing worker bug --- .changeset/happy-items-bathe.md | 5 +++++ examples/monaco-graphql-nextjs/.gitignore | 1 + examples/monaco-graphql-nextjs/package-lock.json | 6 +++--- examples/monaco-graphql-webpack/webpack.config.js | 2 +- packages/monaco-graphql/src/languageFeatures.ts | 6 ++++++ 5 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .changeset/happy-items-bathe.md create mode 100644 examples/monaco-graphql-nextjs/.gitignore diff --git a/.changeset/happy-items-bathe.md b/.changeset/happy-items-bathe.md new file mode 100644 index 00000000000..47670e107f7 --- /dev/null +++ b/.changeset/happy-items-bathe.md @@ -0,0 +1,5 @@ +--- +'monaco-graphql': patch +--- + +Bugfix for 'worker not found' type errors on \_doValidate()' diff --git a/examples/monaco-graphql-nextjs/.gitignore b/examples/monaco-graphql-nextjs/.gitignore new file mode 100644 index 00000000000..a680367ef56 --- /dev/null +++ b/examples/monaco-graphql-nextjs/.gitignore @@ -0,0 +1 @@ +.next diff --git a/examples/monaco-graphql-nextjs/package-lock.json b/examples/monaco-graphql-nextjs/package-lock.json index e9ee1f0a4bb..e1c8db9375a 100644 --- a/examples/monaco-graphql-nextjs/package-lock.json +++ b/examples/monaco-graphql-nextjs/package-lock.json @@ -1238,9 +1238,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.320", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.320.tgz", - "integrity": "sha512-h70iRscrNluMZPVICXYl5SSB+rBKo22XfuIS1ER0OQxQZpKTnFpuS6coj7wY9M/3trv7OR88rRMOlKmRvDty7Q==", + "version": "1.4.321", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.321.tgz", + "integrity": "sha512-ERuAqNq7YknVY3+47VbB+Q92kWH7O7sX3mkZINqZtsGJMQFb0dj71d5U3PRTihX03qt2NWIfZic2CCcGXOHJ7A==", "peer": true }, "node_modules/emoji-regex": { diff --git a/examples/monaco-graphql-webpack/webpack.config.js b/examples/monaco-graphql-webpack/webpack.config.js index 909023bbee2..577f2b1f5c2 100644 --- a/examples/monaco-graphql-webpack/webpack.config.js +++ b/examples/monaco-graphql-webpack/webpack.config.js @@ -55,7 +55,7 @@ const resultConfig = { // critical! make sure that webpack can consume the exported modules and types new ForkTsCheckerWebpackPlugin({ async: isDev, - tsconfig: rootPath('tsconfig.json'), + typescript: { configFile: rootPath('tsconfig.json') }, }), new MonacoWebpackPlugin({ diff --git a/packages/monaco-graphql/src/languageFeatures.ts b/packages/monaco-graphql/src/languageFeatures.ts index b8bb346a947..5203bcd0933 100644 --- a/packages/monaco-graphql/src/languageFeatures.ts +++ b/packages/monaco-graphql/src/languageFeatures.ts @@ -123,6 +123,12 @@ export class DiagnosticsAdapter { ) { const worker = await this._worker(resource); + // to handle an edge case bug that happens when + // typing before the schema is present + if (!worker) { + return; + } + const diagnostics = await worker.doValidation(resource.toString()); editor.setModelMarkers( editor.getModel(resource) as editor.ITextModel,