neutrinojs / neutrino Public
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
Add checks for middleware being used twice unintentionally #1162
Add checks for middleware being used twice unintentionally #1162
Conversation
@edmorley there is some crossover here with #964. I've had a few people asking how they can configure …and you can't. My only suggestion to them thus far was doing exactly what you're referencing here: use |
The check in the PR uses However perhaps the wording of the error message shown needs to say: |
@edmorley My only thought is you could consider simplifying the messages and including a link to a page in the docs detailing more specifics – but short of that, looks good! |
Yeah true. I think the reason I didn't initially, is that there isn't a good permalink for many of the settings, since they appear in the middle of "here are all the options" sections. A hardcoded URL would also get out of date once we release new major versions of Neutrino (though we have this problem already in a few places). |
Another way we could have a more generic error message would be to subclass Error: class DuplicateRuleError extends Error {
constructor(name, ruleId) {
super(
`${name} has been used twice with the same `ruleId` of ${ruleId}.\n` +
'If you are including this preset manually to customise the rules\n' +
"configured by another preset, instead use that preset's own options to do so."
);
}
}
// ...
if (neutrino.config.module.rules.has(ruleId)) {
throw new DuplicateRuleError('@neutrinojs/compile-loader', 'compile'); |
Yeah that may be better (I'd decided against it before since each message was subtly different eg the preset option name, but perhaps that's unnecessary). Should |
That would be my recommendation since every middleware we have peer-depends on it. |
To try and prevent the confusion caused when users do things like: * using `@neutrinojs/react` followed by `@neutrinojs/web`, which clobbers the React parts of the config: #1129 (comment) * using `@neutrinojs/react` followed by `@neutrinojs/style`, which causes incorrect `extract` and `hot` configuration: #1129 (comment) #755 (comment) #803 (comment) #869 (comment)
PR updated with a new |
To try and prevent the confusion caused when users do things like:
@neutrinojs/react
followed by@neutrinojs/web
, which clobbers the React parts of the config:#1129 (comment)
@neutrinojs/react
followed by@neutrinojs/style
, which causes incorrectextract
andhot
configuration:#1129 (comment)
#755 (comment)
#803 (comment)
#869 (comment)