-
Notifications
You must be signed in to change notification settings - Fork 263
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
Use debug package in favor of console.log #503
Conversation
@jonjaques thank you for the contribution! I would like to figure out why the message is printed so many times (it should be printed only once) and fix that instead. Here is the relevant piece of code https://github.com/zeit/styled-jsx/blob/a9167122eb72a824a866cd9f1bcf45fd50305610/src/_utils.js#L460-L489 |
Thanks @giuseppeg. I'm not sure, as I just have a pretty standard webpack setup: module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader'
}
]
} .babelrc plugins: [
[
'styled-jsx/babel',
{ 'plugins': [
['styled-jsx-plugin-sass', {
'sassOptions': {
'includePaths': [
'./node_modules',
'./assets/scss'
],
'precision': 2
}
}] ]
}
],
.... babel/js stuff ....
] Though where I am getting the messages (and also subsequently an error about nesting) is this UI.js file I have. Basically I'm importing The usecase here is I want to output bootstrap styles only if I use that component on a page. /**
* Progress
*/
import {
Progress as BSProgress,
} from 'reactstrap'
const progressStyles = css`
@import "base";
@import "bootstrap/scss/progress";
`
export const Progress = wrap(BSProgress, progressStyles)
/**
* Tables
*/
import {
Table as BSTable,
} from 'reactstrap'
const tableStyles = css`
@import "base";
@import "bootstrap/scss/tables";
`
export const Table = wrap(BSTable, tableStyles)
/**
* Tooltips
*/
import {
Tooltip as BSTooltip,
UncontrolledTooltip as BSUncontrolledTooltip,
} from 'reactstrap'
const tooltipStyles = css`
@import "base";
@import "bootstrap/scss/tooltip";
`
export const Tooltip = wrap(BSTooltip, modalStyles)
export const UncontrolledTooltip = wrap(BSUncontrolledTooltip, tooltipStyles)
function wrap (Component, css) {
return function (props) {
return <Fragment>
<Component {...props} />
<style jsx global>{css}</style>
</Fragment>
}
} |
I mean we should dig into the babel plugin code and figure out why it calls it so many times |
Just wondering if there's any more update on this? Or anything figured out why babel calls it so many times? My logs are flooded with these messages, so be good to sort out why babel is doing that, or merge this PR in too? |
@mike-weshop hi unfortunately I don't have time right now, would you like to debug and figure out why? |
In the meantime, this is a bloody hack but it works for us...
Save that to a JS file, add it to package.json:
and silence is golden... Actually makes a huge difference in build/rebuild times. When the thousands of log lines are included, the build takes 3-4x longer. |
fixing this in #518 thanks for the help! |
I use style-jsx-plugin-sass in my project, as you can see - and recently updated to 3.1.0 to find that I get a lot of this in my build.
This PR simply utilizes the debug package to quiet the output and allow users to opt-in to this behavior instead of enforcing it.
Produces the following:
Note, the timestamp in front is because the tests run in a non TTY environment; for most people it will output a colored string "styled-jsx".