threepointone/glamor

extract module scoped css

Closed this issue · 1 comments

specifically, anything 'defined' inside module scope should be considered 'static'. examples -

// valid 
let rule = style({ color: 'red' })
let nested = {
  a: style({ color: 'red' }),
  b: style({ color: 'blue' }),
  c: [...someArrayofStyles]
}

let el = <div {...style({ something: 'inline' })}/>


// invalid 

let inside = () => style({ })
// or inside a class, whatever

steps -

  • flush singleton
  • require(filepath) (optionally use something like require-reload)
  • gather css (and optionally ids)
  • output

closing this as it isn't really 'safe' (eg - it'll clearly miss anything defined dynamically) and next.js shows this isn't critical at all.