Move painless lang support to @kbn/monaco#81010
Move painless lang support to @kbn/monaco#81010alisonelizabeth merged 4 commits intoelastic:masterfrom
Conversation
| @@ -41,8 +34,7 @@ interface Language extends monaco.languages.IMonarchLanguage { | |||
| } | |||
|
|
|||
| export const lexerRules = { | |||
There was a problem hiding this comment.
As you can see, there are a few minor differences between the painless lexer rules in xjson (original code) and the lexer rules in painless lab (original code). I don't see why they would/should be different, but if there is a reason, please let me know.
| }, | ||
| } as Language; | ||
|
|
||
| monaco.languages.register({ id: ID }); |
There was a problem hiding this comment.
I noticed the xjson and painless languages were getting registered twice - once here (and in lexer_rules/xjson, respectively), and again in the registerLexerRules function. I assume this was a mistake, but wanted to call out here if not.
|
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
There was a problem hiding this comment.
Great work @alisonelizabeth ! I tested locally and everything seems to be working as expected!
I noticed this warning from Monaco when opening a page, like Painless lab, with a painless editor in it:
I think we need to re-introduce the behaviour of language_service.ts that did the following:
import workerSrc from 'raw-loader!monaco-editor/min/vs/base/worker/workerMain.js';
...
(window as any).MonacoEnvironment = {
getWorker: () => {
const blob = new Blob([workerSrc], { type: 'application/javascript' });
return new Worker(window.URL.createObjectURL(blob));
},
...In the global.ts file you created we should just add an if check for painless to suppress this warning. We also need to do this for Elasticsearch SQL esql.
One other thing that I want to get your thoughts on, non-blocking: I think renaming global.ts -> register_globals.ts and changing monaco.ts -> monaco_imports.ts might better communicate the intention behind these files. That way if I see import './reigster_globals' in the code it seems even clearer regarding the intention behind the file.
Overall these changes are looking great!
|
Thanks @jloleysens for the review!
👍 Good call. I went ahead and made this change. I think this is more explicit as well.
Good catch! For some reason, I don't recall seeing the warnings when I was doing initial testing, which is why I removed it. This should be fixed now via ac180cc. |
💚 Build SucceededMetrics [docs]@kbn/optimizer bundle module count
@kbn/ui-shared-deps asset size
async chunks size
distributable file count
page load bundle size
History
To update your PR or re-run it, just comment with: |

This PR includes some refactoring of the
@kbn/monacopackage. I started this work in #80577, but decided to break it up as a separate PR as it affects the XJSON support.painlessandesqllanguages, parallel toxjson. Thepainlesslanguage will eventually include autocomplete and error handling support (to be implemented in Support for painless language autocomplete within monaco #80577). I imagine we might at some point want to provide the same foresqltoo.global.tsfile that registers the languages and creates the web workers. There will eventually be a web worker for painless.languageServiceinpainless_lab. AFAICT this is no longer necessary.How to test
Verify there are no regressions in the XJSON support and syntax highlighting in painless lab. I'm fairly confident in the painless lab changes, but not so much for XJSON 😄 . I used the sample in #67485 to test, but there may be more use cases I should verify (in particular around
esqlsupport).