Skip to content

Commit

Permalink
[ES UI] Reintroduce import of brace/mode/json (elastic#78571)
Browse files Browse the repository at this point in the history
* added brace/mode/json import everywhere json mode is being used

* added brace mocks to tests

* slight refactor of imports

* remove import from es ui shared

* Reverse adding brace/mode/json import everywhere

- different approach of just adding brace/json/mode to
  es_ui_shared as before with a BIG comment

* updated @kbn/ace readme

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
jloleysens and elasticmachine committed Oct 1, 2020
1 parent dc658d6 commit f066434
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/kbn-ace/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# @kbn/ace

Contains all Kibana-specific brace related code. Excluding the code that still inside of Console because that code is only used inside of console at the moment.
This package contains the XJSON mode for brace. This is an extension of the `brace/mode/json` mode.

This package enables plugins to use this functionality and import it as needed -- behind an async import so that brace does not bloat the JS code needed for first page load of Kibana.
This package also contains an import of the entire brace editor which is used for creating the custom XJSON worker.

## Note to plugins
_This code should not be eagerly loaded_.

Make sure imports of this package are behind a lazy-load `import()` statement.

Your plugin should already be loading application code this way in the `mount` function.

## Deprecated

This package is considered deprecated and will be removed in future.

New and existing editor functionality should use Monaco.

_Do not add new functionality to this package_. Build new functionality for Monaco and use it instead.
15 changes: 15 additions & 0 deletions src/plugins/es_ui_shared/static/forms/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@
* under the License.
*/

/*
@TODO
The brace/mode/json import below is loaded eagerly - before this plugin is explicitly loaded by users. This makes
the brace JSON mode, used for JSON syntax highlighting and grammar checking, available across all of Kibana plugins.
This is not ideal because we are loading JS that is not necessary for Kibana to start, but the alternative
is breaking JSON mode for an unknown number of ace editors across Kibana - not all components reference the underlying
EuiCodeEditor (for instance, explicitly).
Importing here is a way of preventing a more sophisticated solution to this problem since we want to, eventually,
migrate all code editors over to Monaco. Once that is done, we should remove this import.
*/
import 'brace/mode/json';

export * from './field';
export * from './form_row';
export * from './fields';

0 comments on commit f066434

Please sign in to comment.