Skip to content

Commit

Permalink
Lazy load block edit functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr authored and flootr committed Nov 29, 2023
1 parent a2ebf0b commit 87e6536
Show file tree
Hide file tree
Showing 103 changed files with 513 additions and 202 deletions.
6 changes: 4 additions & 2 deletions packages/block-library/src/archives/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { archive as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import metadata from './block.json';
import edit from './edit';

const { name } = metadata;

Expand All @@ -17,7 +17,9 @@ export { metadata, name };
export const settings = {
icon,
example: {},
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "archives/editor" */ './edit' )
),
};

export const init = () => initBlock( { name, metadata, settings } );
7 changes: 5 additions & 2 deletions packages/block-library/src/audio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { audio as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import deprecated from './deprecated';
import edit from './edit';

import metadata from './block.json';
import save from './save';
import transforms from './transforms';
Expand All @@ -27,7 +28,9 @@ export const settings = {
},
transforms,
deprecated,
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "audio/editor" */ './edit' )
),
save,
};

Expand Down
6 changes: 4 additions & 2 deletions packages/block-library/src/avatar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import { commentAuthorAvatar as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import metadata from './block.json';
import edit from './edit';

const { name } = metadata;
export { metadata, name };

export const settings = {
icon,
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "avatar/editor" */ './edit' )
),
};

export const init = () => initBlock( { name, metadata, settings } );
6 changes: 4 additions & 2 deletions packages/block-library/src/block/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import { symbol as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import metadata from './block.json';
import edit from './edit';

const { name } = metadata;

export { metadata, name };

export const settings = {
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "block/editor" */ './edit' )
),
icon,
};

Expand Down
7 changes: 5 additions & 2 deletions packages/block-library/src/button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import { button as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import deprecated from './deprecated';
import edit from './edit';

import metadata from './block.json';
import save from './save';

Expand All @@ -25,7 +26,9 @@ export const settings = {
text: __( 'Call to Action' ),
},
},
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "button/editor" */ './edit' )
),
save,
deprecated,
merge: ( a, { text = '' } ) => ( {
Expand Down
7 changes: 5 additions & 2 deletions packages/block-library/src/buttons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { buttons as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import deprecated from './deprecated';
import transforms from './transforms';
import edit from './edit';

import metadata from './block.json';
import save from './save';

Expand All @@ -34,7 +35,9 @@ export const settings = {
},
deprecated,
transforms,
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "buttons/editor" */ './edit' )
),
save,
};

Expand Down
7 changes: 5 additions & 2 deletions packages/block-library/src/calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { calendar as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import metadata from './block.json';
import edit from './edit';

import transforms from './transforms';

const { name } = metadata;
Expand All @@ -18,7 +19,9 @@ export { metadata, name };
export const settings = {
icon,
example: {},
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "calendar/editor" */ './edit' )
),
transforms,
};

Expand Down
6 changes: 4 additions & 2 deletions packages/block-library/src/categories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { category as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import metadata from './block.json';
import edit from './edit';

const { name } = metadata;

Expand All @@ -17,7 +17,9 @@ export { metadata, name };
export const settings = {
icon,
example: {},
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "categories/editor" */ './edit' )
),
};

export const init = () => initBlock( { name, metadata, settings } );
7 changes: 5 additions & 2 deletions packages/block-library/src/code/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { code as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import edit from './edit';

import metadata from './block.json';
import save from './save';
import transforms from './transforms';
Expand All @@ -35,7 +36,9 @@ export const settings = {
};
},
transforms,
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "code/editor" */ './edit' )
),
save,
};

Expand Down
7 changes: 5 additions & 2 deletions packages/block-library/src/column/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { column as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import deprecated from './deprecated';
import edit from './edit';

import metadata from './block.json';
import save from './save';

Expand All @@ -18,7 +19,9 @@ export { metadata, name };

export const settings = {
icon,
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "column/editor" */ './edit' )
),
save,
deprecated,
};
Expand Down
7 changes: 5 additions & 2 deletions packages/block-library/src/columns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import { columns as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import deprecated from './deprecated';
import edit from './edit';

import metadata from './block.json';
import save from './save';
import variations from './variations';
Expand Down Expand Up @@ -80,7 +81,9 @@ export const settings = {
],
},
deprecated,
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "columns/editor" */ './edit' )
),
save,
transforms,
};
Expand Down
8 changes: 6 additions & 2 deletions packages/block-library/src/comment-author-avatar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ import { commentAuthorAvatar as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import metadata from './block.json';
import edit from './edit';

const { name } = metadata;
export { metadata, name };

export const settings = {
icon,
edit,
edit: lazyLoad( () =>
import(
/* webpackChunkName: "comment-author-avatar/editor" */ './edit'
)
),
};

export const init = () => initBlock( { name, metadata, settings } );
7 changes: 5 additions & 2 deletions packages/block-library/src/comment-author-name/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ import { commentAuthorName as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import metadata from './block.json';
import edit from './edit';

import deprecated from './deprecated';

const { name } = metadata;
export { metadata, name };

export const settings = {
icon,
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "comment-author-name/editor" */ './edit' )
),
deprecated,
};

Expand Down
6 changes: 4 additions & 2 deletions packages/block-library/src/comment-content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import { commentContent as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import metadata from './block.json';
import edit from './edit';

const { name } = metadata;
export { metadata, name };

export const settings = {
icon,
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "comment-content/editor" */ './edit' )
),
};

export const init = () => initBlock( { name, metadata, settings } );
7 changes: 5 additions & 2 deletions packages/block-library/src/comment-date/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ import { postDate as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import metadata from './block.json';
import edit from './edit';

import deprecated from './deprecated';

const { name } = metadata;
export { metadata, name };

export const settings = {
icon,
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "comment-date/editor" */ './edit' )
),
deprecated,
};

Expand Down
6 changes: 4 additions & 2 deletions packages/block-library/src/comment-edit-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import { commentEditLink as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import metadata from './block.json';
import edit from './edit';

const { name } = metadata;
export { metadata, name };

export const settings = {
icon,
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "comment-edit-link/editor" */ './edit' )
),
};

export const init = () => initBlock( { name, metadata, settings } );
6 changes: 4 additions & 2 deletions packages/block-library/src/comment-reply-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import { commentReplyLink as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import lazyLoad from '../utils/lazy-load';
import initBlock from '../utils/init-block';
import metadata from './block.json';
import edit from './edit';

const { name } = metadata;
export { metadata, name };

export const settings = {
edit,
edit: lazyLoad( () =>
import( /* webpackChunkName: "comment-reply-link/editor" */ './edit' )
),
icon,
};

Expand Down
Loading

0 comments on commit 87e6536

Please sign in to comment.