-
Notifications
You must be signed in to change notification settings - Fork 54
feat: export modules required by graphiql #702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: export modules required by graphiql #702
Conversation
7597898
to
bd51c4d
Compare
Thanks!
Sure! tell me more about what's blocking you?
It is indeed a monaco-editor specific file, and as you said it's just re-exporting editor.api.js so it can be replaced safely You can probably to something similar to what is done for editor.worker.js, just doing |
Awesome, updated the config to include the [!] Error: Cannot find module '../util/utimes.js'
Require stack:
- /workspaces/monaco-vscode-api/node_modules/rollup-plugin-copy/node_modules/fs-extra/lib/copy-sync/copy-sync.js
- /workspaces/monaco-vscode-api/node_modules/rollup-plugin-copy/node_modules/fs-extra/lib/copy-sync/index.js
- /workspaces/monaco-vscode-api/node_modules/rollup-plugin-copy/node_modules/fs-extra/lib/index.js
- /workspaces/monaco-vscode-api/node_modules/rollup-plugin-copy/dist/index.commonjs.js I'm using MacOS 15.7 and running in the dev-container provided in the repo. |
Hum very weird error 🤔 Never seen it before does |
Ok I did a complete uninstall and reinstall and now I was able to build the packages without errors. "resolutions": {
"@codingame/monaco-vscode-api": "portal:<REDACTED>/monaco-vscode-api/dist/packages/monaco-vscode-api",
"monaco-editor": "portal:<REDACTED>/monaco-vscode-api/dist/packages/monaco-vscode-editor-api"
} But running $ yarn
➤ YN0000: · Yarn 4.9.4
➤ YN0000: ┌ Project validation
➤ YN0057: │ @wiz/portal: Resolutions field will be ignored
➤ YN0000: └ Completed
➤ YN0000: ┌ Resolution step
➤ YN0082: │ @codingame/monaco-vscode-5452e2b7-9081-5f95-839b-4ab3544ce28f-common@npm:0.0.0-semantic-release: No candidates found
➤ YN0000: └ Completed in 1s 754ms
➤ YN0000: · Failed with errors in 1s 759ms |
yes, it references the version The simplest way is probably to not try to install the package, but simply copy the content of the package in your node_modules by hands |
What is the status? do you consider it ready to be merged? I'm not sure since you just merged main into it |
No sorry, it's not ready yet. Had to take a break and only now I'm returning to it so I made sure to work on the latest version. |
Seems that |
The standalone languages are bundled in An option is to create an empty module at that location |
What do you mean? you're the one expected to provide the
Probably not a good idea |
IIUC, the
How should we do it then? |
I do think monaco-languageclient allows to register your own workers, if you can't use
I don't know what it is doing exactly, nothing else is required 🤷 |
Hi @dorshinar you can supply your own workerFactory. This is best demonstrated in the unit tests: |
Got it @kaisalmen, I switched to calling But I'm still seeing these errors: The error comes from here, where the |
@dorshinar have you considered to pre-bundle the graphql worker with rollup or esbuild? It might circumvent the problem. |
@kaisalmen I believe this is handled by vite automatically Can you elaborate? |
It is possible to just bundle the worker as single ESM file, then the build performing the production build will not see a need to touch/transform it. Depending on the build tooling (I have next.js / webpack in mind here) this can circumvent issues. But it may not help in your situation. |
Got it, so this may solve the second issue. |
I did some more digging. I looked at how the I debugged a working example from the Graphiql repo, and saw that the Do you have any idea where the problem might be? |
Monaco-editor workers has changed quite a lot in the last monaco-editor version. We had a compatibility layer until monaco-editor 53 is out that is now removed, and it was about |
I think it's not working with 0.53, and your explanation makes sense. |
Here's the backward compatibility code that was removed in the last versions: d3fcbe9 I guess you can apply that patch in your node_modules until graphiql updates |
Awesome, it works! I believe the error originates from the Uncaught (in promise) FileOperationError: Unable to read file '/r1j-variables.json' (Error: Unable to resolve nonexistent file '/r1j-variables.json')
at FileServiceOverride.restoreReadError (fileService.js:537:18)
at FileServiceOverride.doReadFileStream (fileService.js:521:24)
at async BrowserTextFileService2.doRead (textFileService.js:170:28)
at async BrowserTextFileService2.readStream (textFileService.js:152:41)
at async _a3.resolveFromFile (textFileEditorModel.js:297:29)
at async _a3.resolve (textFileEditorModel.js:198:9)
at async TextFileEditorModelManager2.doResolve (textFileEditorModelManager.js:294:13)
at async ResourceModelCollection2.doCreateReferencedObject (textModelResolverService.js:53:27)
at async AsyncReferenceCollection.acquire (lifecycle.js:432:28)
at async TextModelResolverService2.createModelReference (textModelResolverService.js:176:16) EDIT: |
Regarding my issue of a file not being created, I see that Because it's called in |
The issue with using createModel is that no ref on it will exist, so it may crash the next time createModelReference is called, which is done internally in VSCode
Also make sure to not be disposing the model reference until graphiql doesn't need it anymore or the model may be deleted |
Got it. Tried that and now I'm not getting the error in the console, but the variables JSON validation is still not working. {
"schemaValidation": "error",
"validate": true,
"allowComments": true,
"trailingCommas": "ignore",
"schemas": [
{
"uri": "file:///file%3A///r1j-variables-schema.json",
"schema": {
"$schema": "http://json-schema.org/draft-04/schema",
"type": "object",
"properties": {...},
"required": [...],
"additionalProperties": false,
"definitions": {...},
"$id": "monaco://variables-schema.json",
"title": "GraphQL Variables"
},
"fileMatch": [
"file:///r1j-variables.json"
]
}
],
"enableSchemaRequest": false
} But no markers are shown. I tried adding more imports, but to no avail. This is what I have now: import '@codingame/monaco-vscode-standalone-languages';
import '@codingame/monaco-vscode-standalone-json-language-features';
import '@codingame/monaco-vscode-json-default-extension';
import '@codingame/monaco-vscode-json-language-features-default-extension';
import getLanguageServiceOverride from '@codingame/monaco-vscode-languages-service-override';
import getFilesServiceOverride from '@codingame/monaco-vscode-files-service-override';
import getMarkersServiceOverride from '@codingame/monaco-vscode-markers-service-override';
import getBaseServiceOverride from '@codingame/monaco-vscode-base-service-override';
import getExtensionsServiceOverride from '@codingame/monaco-vscode-extensions-service-override';
import getModelServiceOverride from '@codingame/monaco-vscode-model-service-override'; Am I missing something? |
Do you have a minimal reproduction project to provide? |
Sure. query MyQuery ($limit: Int) {
ability(limit: $limit) {
generaton_id
}
} With this variables json: {
"limdit": 1
} The But |
would you mind packing the modified libraries and installing them on your project so I don't have to rebuild them? |
Yeah sure, do you want me to zip the node_modules folder? |
I meant:
That's what I do when I need to use a non-published yet library |
Ok it's maybe more complicated than that 🤔 let's merge and deploy this MR, and then open another issue for that problem? |
Fine by me |
Opened a separate issue. |
🎉 This PR is included in version 22.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Hi! :)
Following up on this issue, I added the necessary exports for Graphiql to work.
However, I can't validate it because I was not able to build the project locally and link all created packages to my project.
Would you be able to help me with that?
There's also another file missing that I couldn't figure out how to include. It's
/monaco-editor/esm/vs/editor/edcore.main.js
that you can see here. The file is simply re-exporting some things, and I think that for the Graphiql use caseexport * from './editor.api.js';
would be enough, as theeditor.api.js
already exists.In monaco's source code I believe it is generated by the bundler here, I'm not sure how to mimic this behavior in rollup so I would appreciate any help with that. It's also fine to include a static file with the necessary export.
Thank you very much!