@gravityforms/gulp-tasks
Version:
Configurable Gulp tasks for use in Gravity Forms projects.
74 lines (68 loc) • 1.3 kB
JavaScript
function camelCase( str ) {
return str
.split( /-| / )
.map( ( word, index ) => index === 0 ? word.toLowerCase() : word.charAt( 0 ).toUpperCase() + word.slice( 1 ).toLowerCase() )
.join( '' );
}
const wp = [
'a11y',
'api-fetch',
'autop',
'blob',
'block-directory',
'block-editor',
'block-library',
'blocks',
'components',
'compose',
'core-data',
'data',
'date',
'dom',
'edit-post',
'editor',
'element',
'escape-html',
'format-library',
'hooks',
'html',
'html-entities',
'i18n',
'is-shallow-equal',
'keyboard-shortcuts',
'keycodes',
'media-utils',
'notices',
'plugins',
'preferences',
'preferences-persistence',
'primitives',
'priority-queue',
'reusable-blocks',
'rich-text',
'server-side-render',
'style-engine',
'url',
'utils',
'viewport',
'wordcount',
];
const createNamespace = ( dependency ) => {
if ( dependency.includes( '-' ) ) {
return camelCase( dependency );
}
return dependency;
};
// Puts @wordpress/[dependency] on the window object as window.wp.[dependency]
const externals = wp.reduce(
( result, dependency ) => {
const namespace = createNamespace( dependency );
result[ `@wordpress/${ dependency }` ] = {
var: `wp.${ namespace }`,
root: [ 'wp', namespace ],
};
return result;
},
{}
);
module.exports = externals;