Improve lazy loading (#12393)
Creating manual chunk was a bad idea, we should always solve lazy loading problem at the source instance. Setting a 4.5MB for the index bundle size, CI will fail if we go above. There is still a lot of room for optimizations! - More agressive lazy loading (e.g. xyflow and tiptap are still loaded in index!) - Add a prefetch mechanism - Add stronger CI checks to make sure libraries we've set asides are not added back - Fix AllIcons component with does not work as intended (loaded on initial load)
This commit is contained in:
@ -1,23 +1,23 @@
|
||||
import { getFunctionInputFromSourceCode } from '@/serverless-functions/utils/getFunctionInputFromSourceCode';
|
||||
|
||||
describe('getFunctionInputFromSourceCode', () => {
|
||||
it('should return empty input if not parameter', () => {
|
||||
it('should return empty input if not parameter', async () => {
|
||||
const fileContent = 'function testFunction() { return }';
|
||||
const result = getFunctionInputFromSourceCode(fileContent);
|
||||
const result = await getFunctionInputFromSourceCode(fileContent);
|
||||
expect(result).toEqual({});
|
||||
});
|
||||
it('should return first input if multiple parameters', () => {
|
||||
it('should return first input if multiple parameters', async () => {
|
||||
const fileContent =
|
||||
'function testFunction(params1: {}, params2: {}) { return }';
|
||||
const result = getFunctionInputFromSourceCode(fileContent);
|
||||
const result = await getFunctionInputFromSourceCode(fileContent);
|
||||
expect(result).toEqual({});
|
||||
});
|
||||
it('should return empty input if wrong parameter', () => {
|
||||
it('should return empty input if wrong parameter', async () => {
|
||||
const fileContent = 'function testFunction(params: string) { return }';
|
||||
const result = getFunctionInputFromSourceCode(fileContent);
|
||||
const result = await getFunctionInputFromSourceCode(fileContent);
|
||||
expect(result).toEqual({});
|
||||
});
|
||||
it('should return input from source code', () => {
|
||||
it('should return input from source code', async () => {
|
||||
const fileContent = `
|
||||
function testFunction(
|
||||
params: {
|
||||
@ -34,7 +34,7 @@ describe('getFunctionInputFromSourceCode', () => {
|
||||
}
|
||||
`;
|
||||
|
||||
const result = getFunctionInputFromSourceCode(fileContent);
|
||||
const result = await getFunctionInputFromSourceCode(fileContent);
|
||||
expect(result).toEqual({
|
||||
param1: null,
|
||||
param2: null,
|
||||
|
||||
@ -1,16 +1,18 @@
|
||||
import { getDefaultFunctionInputFromInputSchema } from '@/serverless-functions/utils/getDefaultFunctionInputFromInputSchema';
|
||||
import { getFunctionInputSchema } from '@/serverless-functions/utils/getFunctionInputSchema';
|
||||
import { FunctionInput } from '@/workflow/workflow-steps/workflow-actions/code-action/types/FunctionInput';
|
||||
import { isObject } from '@sniptt/guards';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const getFunctionInputFromSourceCode = (
|
||||
export const getFunctionInputFromSourceCode = async (
|
||||
sourceCode?: string,
|
||||
): FunctionInput => {
|
||||
): Promise<FunctionInput> => {
|
||||
if (!isDefined(sourceCode)) {
|
||||
throw new Error('Source code is not defined');
|
||||
}
|
||||
|
||||
const { getFunctionInputSchema } = await import(
|
||||
'@/serverless-functions/utils/getFunctionInputSchema'
|
||||
);
|
||||
const functionInputSchema = getFunctionInputSchema(sourceCode);
|
||||
|
||||
const result = getDefaultFunctionInputFromInputSchema(functionInputSchema)[0];
|
||||
|
||||
Reference in New Issue
Block a user