0.1.5 • Published 9 months ago

@jk2908/cxx v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

cxx

library based on experiments with React 19 suspenseful style hoisting and deduping. cxx intakes CSS via a template literal arg and returns a three item tuple; the processed CSS, if configured (on by default) a CSS Modules exports object, and also optionally for usage, an id to pass to the href attribute of a style tag for deduping see React docs. The function actually just returns placeholders for the above items which will be replaced at build time. No string interpolation is supported within the CSS template tag input at the moment.

example usage: In ui templates cmp.tsx:

  import { cxx } from '@jk2908/cxx'

  const [css, styles, href] = cxx`
    .header {
      display: flex;
    }
  ` 

  function Cmp() {
    return (
      <header className={styles.header}>
        ...

        <style href={href} precedence="medium">
          {css}
        </style>
      </header>
    )
  }

  // without CSS Modules exports but with href
  const [css,, href] = cxx`...`

  // plain CSS
  const [css] = cxx`...`

CSS is transformed using lightningcss. There is access to the full lightningcss config.

vite vite.config.ts:

  import cxx from '@jk2908/cxx/vite-plugin-cxx'

  export default defineConfig({
    plugins: [react(), cxx({ ...optional cxx config })],
  })

  // turn off default config
  export default defineConfig({
    plugins: [cxx({
      lightningcss: {
        minify: false,
        cssModules: false,
        ...other transform options
      }
    })]
  })

next next.config.ts:

  import { withCxx } from '@jk2908/cxx/next'

  const nextConfig = {}

  export default withCxx(nextConfig, { ...optional cxx config })

with inspiration from:

using:

0.1.5-canary.5

9 months ago

0.1.5-canary.4

9 months ago

0.1.5-canary.3

9 months ago

0.1.5-canary.2

9 months ago

0.1.5-canary.1

9 months ago

0.1.5

9 months ago

0.1.5-canary

9 months ago

0.1.4

9 months ago

0.1.0-canary.2

10 months ago

0.1.0-canary.1

10 months ago

0.0.30-canary.0

10 months ago

0.0.30

11 months ago

0.0.31

11 months ago

0.0.32

11 months ago

0.0.33

11 months ago

0.1.0

10 months ago

0.1.2

10 months ago

0.1.1

10 months ago

0.0.28

11 months ago

0.0.29

11 months ago

0.1.3

10 months ago

0.0.27

11 months ago

0.0.26

11 months ago

0.0.25

11 months ago

0.0.24

11 months ago

0.0.23

11 months ago

0.0.22

11 months ago

0.0.21

11 months ago

0.0.20

11 months ago

0.0.19

11 months ago

0.0.18

11 months ago

0.0.17

11 months ago

0.0.16

11 months ago

0.0.15

11 months ago

0.0.14

11 months ago

0.0.13

11 months ago

0.0.12

11 months ago

0.0.11

11 months ago

0.0.10

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago