Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle the icons package instead of using it as an external #19809

Merged
merged 3 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/components/src/circular-option-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { __experimentalIcon as Icon, check } from '@wordpress/icons';
import { Icon, check } from '@wordpress/icons';

/**
* Internal dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,6 @@ exports[`ColorPalette should render a dynamic toolbar of colors 1`] = `
<Icon
icon={
<SVG
aria-hidden={true}
gziolo marked this conversation as resolved.
Show resolved Hide resolved
focusable="false"
role="img"
viewBox="-2 -2 24 24"
xmlns="http://www.w3.org/2000/svg"
>
Expand All @@ -334,10 +331,7 @@ exports[`ColorPalette should render a dynamic toolbar of colors 1`] = `
}
>
<SVG
aria-hidden={true}
focusable="false"
height={24}
role="img"
viewBox="-2 -2 24 24"
width={24}
xmlns="http://www.w3.org/2000/svg"
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/custom-select-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { __experimentalIcon as Icon, check } from '@wordpress/icons';
import { Icon, check } from '@wordpress/icons';
/**
* Internal dependencies
*/
Expand Down
5 changes: 5 additions & 0 deletions packages/dependency-extraction-webpack-plugin/util.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const WORDPRESS_NAMESPACE = '@wordpress/';
const BUNDLED_PACKAGES = '@wordpress/icons';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant to use an array of packages here:

Suggested change
const BUNDLED_PACKAGES = '@wordpress/icons';
const BUNDLED_PACKAGES = [ '@wordpress/icons' ];

This seems to only be relevant for packages in the @wordpress namespace (if we want to bundle other packages, they wouldn't be included below). We might lest those and handle them as needed:

Suggested change
const BUNDLED_PACKAGES = '@wordpress/icons';
const BUNDLED_PACKAGES = [ 'icons' ];

and changes below would become:

	if ( request.startsWith( WORDPRESS_NAMESPACE ) ) {
		const packageName = request.substring( WORDPRESS_NAMESPACE.length );
		if ( BUNDLED_PACKAGES.includes( packageName ) ) {
			return undefined;
		}
		return [ 'wp', camelCaseDash( packageName ) ];
	}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might trip any package that has the word icons in it.


/**
* Default request to global transformation
Expand Down Expand Up @@ -34,6 +35,10 @@ function defaultRequestToExternal( request ) {
return 'ReactDOM';
}

if ( BUNDLED_PACKAGES.includes( request ) ) {
return undefined;
}

if ( request.startsWith( WORDPRESS_NAMESPACE ) ) {
return [ 'wp', camelCaseDash( request.substring( WORDPRESS_NAMESPACE.length ) ) ];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/post-saved-state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { withSelect, withDispatch } from '@wordpress/data';
import { displayShortcut } from '@wordpress/keycodes';
import { withSafeTimeout, compose } from '@wordpress/compose';
import { withViewportMatch } from '@wordpress/viewport';
import { __experimentalIcon as Icon, check } from '@wordpress/icons';
import { Icon, check } from '@wordpress/icons';

/**
* Internal dependencies
Expand Down
2 changes: 1 addition & 1 deletion packages/icons/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## 1.0.0 (2019-08-15)
## Master

- Initial release
2 changes: 1 addition & 1 deletion packages/icons/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ _This package assumes that your code will run in an **ES2015+** environment. If
## Usage

```js
import { __experimentalIcon as Icon, check } from '@wordpress/icons';
import { Icon, check } from '@wordpress/icons';

<Icon icon={ check } />
```
Expand Down
2 changes: 1 addition & 1 deletion packages/icons/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { default as __experimentalIcon } from './icon';
export { default as Icon } from './icon';

export { default as check } from './library/check';
export { default as paragraph } from './library/paragraph';
8 changes: 1 addition & 7 deletions packages/icons/src/library/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
import { SVG, Path } from '@wordpress/primitives';

const saved = (
<SVG
aria-hidden
role="img"
focusable="false"
xmlns="http://www.w3.org/2000/svg"
viewBox="-2 -2 24 24"
>
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 24 24">
<Path d="M15.3 5.3l-6.8 6.8-2.8-2.8-1.4 1.4 4.2 4.2 8.2-8.2" />
</SVG>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/primitives/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### Master
## Master
gziolo marked this conversation as resolved.
Show resolved Hide resolved

Initial release.
6 changes: 5 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ const {
} = process.env;

const WORDPRESS_NAMESPACE = '@wordpress/';
const BUNDLED_PACKAGES = [ '@wordpress/icons' ];

const gutenbergPackages = Object.keys( dependencies )
.filter( ( packageName ) => packageName.startsWith( WORDPRESS_NAMESPACE ) )
.filter( ( packageName ) =>
! BUNDLED_PACKAGES.includes( packageName ) &&
packageName.startsWith( WORDPRESS_NAMESPACE )
)
.map( ( packageName ) => packageName.replace( WORDPRESS_NAMESPACE, '' ) );

module.exports = {
Expand Down