-
Notifications
You must be signed in to change notification settings - Fork 414
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
Rollup: Using the "styled" tag in runtime is not supported #364
Comments
Can you post your code? How are you importing |
Thanks for the quick response @satya164! I have updated my original issue with an example component to illustrate my usage 👍 |
I don't have much experience with rollup, so not sure about plugin ordering. Linaria needs to run before babel, have you tried adding the linaria plugin before babel? |
Yeah, I originally had them the other way around and have just tried it again without success. // other plugins
linaria({
sourceMap: process.env.NODE_ENV !== 'production',
evaluate: true,
}),
// Compile TypeScript/JavaScript files
babel({ extensions, include: ['src/**/*'] }),
// more plugins |
I'm tagging @johanholmerin who implemented the rollup plugin. Maybe he will be able to help you. Sorry, I'm not very familiar with rollup. |
No problem, thanks for your help so far 👊 Whenever I get this resolved, if I think there is space for improvement, I will make a PR to the rollup section of the documentation 👍 |
Just wondering if there has been an update to this or if more information is available. I'm running into this as well with a similar setup. |
I'm getting the same error when using #285 (comment) |
@johanholmerin any chance you can look into this? it's a show stopper unfortunately. |
Do you have a repo with a minimal reproduction? |
Not completely minimal, but here is one that suffers from the issue: |
Have already seen that one. Couldn't reproduce. That's why I asked for a minimal repo. |
@johanholmerin Okay, I tried to create something much more minimal. Let me know if you are able to reproduce |
If you look at
|
Still running into this error as well. Any updates? |
Solution will be to remove typescript plugin because it is somehow transforming template literals before linaria is able to recognise it. plugins: [babel({
presets: [
"linaria/babel",
"@babel/preset-typescript",
"@babel/preset-react",
],
extensions: [".ts", ".tsx"],
}),
...
] or plugins: [ babel({
presets: ["@babel/preset-typescript", "@babel/preset-react"],
extensions: [".ts", ".tsx"],
}),
linaria(),
...] Extensions key is important because otherwise |
@TMaszko I try to use rollup config as you give, but there is an error in runtime css tag not support |
@tanphamhaiduong please provide a link to the repo where we can reproduce your bug |
@TMaszko I fixed by using this one in package.json
and my roll-up config
But seems it doesn't bundle to styles.css like config above
So i'm investigating |
@tanphamhaiduong so please provide a repo then we will able to help you with further investigation |
@TMaszko So @tanphamhaiduong is on my team and we found a valid workaround - basically the issue is in the tsconfig - if you set your target to es6, it will strip out the Linaria template literals but if you set the target to ESNEXT, it will preserve them and the rollup plugin works fine with the typescript2 rollup plugin. We are using the TSDX package to build our app, so this looks a bit janky as had to override the existing rollup config but hopefully the comments explain what is going on: https://github.com/reapit/foundations/blob/master/packages/elements/tsdx.config.js Basically the plugin order we found worked was (pseudo code);
Hopefully helps! BTW, really nice work on the library - was looking for ages for a CSS in JS solution that allows export to a static stylesheet as well as React Components. We distribute a UI lib to our users that exports both React Components and for non-react users, just a stylesheet. With the friendly output classes in the classNameSlug option, it's absolutely the perfect tool for us - thanks for your work 💯 |
I assume that there is a workaround for this issue. Developers has to be very careful with a rollup unfortunately |
Environment
rollup
:^1.2.2
linaria
:^1.3.1
Description
Project is TypeScript + Linaria transpiled via Babel using
@babel/preset-typescript
. The module bundler I am using isrollup
. Despite having included thelinaria/babel
preset in mybabel.config.js
file I am still seeing an error in the console:Error: Using the "styled" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly.
Reproducible Demo
The text was updated successfully, but these errors were encountered: