mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Timelion] Build optimization - move parser_async to chunk (#93766)
* [Timelion] Build optimization - move parser_async to chunk * Update parser_async.ts
This commit is contained in:
parent
542d66643e
commit
a3b848a5be
3 changed files with 21 additions and 6 deletions
15
src/plugins/vis_type_timelion/common/parser_async.ts
Normal file
15
src/plugins/vis_type_timelion/common/parser_async.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { ParsedExpression } from './parser';
|
||||
|
||||
/** Build optimizations, we want to exclude the parser from the main bundle **/
|
||||
export const parseTimelionExpressionAsync = async (input: string): Promise<ParsedExpression> => {
|
||||
const { parseTimelionExpression } = await import('../common/parser');
|
||||
return parseTimelionExpression(input);
|
||||
};
|
|
@ -9,8 +9,8 @@
|
|||
import { startsWith } from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { monaco } from '@kbn/monaco';
|
||||
import {
|
||||
parseTimelionExpression,
|
||||
import { parseTimelionExpressionAsync } from '../../common/parser_async';
|
||||
import type {
|
||||
ParsedExpression,
|
||||
TimelionExpressionArgument,
|
||||
ExpressionLocation,
|
||||
|
@ -128,7 +128,7 @@ export async function suggest(
|
|||
argValueSuggestions: ArgValueSuggestions
|
||||
) {
|
||||
try {
|
||||
const result = parseTimelionExpression(expression);
|
||||
const result = await parseTimelionExpressionAsync(expression);
|
||||
|
||||
return await extractSuggestionsFromParsedResult(
|
||||
result,
|
||||
|
|
|
@ -15,7 +15,7 @@ import { TimelionVisDependencies } from './plugin';
|
|||
import { toExpressionAst } from './to_ast';
|
||||
import { getIndexPatterns } from './helpers/plugin_services';
|
||||
|
||||
import { parseTimelionExpression } from '../common/parser';
|
||||
import { parseTimelionExpressionAsync } from '../common/parser_async';
|
||||
|
||||
import { VIS_EVENT_TO_TRIGGER, VisParams } from '../../visualizations/public';
|
||||
|
||||
|
@ -50,9 +50,9 @@ export function getTimelionVisDefinition(dependencies: TimelionVisDependencies)
|
|||
getSupportedTriggers: () => {
|
||||
return [VIS_EVENT_TO_TRIGGER.applyFilter];
|
||||
},
|
||||
getUsedIndexPattern: (params: VisParams) => {
|
||||
getUsedIndexPattern: async (params: VisParams) => {
|
||||
try {
|
||||
const args = parseTimelionExpression(params.expression)?.args ?? [];
|
||||
const args = (await parseTimelionExpressionAsync(params.expression))?.args ?? [];
|
||||
const indexArg = args.find(
|
||||
({ type, name, function: fn }) => type === 'namedArg' && fn === 'es' && name === 'index'
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue