Skip to content

Commit d7668a0

Browse files
Spencerkibanamachine
andauthored
[babel/register] remove from build (take 2) (#79379) (#79382)
Co-authored-by: spalger <spalger@users.noreply.github.com> # Conflicts: # package.json Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent 9eeff6d commit d7668a0

25 files changed

Lines changed: 127 additions & 68 deletions

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@
112112
]
113113
},
114114
"dependencies": {
115-
"@babel/core": "^7.11.1",
116-
"@babel/register": "^7.10.5",
117115
"@elastic/datemath": "5.0.3",
118116
"@elastic/elasticsearch": "7.9.1",
119117
"@elastic/eui": "29.0.0",
@@ -125,7 +123,6 @@
125123
"@hapi/wreck": "^15.0.2",
126124
"@kbn/analytics": "1.0.0",
127125
"@kbn/apm-config-loader": "1.0.0",
128-
"@kbn/babel-preset": "1.0.0",
129126
"@kbn/config": "1.0.0",
130127
"@kbn/config-schema": "1.0.0",
131128
"@kbn/i18n": "1.0.0",
@@ -211,6 +208,7 @@
211208
"rxjs": "^6.5.5",
212209
"seedrandom": "^3.0.5",
213210
"semver": "^5.7.0",
211+
"source-map-support": "^0.5.19",
214212
"symbol-observable": "^1.2.0",
215213
"tar": "4.4.13",
216214
"tinygradient": "0.4.3",
@@ -223,7 +221,9 @@
223221
"yauzl": "^2.10.0"
224222
},
225223
"devDependencies": {
224+
"@babel/core": "^7.11.1",
226225
"@babel/parser": "^7.11.2",
226+
"@babel/register": "^7.10.5",
227227
"@babel/types": "^7.11.0",
228228
"@elastic/apm-rum": "^5.6.1",
229229
"@elastic/charts": "23.0.0",
@@ -234,6 +234,7 @@
234234
"@elastic/github-checks-reporter": "0.0.20b3",
235235
"@elastic/makelogs": "^6.0.0",
236236
"@elastic/ui-ace": "0.2.3",
237+
"@kbn/babel-preset": "1.0.0",
237238
"@kbn/dev-utils": "1.0.0",
238239
"@kbn/es": "1.0.0",
239240
"@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/kibana.js

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

20-
require('../src/apm')(process.env.ELASTIC_APM_PROXY_SERVICE_NAME || 'kibana-proxy');
21-
require('../src/setup_node_env');
22-
require('../src/cli/cli');
20+
require('../src/cli/dev');

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();

0 commit comments

Comments
 (0)