-
Notifications
You must be signed in to change notification settings - Fork 27.9k
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
Next 6 breaks styled-jsx with sass plugin #4265
Comments
You may check this package: https://github.com/zeit/next-plugins/tree/master/packages/next-sass |
I saw that, but prefer the automatic name spacing that styled-jsx provides without having to import every classname with css modules. As well as not having to update 50+ pages/components |
Edit: Seems that this was in our case caused by another babel plugin (specifically transform-react-constant-elements, vercel/styled-jsx#85). This seems to affect us too (but a little differently): we The generated css still seems to include the variable names instead of the values from the theme file, which breaks the layout: |
Can you provide a repository so I can check it out easily? |
Can you try |
Same issue on canary, I'll try to make a repo tomorrow |
Hey guys, any updates on this? Still happening in 6.0.3 |
It’s close to impossible to help if you don’t provide an example repository. Saying something doesn’t work while the issue is still open and asking for updates without providing a way to reproduce doesn’t help solve the issue. Instead try providing a repository to reproduce, like I asked for already in this issue 👍🏻 |
@timneutkens Given vercel/styled-jsx#425 and #4299 and #4335 I would have thought you were aware of the issue since you replied to them and at least one of those seems like the same issue, and the suggestion to use Canary also suggests you guys thought you had a fix. I didn't jump on to a thread, splatter my brains over it and leave. I am building a repo now. |
Sorry work is crazy and I haven't gotten a chance to setup a repo, but a couple notes. Not using the global option |
I have same problem. and @timneutkens point out my problem. check out this.: #4239 (comment) If you use thanks to @timneutkens |
Echoing @blackbing and @timneutkens, that change to the babel config fixed everything on my side. @jakegibson unless you have further issues I am willing to bet this fixes it for you too and can close the issue. Specifically this is the change that fixed it: #4239 (comment) |
Awesome, I'll just close this. If it doesn't work feel free to provide a full reproduction. Thank you for verifying @codinronan @blackbing! ❤️ |
@timneutkens sorry I think this issue should reopen. It could reproduce on this repo: https://github.com/blackbing/next-with-jest-style-jsx-error and I also create an issue #4501 for "with-jest + with-style-jsx-scss" error. the only difference of configs between test and development is
so it can reproduce if run @jakegibson please help to confirm if it is the same error you got. |
@blackbing yep I can repro that as well, but I think the issue is not in next - I believe it is a problem with styled-jsx. Truthfully I'm not sure where to start there; saying that, styled-jsx 3 is almost a full rewrite from v2, so it may not repro in the new version. That would be nice! |
@giuseppeg I'm guessing this is because they transpile |
@timneutkens probably, the commonjs plugin is not rewriting var _style2 = _interopRequireDefault(require("./style"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = function _default() {
return _react.default.createElement("div", {
className: "hello"
}, _react.default.createElement("p", null, "Hello World"), _react.default.createElement(_style.default, {
styleId: _style2.default.__hash,
css: style
}));
}; see the 3rd last line In the meantime you folks can switch to the commonjs syntax for styled-jsx: module.exports = css`div { color: red }` fwiw the issue is not with styled-jsx-plugin-sass |
ok, I've update the repo and narrow down the problem. https://github.com/blackbing/next-with-jest-style-jsx-error |
@giuseppeg I can help to submit a PR, but I'm not sure where should I add it? Is it in next.js or styled-jsx? |
@blackbing styled-jsx You can add the test here https://github.com/zeit/styled-jsx/blob/master/test/index.js await transform('./fixtures/somefixture.js', { presets: [["babel-preset-env", { "modules": "commonjs" }]] }) |
@giuseppeg it looks pass. blackbing/styled-jsx@0feb15f or do I miss something? |
yea it seems to be correct. Probably in Next.js |
Expected Behavior
Should be able to upgrade next 6 and still use styled-jsx with sass
Current Behavior
Working with next 5.1.0 upgrading to next 6 breaks importing a scss file to be used in styled-jsx
example
import style from './componentName.scss';
in component:
<styled jsx>{style}</style>
On next 6 I get 'style is undefined'
package.json
"extract-text-webpack-plugin": "^3.0.2",
"extracted-loader": "^1.0.3",
"node-sass": "^4.7.2",
"postcss": "^6.0.16",
"postcss-cssnext": "^3.0.2",
"postcss-loader": "^2.0.10",
"sass-loader": "^6.0.6",
"styled-jsx-css-loader": "^0.3.0"
"styled-jsx-plugin-sass": "^0.2.2",
"autoprefixer": "^8.2.0",
babelrc
The text was updated successfully, but these errors were encountered: