Skip to content

dependency-extraction-webpack-plugin should warn on improperly imported @wordpress packages #56097

Open
@JEbertPrime

Description

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:

  1. Autocompletion incorrectly imports a component like InnerBlocks from the wrong place ("@wordpress/block-editor/build/components" instead of "@wordpress/block-editor")
  2. The block builds correctly because the component can be imported from that place, and all the standard linting rules in place find no problems
  3. 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)
  4. 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:

  1. Update the eslint-plugin package with rules that will catch these incorrect imports, or
  2. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions