-
-
Notifications
You must be signed in to change notification settings - Fork 161
Make babel-plugin-react-css-modules work with commonjs require #38
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
Comments
require
, only import
It is possible. However, there hasn't been any demand for it. Provided that I can leave this issue open to see if more people thumbs up the feature. |
Note that ES2015 modules are not yet standard (in spite of its name) and possibly breaking by future spec changes. That's why I hesitate using |
@gajus Could you point me in the direction of how to get this working? I'm afraid switching away from commonjs may be more work. |
This problem is quite important with TypeScript setups where TypeScript transpiles imports to requires (Named imports are undefined) Sure I could. try to make a quite complex full-babel setup (and drop ts-loader) with the plugins in correct order, but then I can't use presets as they are loaded before plugins, and it gets reallyyy complicated. I'd be happy to try to help solving this particular issue, but I would need a maintainer or a contributor to tell me where I could start looking at. (cc @gajus) |
@martpie It's not hard:
babel-plugin-react-css-modules/src/index.js Lines 149 to 184 in b3ae56b
The function name
Here you can use https://astexplorer.net/ , type in code with So maybe you can try
|
Hello,
when requiring scss files using
require()
syntax I getCannot use styleName attribute without importing at least one stylesheet.
. However if I switch to using import it works (minus an eslint parsing error).I'm trying to introduce css-modules into an old code base. I have the es6 babel preset running (that's why imports work), but code is linted without modules support and I would love to keep it that way for the time being. Is there anyway to make this plugin work with require?
The text was updated successfully, but these errors were encountered: