-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Why force specific quotes in dynamic-import-chunkname? #1130
Comments
Does webpack support both formats? |
It does. Moreover it supports a couple of other "invalid" cases:
because it "parses" these options by inserting comment contents inside an object body. Which we could also do here in this rule, that is currently too strict and considers cases with multiple "comment options", like |
I’m fine adding an option for quotes, but i don’t think there’s any value in allowing “anything” |
import(
/* webpackChunkName: "a" */
/* webpackPrefetch: true */
'./a'
)
import(
/* webpackPrefetch: true */
/* webpackChunkName: "a" */
'./a'
)
import(/* webpackChunkName: "a", webpackPrefetch: true */ './a') while accepting import(/* webpackPrefetch: true, webpackChunkName: "a" */ './a')
import(/* totally invalid syntax webpackChunkName: "a" !!!! */ './a') because of current substring search with single spaces around. Second point might be considered separate issue, but everything discussed here boils down to the comment parsing logic. But the rule is about
so it needs to both parse correctly and enforce some whitespace styling. |
To be non-breaking, the default would stay double, and an option could be added to require single instead of double. It wouldn't be very valuable to allow either :-) The rule should certainly allow all of webpack's features - but i don't think it's a good idea to be as loose as webpack is in a linter rule. |
In the meantime, I re-evaluated the position of customizing these little details, and don't think bringing in options for the quotes and spacing preferences adds enough value to even cover the added code complexity and maintenance burden. After all, this rule's main goal is enforcing naming of webpack chunks in dynamic imports, and "the proper format" is only second to that (if at all). Personally, I think simply allowing both quote styles (which is relaxing and non-breaking) would be more beneficial than forcing a specific quote style or having an option for which to enforce. |
Updating the docs is of course always great. I agree there’s added complexity in an option, but in this case it’d just be selecting a single or double quote - it doesn’t seem that painful to add to me. |
I believe #1163 addressed this. |
@ljharb It looks like #1163 omitted allowing single quotes:
Is there still interest in relaxing the double quote requirement? If so, I'd be more than happy to contribute a PR! |
Yes, absolutely! As long as webpack supports it, a PR would be great (please confirm in which versions webpack supports it, in the PR) |
Took a pass at it in #1848, thanks! |
The rule dynamic-import-chunkname forces to use double quotes in the chunk comment. Is is literally said in docs so:
What is the rationale for that? Should I make a PR allowing both single and double quotes by default, or put allowing / forbidding behind an option?
The text was updated successfully, but these errors were encountered: