feat: add option to warn at runtime when non-existent properties are accessed#421
feat: add option to warn at runtime when non-existent properties are accessed#421DrewML wants to merge 2 commits intowebpack:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #421 +/- ##
==========================================
- Coverage 98.35% 98.03% -0.32%
==========================================
Files 9 9
Lines 304 306 +2
Branches 67 68 +1
==========================================
+ Hits 299 300 +1
- Misses 5 6 +1
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #421 +/- ##
==========================================
- Coverage 98.35% 98.03% -0.32%
==========================================
Files 9 9
Lines 304 306 +2
Branches 67 68 +1
==========================================
+ Hits 299 300 +1
- Misses 5 6 +1
Continue to review full report at Codecov.
|
|
It would be possible to skip |
|
The overhead and the use of ES2015 Proxies is a personal concern of mine regarding this, how often is it the case that this happens? Could empty modules be filtered instead ? |
|
@michael-ciniawsky Maybe this is another issue that's better tackled after CSS Modules have been split to a loader of its own? |
|
@bebraw Split 🙃 ? We could do that, maybe the right thing to do, but I could be 'difficult' to do so, I'm still struggling to add it to |
|
@michael-ciniawsky Figuring out the right composition is the key. Now css-loader does too much. If it can go through |
|
The problem with seperation is the current tandem of |
|
I didn't find the right compromise yet 😛 , since otherwise |
|
@michael-ciniawsky Maybe it's better to try to arrange a little design session at Slack so we have a clear high level idea? One way, forget everything you know about the existing loaders etc. and imagine an ideal pipeline. Then we can see how close to that we can get. 😄 |
FWIW, |
|
@DrewML Its's more about browser (IE) support then speed |
We can add in feature detection if that eases your concern at all. Just bail out if no |
|
yeah right we could do that.. 😛 Please be patient for at least 1-2 days since as you may noticed from the discussion started in this thread, |
|
Given we are splitting modules out of css-loader, should this not also target the new modules repo?: |
|
Yes if we split it up, but the current headache is still the how :), so I left it for now. I need to check the possibilties first and get a working prototype of a splitted approach |
|
@michael-ciniawsky Named exports has the same target but in build time, so maybe this is not necessary. |
|
@michael-ciniawsky Sounds good! |
What kind of change does this PR introduce?
A new query param is added to the loader (
cssModuleDevWarnings) that can be used in conjunction with CSS modules. At runtime, this will emit aconsole.warnanytime a non-existent class name is accessed on the CSS module.Did you add tests for your changes?
Not yet. Happy to add them, just wanted to check if you'd be willing to accept this type of change before investing the time to write tests.
If relevant, did you update the README?
Yes
Summary
It's been too easy to mistype a property name when assigning a
classNameproperty in React. At runtime, ifclassNamehas been assigned toundefined, the element in DevTools will just show as having no classname at all. This is a helpful hint to warn you in development when you've typoed, similar to the types of dev warnings that React gives you.Does this PR introduce a breaking change?
Should not
Other information
This feature requires that the user have ES2015 proxy support in their browser, so it's super important this never makes it into a user's production code (also because proxies are slow). Looking for any input on how we can make this more obvious besides just docs (maybe a scarier query param name?)
Example
