Warns when the user is using special webpack syntax#736
Conversation
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
|
I would like this to be a hard error. It was never officially supported and doesn't work with some officially supported features like testing. If somebody uses this in an open source React example and then we break this feature, people using that example will be utterly confused, as happened many times before with e.g. Babel. There won't be any "migration step" in the changelog for them because this feature is unsupported. So we'd rather disable it completely. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
|
@gaearon okay, changed it, thanks for the explanation 👍 still, haven't really tested my implementation though |
555424e to
98b861b
Compare
|
apparently create-react-app uses this syntax in quite a few places and the plugin is also evaluating third-party dependencies, as it can be seen on travis log |
| compiler.plugin('normal-module-factory', (normalModuleFactory) => { | ||
| normalModuleFactory.plugin('before-resolve', (data, callback) => { | ||
| let error = null; | ||
| if (data.request.match(/^-?!!?/)) { |
There was a problem hiding this comment.
It'd be best to use the exact same regexps as webpack uses for this (which I believe can be found here https://github.com/webpack/webpack/blob/master/lib/NormalModuleFactory.js#L86)
|
The reason why the build is failing is because webpack uses this syntax internally, so we can't fully block it without breaking how webpack works. I think it would be easiest to add this as an ESLint rule, so it only forbids using this feature in user code: import-js/eslint-plugin-import#586 |
|
Sorry for the wasted effort! Indeed a lint rule seems better in this case. |
This should solve #733
I haven't tested it yet as I'm in a hurry, so if you can, please do (:
Instead of throwing an error I am showing a warning because I didn't want to block users to use a feature just because it might break in the future, and force them to eject just because of a minor plugin.