-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Conversation
Size Change: +188 B (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
b24a37e
to
3ef3216
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one question regarding some of the packages that are not available through the window object in core but besides that this is looking good to me and I think the speed improvement is really worth it.
'import/no-unresolved': [ | ||
'error', | ||
{ | ||
ignore: [ '^@wordpress/' ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way in which we can exclude packages like the '@wordpress/icons' package from this ignore lists? It already is confusing which ones are included in core and which ones aren't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. It's also @wordpress/interface
. I completely forgot about them. I'm positive we can tweak the regular expression 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2360498 should do the trick.
Description
Follow-up for #27880.
TLDR; Omit verification for WordPress dependencies in the import statements since they get externalized when used with WordPress.
In #27880, I added an option to provide a list of npm dependencies to install when scaffolding the block with
@wordpress/create-block
. The rationale behind it was summarized as follows:In practice, it slows down the scaffolding process too much. It also created some follow-up discussion on whether we could skip linting for WordPress packages that are handled as externals anyway.
This PR explores changes to the ESLint Plugin which ignores all WordPress packages in the linting process for import statements. The exception is disabled in the Gutenberg plugin so we can ensure that npm packages are always correctly configured for usage from npm.
As part of the effort, I think we should remove WordPress packages from the listed npm dependencies in templates so they install way faster. In addition to that, I added a check for when
wp-scripts
gets explicitly disabled to skip npm dependencies because they aren't that useful in such cases.How has this been tested?
I executed
./bin/test-create-block.sh
to ensure that linting still passes for the scaffolded block with the defaultesnext
template even when there are no WordPress dependencies installed.I added a test dependency (
redux
that existed innode_modules
) in the scaffolded template to ensure that the linting rule still throws errors for non-WordPress dependencies:Types of changes
Enhancement.
Checklist:
*.native.js
files for terms that need renaming or removal).