master-co / css

The CSS Language and Framework
https://css.master.co
MIT License
1.78k stars 41 forks source link

💖 Improve initialization of Master CSS Runtime #249

Closed 1aron closed 1 year ago

1aron commented 1 year ago

Description

Current

import MasterCSS from '@master/css'
import config from './master.css'

⚠️ eslint https://eslint.org/docs/latest/rules/no-new

new MasterCSS(config)

⚠️ 'css' is declared but its value is never read. ts(6133)

const css = new MasterCSS(config)

⚠️ Developers are forced to export css.

export const css = new MasterCSS(config)

⚠️ Non-runtime rendering must be set to observe: false.

const css = new MasterCSS({ observe: false, ...config }) 

💖 Expect

import { initRuntime } from '@master/css'
import config from './master.css'

initRuntime(config)

🟢 Store/export the css instance in a variable on demand.

export const css = initRuntime(config)

Deprecate config.observe option and observe on demand.

initRuntime(config, this.shadowRoot)
// equal to
const css = new MasterCSS(config).observe(this.shadowRoot)
1aron commented 1 year ago

🎉 Released in https://github.com/master-co/css/releases/tag/v2.0.0-beta.160