Skip to content

Commit c39243c

Browse files
[7.x] [ES UI Shared] Remove 'brace' from es_ui_shared public (#78033) (#78427)
* [ES UI Shared] Remove 'brace' from es_ui_shared public (#78033) * major wip * major wip * fix worker creation leak * just copy the file over for now * Remove xjson from static and from es_ui_shared entirely - moved expand and collapse logic back to es_ui_shared. It has nothing to do with ace - refactor the useXJson hook which bundled XJsonMode with it. This was convenient but ultimately inflates the amount of code Kibana needs to first load up in the client. Users will need to import XJsonMode and instantiate it when they want to use it. Updated existing usage. - Cleaned up Monaco namespace from es_ui_shared because of how useXJsonMode was refactored -- no longer exporting an editor specific instance means this code does not know about anything to do with code editors so it is decoupled from ace and monaco. * fix export of collapse and expand string literals Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> # Conflicts: # .github/CODEOWNERS # src/plugins/es_ui_shared/kibana.json * import brace json mode in raw vis editor Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 4c3068c commit c39243c

File tree

54 files changed

+192
-196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+192
-196
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@
135135
"@kbn/telemetry-tools": "1.0.0",
136136
"@kbn/test-subj-selector": "0.2.1",
137137
"@kbn/ui-framework": "1.0.0",
138+
"@kbn/ace": "1.0.0",
139+
"@kbn/monaco": "1.0.0",
138140
"@kbn/ui-shared-deps": "1.0.0",
139141
"@types/yauzl": "^2.9.1",
140142
"JSONStream": "1.3.5",

packages/kbn-ace/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# @kbn/ace
2+
3+
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.
4+
5+
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.

packages/kbn-ace/package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "@kbn/ace",
3+
"version": "1.0.0",
4+
"private": true,
5+
"main": "./target/index.js",
6+
"license": "Apache-2.0",
7+
"scripts": {
8+
"build": "node ./scripts/build.js",
9+
"kbn:bootstrap": "yarn build --dev"
10+
},
11+
"dependencies": {
12+
"brace": "0.11.1"
13+
},
14+
"devDependencies": {
15+
"@kbn/dev-utils": "1.0.0",
16+
"@kbn/babel-preset": "1.0.0",
17+
"raw-loader": "3.1.0",
18+
"typescript": "4.0.2"
19+
}
20+
}

packages/kbn-ace/scripts/build.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
const path = require('path');
21+
const del = require('del');
22+
const fs = require('fs');
23+
const supportsColor = require('supports-color');
24+
const { run } = require('@kbn/dev-utils');
25+
26+
const TARGET_BUILD_DIR = path.resolve(__dirname, '../target');
27+
const ROOT_DIR = path.resolve(__dirname, '../');
28+
const WORKER_PATH_SECTION = 'ace/modes/x_json/worker/x_json.ace.worker.js';
29+
30+
run(
31+
async ({ procRunner, log }) => {
32+
log.info('Deleting old output');
33+
34+
await del(TARGET_BUILD_DIR);
35+
36+
const cwd = ROOT_DIR;
37+
const env = { ...process.env };
38+
39+
if (supportsColor.stdout) {
40+
env.FORCE_COLOR = 'true';
41+
}
42+
43+
await procRunner.run('tsc ', {
44+
cmd: 'tsc',
45+
args: [],
46+
wait: true,
47+
env,
48+
cwd,
49+
});
50+
51+
log.success('Copying worker file to target.');
52+
53+
fs.copyFileSync(
54+
path.resolve(__dirname, '..', 'src', WORKER_PATH_SECTION),
55+
path.resolve(__dirname, '..', 'target', WORKER_PATH_SECTION)
56+
);
57+
58+
log.success('Complete');
59+
},
60+
{
61+
flags: {
62+
boolean: ['dev'],
63+
},
64+
}
65+
);

0 commit comments

Comments
 (0)