Skip to content

Commit 511eb0f

Browse files
Spencerspalgerkibanamachine
authored
[babel/register] remove from build (#79176)
Co-authored-by: spalger <spalger@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent c456f64 commit 511eb0f

File tree

21 files changed

+101
-63
lines changed

21 files changed

+101
-63
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@
115115
]
116116
},
117117
"dependencies": {
118-
"@babel/core": "^7.11.1",
119-
"@babel/register": "^7.10.5",
120118
"@elastic/datemath": "5.0.3",
121119
"@elastic/elasticsearch": "7.9.1",
122120
"@elastic/eui": "29.0.0",
@@ -128,7 +126,6 @@
128126
"@hapi/wreck": "^15.0.2",
129127
"@kbn/analytics": "1.0.0",
130128
"@kbn/apm-config-loader": "1.0.0",
131-
"@kbn/babel-preset": "1.0.0",
132129
"@kbn/config": "1.0.0",
133130
"@kbn/config-schema": "1.0.0",
134131
"@kbn/i18n": "1.0.0",
@@ -214,6 +211,7 @@
214211
"rxjs": "^6.5.5",
215212
"seedrandom": "^3.0.5",
216213
"semver": "^5.7.0",
214+
"source-map-support": "^0.5.19",
217215
"style-it": "^2.1.3",
218216
"symbol-observable": "^1.2.0",
219217
"tar": "4.4.13",
@@ -227,7 +225,9 @@
227225
"yauzl": "^2.10.0"
228226
},
229227
"devDependencies": {
228+
"@babel/core": "^7.11.1",
230229
"@babel/parser": "^7.11.2",
230+
"@babel/register": "^7.10.5",
231231
"@babel/types": "^7.11.0",
232232
"@elastic/apm-rum": "^5.6.1",
233233
"@elastic/charts": "23.0.0",
@@ -238,6 +238,7 @@
238238
"@elastic/github-checks-reporter": "0.0.20b3",
239239
"@elastic/makelogs": "^6.0.0",
240240
"@elastic/ui-ace": "0.2.3",
241+
"@kbn/babel-preset": "1.0.0",
241242
"@kbn/dev-utils": "1.0.0",
242243
"@kbn/es": "1.0.0",
243244
"@kbn/es-archiver": "1.0.0",

packages/kbn-babel-preset/node_preset.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,5 @@ module.exports = (_, options = {}) => {
4949
],
5050
require('./common_preset'),
5151
],
52-
plugins: [
53-
[
54-
require.resolve('babel-plugin-transform-define'),
55-
{
56-
'global.__BUILT_WITH_BABEL__': 'true',
57-
},
58-
],
59-
],
6052
};
6153
};

packages/kbn-babel-preset/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"@babel/preset-typescript": "^7.10.4",
1515
"babel-plugin-add-module-exports": "^1.0.2",
1616
"babel-plugin-styled-components": "^1.10.7",
17-
"babel-plugin-transform-define": "^1.3.1",
1817
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
1918
"react-is": "^16.8.0",
2019
"styled-components": "^5.1.0"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
22+
const { REPO_ROOT } = require('@kbn/dev-utils');
23+
24+
// modifies all future calls to require() to automatically
25+
// compile the required source with babel
26+
require('@babel/register')({
27+
ignore: [/[\/\\](node_modules|target|dist)[\/\\]/],
28+
only: [
29+
Path.resolve(REPO_ROOT, 'test'),
30+
Path.resolve(REPO_ROOT, 'x-pack/test'),
31+
Path.resolve(REPO_ROOT, 'examples'),
32+
Path.resolve(REPO_ROOT, 'x-pack/examples'),
33+
// TODO: should should probably remove this link back to the source
34+
Path.resolve(REPO_ROOT, 'x-pack/plugins/task_manager/server/config.ts'),
35+
],
36+
babelrc: false,
37+
presets: [require.resolve('@kbn/babel-preset/node_preset')],
38+
extensions: ['.js', '.ts', '.tsx'],
39+
});

packages/kbn-test/src/functional_tests/lib/run_kibana_server.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,26 @@
1717
* under the License.
1818
*/
1919

20-
import { resolve } from 'path';
20+
import { resolve, relative } from 'path';
2121
import { KIBANA_ROOT, KIBANA_EXEC, KIBANA_EXEC_PATH } from './paths';
2222

23+
function extendNodeOptions(installDir) {
24+
if (!installDir) {
25+
return {};
26+
}
27+
28+
const testOnlyRegisterPath = relative(
29+
installDir,
30+
require.resolve('./babel_register_for_test_plugins')
31+
);
32+
33+
return {
34+
NODE_OPTIONS: `--require=${testOnlyRegisterPath}${
35+
process.env.NODE_OPTIONS ? ` ${process.env.NODE_OPTIONS}` : ''
36+
}`,
37+
};
38+
}
39+
2340
export async function runKibanaServer({ procs, config, options }) {
2441
const { installDir } = options;
2542

@@ -29,6 +46,7 @@ export async function runKibanaServer({ procs, config, options }) {
2946
env: {
3047
FORCE_COLOR: 1,
3148
...process.env,
49+
...extendNodeOptions(installDir),
3250
},
3351
cwd: installDir || KIBANA_ROOT,
3452
wait: /http server running/,

scripts/build_plugin_list_docs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
* under the License.
1818
*/
1919

20-
require('../src/setup_node_env/prebuilt_dev_only_entry');
20+
require('../src/setup_node_env/no_transpilation');
2121
require('@kbn/dev-utils').runPluginListCli();

scripts/es.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
require('../src/setup_node_env/prebuilt_dev_only_entry');
20+
require('../src/setup_node_env/no_transpilation');
2121

2222
var resolve = require('path').resolve;
2323
var pkg = require('../package.json');

scripts/generate_plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
* under the License.
1818
*/
1919

20-
require('../src/setup_node_env/prebuilt_dev_only_entry');
20+
require('../src/setup_node_env/no_transpilation');
2121
require('@kbn/plugin-generator').runCli();

scripts/plugin_helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
* under the License.
1818
*/
1919

20-
require('../src/setup_node_env/prebuilt_dev_only_entry');
20+
require('../src/setup_node_env/no_transpilation');
2121
require('@kbn/plugin-helpers').runCli();

scripts/register_git_hook.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
* under the License.
1818
*/
1919

20-
require('../src/setup_node_env/prebuilt_dev_only_entry');
20+
require('../src/setup_node_env/no_transpilation');
2121
require('@kbn/dev-utils/target/precommit_hook/cli');

0 commit comments

Comments
 (0)