-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Import names aren't validated before writing dependency file #15876
Comments
It seems like this should be handled on the linter side instead. Well, at least this is what we introduced in Gutenberg lately with “import/no-extraneous-dependencies” rule in #16969. It’s handled per package and only for non-test files in Gutenberg but it might be a good idea to set it in recommended config of ESLint and override in the project as Gutenberg is a special case here. @nerrad, @ntwb, and @swissspidy what do you think? |
Ya I agree, linter. A couple IDE's I've used will also warn on invalid imports. |
It looks like the bug was fixed and it has landed in Gutenberg. Next step is to move it to the ESLing plugin. |
@gziolo Was it expected that we now have to add every @WordPress package used in block scripts as a dev dependency? Asking because the rule now produces these errors:
|
Yes. It might be too strict though. We can exclude those dependencies that are listed as webpack externals and resolved as globals in WordPress. I had a similar discussion on WordPress Slack. What do you think about it? I didn't anticipate it being problematic. By the way, |
Not sure, I think they should be excluded but I also see the benefit of having them explicitly defined as a dependency. One issue I see is the versioning because they version installed might not match the version included in the minimum supported WordPress version. With automated package updates (Dependabot) it's too easy to install a new version. Could you link to the Slack discussion please? |
Here's a link to the discussion that happened in Slack: https://wordpress.slack.com/archives/C5UNMSU4R/p1612354700163900 |
Describe the bug
dependency-extraction-webpack-plugin
doesn't validate import names. If an invalid name is used, the parent script will silently fail to load, which can be confusing and time-consuming to fix.Expected behavior
The watch script should throw an error to the console, to alert the dev that they used an invalid dependency.
To reproduce
deps.json
file. e.g.,import
statement. e.g.,The text was updated successfully, but these errors were encountered: