@marianoguerra/tailwindcss 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/ffi.js +27715 -0
- package/index.mjs +46 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# JavaScript / Wasm library
|
|
2
|
+
|
|
3
|
+
An ergonomic, dependency-free wrapper around the MoonBit Tailwind compiler for
|
|
4
|
+
JS and Wasm hosts (Node, browsers, bundlers). It compiles Tailwind v4 CSS fully
|
|
5
|
+
in memory — no filesystem access — so any `@import` is resolved from an
|
|
6
|
+
in-memory `{ path: content }` map you provide.
|
|
7
|
+
|
|
8
|
+
## Build
|
|
9
|
+
|
|
10
|
+
The wrapper (`index.mjs`) imports the compiled MoonBit module as a peer file
|
|
11
|
+
`./ffi.js`. Build one of the supported backends and copy it next to the wrapper:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
# JS backend (Node / browsers / bundlers)
|
|
15
|
+
moon build --target js ffi --release
|
|
16
|
+
cp _build/js/release/build/ffi/ffi.js ffi/js/ffi.js
|
|
17
|
+
|
|
18
|
+
# or the wasm-gc backend (GC-capable Wasm host)
|
|
19
|
+
moon build --target wasm-gc ffi --release
|
|
20
|
+
# load _build/wasm-gc/release/build/ffi/ffi.wasm with your Wasm runtime
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The exported functions are `compile_css_json` (structured, recommended) and
|
|
24
|
+
`compile_css` (inline CSS only, legacy).
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { compile } from './index.mjs'
|
|
30
|
+
|
|
31
|
+
const { css } = compile({
|
|
32
|
+
input: '@import "base.css"; @tailwind utilities;',
|
|
33
|
+
candidates: ['flex', 'hover:bg-black'],
|
|
34
|
+
imports: { 'base.css': '@theme { --color-black: #000; }' },
|
|
35
|
+
from: 'input.css',
|
|
36
|
+
polyfills: 3, // 0=none, 1=@property, 2=color-mix, 3=all
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
console.log(css)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`compile` throws on failure. Candidate discovery is the caller's
|
|
43
|
+
responsibility: pass the class names you want generated in `candidates` (this
|
|
44
|
+
library does not scan content files).
|
|
45
|
+
|
|
46
|
+
## Raw export
|
|
47
|
+
|
|
48
|
+
If you prefer to skip the wrapper, call the export directly. It takes a JSON
|
|
49
|
+
request string and returns a JSON result string:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
import { compile_css_json } from './ffi.js'
|
|
53
|
+
|
|
54
|
+
const result = JSON.parse(compile_css_json(JSON.stringify({
|
|
55
|
+
css: '@theme { --color-black: #000; } @tailwind utilities;',
|
|
56
|
+
candidates: ['flex'],
|
|
57
|
+
})))
|
|
58
|
+
// { ok: true, css: "..." } | { ok: false, error: "..." }
|
|
59
|
+
```
|