Closed
Description
Issue Overview and Possible Solution
When creating a block, I start with something like this:
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
const BlockControls = wp.blocks.BlockControls;
const el = wp.element.createElement;
Strong coupling to global state is consistent with traditional WordPress anti-patterns. But it presents the following problems:
- Gutenberg might not be active (3k active installs) or the site might not be on WordPress 5.0 yet (currently ~77% of WordPress sites are not on the current release series.)
- Relying on global state makes testing very hard and/or impossible depending on test type/ technology.
- I may wish to use these components in my plugin or other type of code that isn't strongly-coupled to WordPress and including them via npm and an import statement is how that should work.
Expected Behavior
$ npm i @wordpress/element
import { createElement } from '@wordpress/element';
Current Behavior
const { createElement } = wp.element;
Tasks
-
api-request
(Add a new@wordpress/api-request
package #7018) -
blob
(Blob: Extract newblob
package out of utils module #6973) - extracted fromutils
-
blocks
- depends onandwp.shortcode
window._wpBlocks
(Packages: Add the blocks module to the packages folder #8046) -
renamed tocore-blocks
block-library
(Extract Core Blocks to the npm packages folder #8287) -
core-data
(Move the Core Data Module to the reusable packages #7222) -
components
(Packages: Move the components module partially to the packages folder #7640) -
compose
(Packages: Add a new compose package #7948) -
editor
(Packages: Extract the editor package #8081) -
- we don't plan to publish it, this might changeedit-post
-
data
(Packages: Move data module to the package maintained by Lerna #6828) -
date
(Build: Move date module to packages maintained by Lerna #6658) -
deprecated
(Deprecated: Introduce new module with depreaction util #6914) - extracted fromutils
-
dom
(Packages: Extract dom package and make it maintained with Lerna #6758) - extracted fromutils
-
element
(Packages: Move element to packages maintained by Lerna #6756) -
library-export-default-webpack-plugin
(Build: Add new Webpack plugin to handle library default export #6935) -
nux
(Packages: Extract@wordpress/nux
package #8016) -
plugins
(Packages: Move Plugins module to packages #7235) -
- to be extracted into smaller packages (Editor: Move media upload from utils #7978)utils
-
viewport
- depends oncomponents
(Packages: Extract viewport package #7975)