Skip to content

Commit

Permalink
Reduced bundle size.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuznietsov committed May 20, 2022
1 parent 8473527 commit f400f05
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* Side Public License, v 1.
*/

import { validateAccessor } from '@kbn/visualizations-plugin/common/utils';
import { LayerTypes, REFERENCE_LINE_LAYER, EXTENDED_Y_CONFIG } from '../constants';
import { REFERENCE_LINE_LAYER, EXTENDED_Y_CONFIG } from '../constants';
import { ReferenceLineLayerFn } from '../types';
import { strings } from '../i18n';

Expand Down Expand Up @@ -41,16 +40,8 @@ export const referenceLineLayerFunction: ReferenceLineLayerFn = {
help: strings.getLayerIdHelp(),
},
},
fn(input, args) {
const table = args.table ?? input;
const accessors = args.accessors ?? [];
accessors.forEach((accessor) => validateAccessor(accessor, table.columns));

return {
type: REFERENCE_LINE_LAYER,
...args,
layerType: LayerTypes.REFERENCELINE,
table: args.table ?? input,
};
async fn(input, args, context) {
const { referenceLineLayerFn } = await import('./reference_line_layer_fn');
return await referenceLineLayerFn(input, args, context);
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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 { validateAccessor } from '@kbn/visualizations-plugin/common/utils';
import { LayerTypes, REFERENCE_LINE_LAYER } from '../constants';
import { ReferenceLineLayerFn } from '../types';

export const referenceLineLayerFn: ReferenceLineLayerFn['fn'] = async (input, args, handlers) => {
const table = args.table ?? input;
const accessors = args.accessors ?? [];
accessors.forEach((accessor) => validateAccessor(accessor, table.columns));

return {
type: REFERENCE_LINE_LAYER,
...args,
layerType: LayerTypes.REFERENCELINE,
table: args.table ?? input,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ export type ReferenceLineLayerFn = ExpressionFunctionDefinition<
typeof REFERENCE_LINE_LAYER,
Datatable,
ReferenceLineLayerArgs,
ReferenceLineLayerConfigResult
Promise<ReferenceLineLayerConfigResult>
>;

export type YConfigFn = ExpressionFunctionDefinition<typeof Y_CONFIG, null, YConfig, YConfigResult>;
Expand Down

0 comments on commit f400f05

Please sign in to comment.