dependency-extraction-webpack-plugin should warn on improperly imported @wordpress packages #56097
Open
Description
opened on Nov 14, 2023
What problem does this address?
This might be a unique problem to my team, but occasionally in the block development process, a bug slips through like this:
- Autocompletion incorrectly imports a component like InnerBlocks from the wrong place ("@wordpress/block-editor/build/components" instead of "@wordpress/block-editor")
- The block builds correctly because the component can be imported from that place, and all the standard linting rules in place find no problems
- dependency-extraction-webpack-plugin matches the import from an @WordPress package with the wildcard match it uses for all the wordpress packages, but improperly externalizes the dependency (appending the "/build/components" to the handle)
- the block's editorScript is not enqueued because of (i think, but maybe this isn't how enqueue_script works) missing dependencies
Again, maybe this is a unique problem to my team's setup, and possibly the solution is in the linting step.
What is your proposed solution?
I see one of two solutions:
- Update the eslint-plugin package with rules that will catch these incorrect imports, or
- Fix the webpack plugin so that it either warns when an import is incorrect, or just cuts off the extra subdirectories from the dependency handle so that the script makes it past the check for dependencies
Activity