Repository navigation
Create Block: Speed up scaffolding by omitting WordPress dependencies - #37639
Merged
Merged
Conversation
gziolo
requested review from
ajitbohra,
mkaz,
nerrad and
ntwb
as code owners
December 28, 2021 11:23
|
Size Change: +188 B (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
gziolo
force-pushed
the
update/faster-create-block
branch
from
December 28, 2021 11:50
b24a37e to
3ef3216
Compare
fabiankaegy
approved these changes
Dec 28, 2021
fabiankaegy
left a comment
Member
There was a problem hiding this comment.
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/' ], |
Member
There was a problem hiding this comment.
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.
Member
Author
There was a problem hiding this comment.
Good catch. It's also @wordpress/interface. I completely forgot about them. I'm positive we can tweak the regular expression 👍🏻
gziolo
commented
Dec 28, 2021
This was referenced Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-scriptsgets 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.shto ensure that linting still passes for the scaffolded block with the defaultesnexttemplate even when there are no WordPress dependencies installed.I added a test dependency (
reduxthat 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.jsfiles for terms that need renaming or removal).