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

Create Block: Speed up scaffolding by omitting WordPress dependencies #37639

Merged
merged 4 commits into from
Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module.exports = {
jsdoc: {
mode: 'typescript',
},
'import/internal-regex': null,
'import/resolver': require.resolve( './tools/eslint/import-resolver' ),
},
rules: {
Expand Down
4 changes: 4 additions & 0 deletions packages/create-block-tutorial-template/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancement

- Speed up scaffolding process by omitting WordPress dependencies in the template ([#37639](https://github.com/WordPress/gutenberg/pull/37639)).

## 1.3.0 (2021-07-21)

### Enhancement
Expand Down
6 changes: 0 additions & 6 deletions packages/create-block-tutorial-template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ module.exports = {
supports: {
html: false,
},
npmDependencies: [
'@wordpress/block-editor',
'@wordpress/blocks',
'@wordpress/components',
'@wordpress/i18n',
],
},
templatesPath: join( __dirname, 'templates' ),
assetsPath: join( __dirname, 'assets' ),
Expand Down
4 changes: 4 additions & 0 deletions packages/create-block/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancement

- Speed up scaffolding process by omitting WordPress dependencies in the template ([#37639](https://github.com/WordPress/gutenberg/pull/37639)).

### Internal

- The bundled `npm-package-arg` dependency has been updated from requiring `^8.0.1` to requiring `^8.1.5` ([#37395](https://github.com/WordPress/gutenberg/pull/37395)).
Expand Down
2 changes: 1 addition & 1 deletion packages/create-block/lib/init-package-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = async ( {
)
);

if ( size( npmDependencies ) ) {
if ( wpScripts && size( npmDependencies ) ) {
info( '' );
info(
'Installing npm dependencies. It might take a couple of minutes...'
Expand Down
5 changes: 0 additions & 5 deletions packages/create-block/lib/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ const predefinedBlockTemplates = {
supports: {
html: false,
},
npmDependencies: [
'@wordpress/block-editor',
'@wordpress/blocks',
'@wordpress/i18n',
],
},
templatesPath: join( __dirname, 'templates', 'esnext' ),
},
Expand Down
4 changes: 4 additions & 0 deletions packages/eslint-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
- The bundled `eslint-plugin-jsdoc` dependency has been updated from requiring `^36.0.8` to requiring `^37.0.3` ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).
- The bundled `globals` dependency has been updated from requiring `^12.0.0` to requiring `^13.12.0` ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).

### Enhancement

- Omit verification for WordPress dependencies in the import statements since they get externalized when used with WordPress ([#37639](https://github.com/WordPress/gutenberg/pull/37639)).

### Bug Fix

- Fix Babel config resolution when a custom ESLint config present ([#37406](https://github.com/WordPress/gutenberg/pull/37406)). Warning: it won't recognize the `babel.config.json` file present in the project until the upstream bug in `cosmiconfig` is fixed.
Expand Down
5 changes: 0 additions & 5 deletions packages/eslint-plugin/configs/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,4 @@ module.exports = {
},
},
],
settings: {
react: {
version: '16.6',
},
},
};
4 changes: 3 additions & 1 deletion packages/eslint-plugin/configs/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ module.exports = {
},
},
settings: {
'import/extensions': [ '.js', '.jsx' ],
react: {
version: 'detect',
},
},
plugins: [ '@wordpress', 'react', 'react-hooks' ],
rules: {
Expand Down
14 changes: 13 additions & 1 deletion packages/eslint-plugin/configs/recommended-with-formatting.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
*/
const { isPackageInstalled } = require( '../utils' );

// Exclude bundled WordPress packages from the list.
const wpPackagesRegExp = '^@wordpress/(?!(icons|interface))';
gziolo marked this conversation as resolved.
Show resolved Hide resolved

const config = {
extends: [
require.resolve( './jsx-a11y.js' ),
Expand All @@ -20,14 +23,23 @@ const config = {
document: true,
wp: 'readonly',
},
settings: {
'import/internal-regex': wpPackagesRegExp,
'import/extensions': [ '.js', '.jsx' ],
},
rules: {
'import/no-extraneous-dependencies': [
'error',
{
peerDependencies: true,
},
],
'import/no-unresolved': 'error',
'import/no-unresolved': [
'error',
{
ignore: [ wpPackagesRegExp ],
},
],
'import/default': 'warn',
'import/named': 'warn',
},
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-plugin/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ if ( isPackageInstalled( 'typescript' ) ) {
extensions: [ '.js', '.jsx', '.ts', '.tsx' ],
},
},
'import/core-modules': [ 'react' ],
};
config.extends.push( 'plugin:@typescript-eslint/eslint-recommended' );
config.ignorePatterns = [ '**/*.d.ts' ];
Expand Down