Handle local type definitions in Monaco #2883
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
There are two fixes in this PR:
The upshot of this is: if you're developing an adaptor locally and you want to see whether the typings are working in Monaco, you can.
This PR does not address the issue of fixing adaptor docs locally.
Local Adaptors
So if you do
LOCAL_ADAPTORS=true mix phx.server
, Lightning will very cleverly go off and load adaptors straight out of your monorepo. Neato.There are two things that break:
This PR addresses the first point by telling Monaco's supporting code to load
@load
adaptor definitions from a local server.What local server, you say?
TODO: local serve support
I could use some help here!
For this to work right now, you have to go into
adaptors
and runPORT=5000 npx serve --cors
to create a local web server to host requests for d.ts files.This is fine, and I could just go off and document this. But before I do: could we have Lightning run that command if
LOCAL_ADAPTORS
is set? Then this stuff can just work automatically.QA Notes
It would be great to go through a couple of key adaptors (including dhis2 metadata) and ensure that language support is consistent across this branch and main. There's one change which I'm a little worried about.
Note that I think metadata for dhis2 is actually broken in production right now. I need to investigate separately.
AI Usage
Please disclose how you've used AI in this work (it's cool, we just want to know!):
You can read more details in our Responsible AI Policy