@rebuildjs/tailwindcss 0.3.21 → 0.4.1
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/package.json
CHANGED
|
@@ -1,67 +1,68 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
2
|
+
"name": "@rebuildjs/tailwindcss",
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "Tailwindcss integration with rebuildjs",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"tailwindcss",
|
|
7
|
+
"reactive",
|
|
8
|
+
"multi page apps",
|
|
9
|
+
"web app",
|
|
10
|
+
"web server",
|
|
11
|
+
"esbuild",
|
|
12
|
+
"rmemo",
|
|
13
|
+
"ctx-core"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://github.com/rebuildjs/tailwindcss#readme",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/rebuildjs/tailwindcss/issues"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/rebuildjs/tailwindcss.git"
|
|
22
|
+
},
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"author": "Brian Takita",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"files": [
|
|
27
|
+
"*.d.ts",
|
|
28
|
+
"*.js",
|
|
29
|
+
"*.json",
|
|
30
|
+
"rebuild_tailwind_plugin"
|
|
31
|
+
],
|
|
32
|
+
"types": "./index.d.ts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": "./index.js",
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": ":",
|
|
39
|
+
"clean": ":",
|
|
40
|
+
"exec": "$@",
|
|
41
|
+
"prepublishOnly": "pnpm clean && pnpm build && pnpm test",
|
|
42
|
+
"test": "pnpm test:unit && pnpm test:types",
|
|
43
|
+
"test:types": "check-dts",
|
|
44
|
+
"test:unit": "NODE_OPTIONS=--loader=esmock tsx node_modules/uvu/bin.js . '\\.test\\.(ts|js)$'",
|
|
45
|
+
"test:unit:coverage": "c8 pnpm test:unit"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"ctx-core": "^5.37.0",
|
|
49
|
+
"esbuild": "^0.20.0",
|
|
50
|
+
"postcss": "^8.4.33",
|
|
51
|
+
"rebuildjs": "^0.53.0",
|
|
52
|
+
"tailwindcss": "^3.4.1"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"c8": "^9.1.0",
|
|
56
|
+
"check-dts": "^0.7.2",
|
|
57
|
+
"esmock": "^2.6.3",
|
|
58
|
+
"relementjs": "^0.63.0",
|
|
59
|
+
"tsx": "^4.7.0",
|
|
60
|
+
"typescript": "next",
|
|
61
|
+
"uvu": "^0.5.6"
|
|
62
|
+
},
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public",
|
|
65
|
+
"cache": "~/.npm"
|
|
66
|
+
},
|
|
67
|
+
"sideEffects": false
|
|
67
68
|
}
|
|
@@ -6,4 +6,5 @@ export declare const rebuild_tailwind_plugin__build_id_:ctx__get_T<string|undefi
|
|
|
6
6
|
export declare const rebuild_tailwind_plugin__build_id__set:ctx__set_T<string|undefined, 'app'>
|
|
7
7
|
export declare const rebuild_tailwind_plugin__ready$_:ctx__be_T<sig_T<boolean>, 'app'>
|
|
8
8
|
export declare const rebuild_tailwind_plugin__ready_:ctx__get_T<boolean, 'app'>
|
|
9
|
+
export declare function rebuild_tailwind_plugin__ready(timeout?:number):Promise<boolean>
|
|
9
10
|
export declare function rebuild_tailwind_plugin_(config?:Config):Plugin
|
|
@@ -7,21 +7,29 @@ import {
|
|
|
7
7
|
memo_,
|
|
8
8
|
nullish__none_,
|
|
9
9
|
promise__cancel__throw,
|
|
10
|
+
rmemo__wait,
|
|
10
11
|
run,
|
|
11
12
|
sleep,
|
|
12
13
|
tup
|
|
13
14
|
} from 'ctx-core/rmemo'
|
|
14
15
|
import { readFile, writeFile } from 'node:fs/promises'
|
|
15
|
-
import { join } from 'node:path'
|
|
16
|
+
import { basename, join } from 'node:path'
|
|
16
17
|
import postcss from 'postcss'
|
|
17
18
|
import {
|
|
18
19
|
app_ctx,
|
|
20
|
+
browser__metafile_,
|
|
21
|
+
browser__metafile__update,
|
|
19
22
|
browser__output_,
|
|
23
|
+
browser__output__relative_path_,
|
|
20
24
|
build_id_,
|
|
25
|
+
cssBundle__annotate,
|
|
21
26
|
cwd_,
|
|
22
27
|
rebuildjs__build_id_,
|
|
23
28
|
rebuildjs__ready_,
|
|
29
|
+
server__metafile_,
|
|
30
|
+
server__metafile__update,
|
|
24
31
|
server__output_,
|
|
32
|
+
server__output__relative_path_,
|
|
25
33
|
server__output__relative_path_M_middleware_ctx_
|
|
26
34
|
} from 'rebuildjs/server'
|
|
27
35
|
import tailwind from 'tailwindcss'
|
|
@@ -41,6 +49,12 @@ export const [
|
|
|
41
49
|
&& rebuildjs__ready_(ctx)
|
|
42
50
|
&& build_id_(ctx) === rebuild_tailwind_plugin__build_id_(ctx)),
|
|
43
51
|
{ id: 'rebuild_tailwind_plugin__ready', ns: 'app' })
|
|
52
|
+
export function rebuild_tailwind_plugin__ready(timeout) {
|
|
53
|
+
return rmemo__wait(
|
|
54
|
+
rebuild_tailwind_plugin__ready$_(app_ctx),
|
|
55
|
+
ready=>ready,
|
|
56
|
+
timeout ?? 10_000)
|
|
57
|
+
}
|
|
44
58
|
export function rebuild_tailwind_plugin_(config) {
|
|
45
59
|
return { name: 'rebuild_tailwind_plugin', setup: setup_() }
|
|
46
60
|
function setup_() {
|
|
@@ -57,15 +71,15 @@ export function rebuild_tailwind_plugin_(config) {
|
|
|
57
71
|
setup.tailwind__build$ = tailwind__build$_()
|
|
58
72
|
return setup
|
|
59
73
|
function tailwind__build$_() {
|
|
60
|
-
return be(app_ctx,
|
|
74
|
+
return be(app_ctx, app_ctx=>
|
|
61
75
|
run(memo_(tailwind__build$=>{
|
|
62
76
|
r()
|
|
63
77
|
return tailwind__build$
|
|
64
78
|
function r() {
|
|
65
|
-
if (!rebuildjs__ready_(
|
|
79
|
+
if (!rebuildjs__ready_(app_ctx)) return
|
|
66
80
|
nullish__none_(tup(
|
|
67
|
-
build_id_(
|
|
68
|
-
rebuildjs__build_id_(
|
|
81
|
+
build_id_(app_ctx),
|
|
82
|
+
rebuildjs__build_id_(app_ctx),
|
|
69
83
|
server__output__relative_path_M_middleware_ctx_(app_ctx),
|
|
70
84
|
), async (
|
|
71
85
|
build_id,
|
|
@@ -73,11 +87,27 @@ export function rebuild_tailwind_plugin_(config) {
|
|
|
73
87
|
server__output__relative_path_M_middleware_ctx,
|
|
74
88
|
)=>{
|
|
75
89
|
try {
|
|
90
|
+
let server__metafile_updated
|
|
91
|
+
let browser_metafile_updated
|
|
76
92
|
for (const middleware_ctx of server__output__relative_path_M_middleware_ctx.values()) {
|
|
77
|
-
await output__process(
|
|
78
|
-
|
|
93
|
+
server__metafile_updated = await output__process(
|
|
94
|
+
server__metafile_(middleware_ctx),
|
|
95
|
+
server__output__relative_path_(middleware_ctx),
|
|
96
|
+
server__output_(middleware_ctx))
|
|
97
|
+
browser_metafile_updated = await output__process(
|
|
98
|
+
browser__metafile_(middleware_ctx),
|
|
99
|
+
browser__output__relative_path_(middleware_ctx),
|
|
100
|
+
browser__output_(middleware_ctx))
|
|
101
|
+
}
|
|
102
|
+
if (server__metafile_updated) {
|
|
103
|
+
await cmd(server__metafile__update(server__metafile_(app_ctx)))
|
|
104
|
+
}
|
|
105
|
+
if (browser_metafile_updated) {
|
|
106
|
+
await cmd(browser__metafile__update(browser__metafile_(app_ctx)))
|
|
107
|
+
}
|
|
108
|
+
if (!server__metafile_updated && !browser_metafile_updated) {
|
|
109
|
+
rebuild_tailwind_plugin__build_id__set(app_ctx, build_id)
|
|
79
110
|
}
|
|
80
|
-
rebuild_tailwind_plugin__build_id__set(ctx, build_id)
|
|
81
111
|
} catch (err) {
|
|
82
112
|
if (err instanceof Cancel) return
|
|
83
113
|
throw err
|
|
@@ -87,25 +117,41 @@ export function rebuild_tailwind_plugin_(config) {
|
|
|
87
117
|
* @returns {Promise<void>}
|
|
88
118
|
*/
|
|
89
119
|
async function output__process(
|
|
90
|
-
|
|
120
|
+
metafile,
|
|
121
|
+
output__relative_path,
|
|
122
|
+
output,
|
|
91
123
|
) {
|
|
124
|
+
let metafile_updated = false
|
|
92
125
|
const cssBundle = output?.cssBundle
|
|
93
|
-
if (!cssBundle) return
|
|
94
|
-
const cssBundle_path = join(cwd_(ctx), cssBundle)
|
|
126
|
+
if (!cssBundle) return metafile_updated
|
|
95
127
|
const esbuild_cssBundle = output.esbuild_cssBundle ?? cssBundle
|
|
96
|
-
const esbuild_cssBundle_path = join(cwd_(
|
|
97
|
-
await file_exists__waitfor(
|
|
128
|
+
const esbuild_cssBundle_path = join(cwd_(app_ctx), esbuild_cssBundle)
|
|
129
|
+
await cmd(file_exists__waitfor(
|
|
98
130
|
esbuild_cssBundle_path,
|
|
99
131
|
1000,
|
|
100
|
-
()=>cmd(sleep(0)))
|
|
132
|
+
()=>cmd(sleep(0))))
|
|
101
133
|
const esbuild_cssBundle_map_path = esbuild_cssBundle_path + '.map'
|
|
102
134
|
const esbuild_cssBundle_map_exists = await cmd(file_exists_(esbuild_cssBundle_map_path))
|
|
135
|
+
const output_hash =
|
|
136
|
+
basename(output__relative_path, '.js')
|
|
137
|
+
.split('-')
|
|
138
|
+
.slice(-1)[0]
|
|
139
|
+
metafile_updated = !cssBundle.includes('_' + output_hash)
|
|
140
|
+
const annotated_cssBundle =
|
|
141
|
+
metafile_updated
|
|
142
|
+
? cssBundle__annotate(cssBundle, '_' + output_hash)
|
|
143
|
+
: cssBundle
|
|
144
|
+
output.cssBundle = annotated_cssBundle
|
|
145
|
+
if (metafile_updated) {
|
|
146
|
+
metafile.outputs[annotated_cssBundle] = metafile.outputs[cssBundle]
|
|
147
|
+
}
|
|
148
|
+
const annotated_cssBundle_path = join(cwd_(app_ctx), annotated_cssBundle)
|
|
103
149
|
const result = await cmd(postcss([
|
|
104
150
|
tailwind({
|
|
105
151
|
...config,
|
|
106
152
|
content: [
|
|
107
153
|
...output.cssBundle_content.map(content__relative_path=>
|
|
108
|
-
join(cwd_(
|
|
154
|
+
join(cwd_(app_ctx), content__relative_path)),
|
|
109
155
|
...(config?.content ?? [])
|
|
110
156
|
]
|
|
111
157
|
})
|
|
@@ -113,17 +159,27 @@ export function rebuild_tailwind_plugin_(config) {
|
|
|
113
159
|
await cmd(readFile(esbuild_cssBundle_path)),
|
|
114
160
|
{
|
|
115
161
|
from: esbuild_cssBundle_path,
|
|
116
|
-
to:
|
|
162
|
+
to: join(cwd_(app_ctx), cssBundle),
|
|
117
163
|
map: esbuild_cssBundle_map_exists
|
|
118
164
|
? {
|
|
119
165
|
prev: JSON.parse(await cmd(readFile(esbuild_cssBundle_path + '.map')))
|
|
120
166
|
}
|
|
121
167
|
: false,
|
|
122
168
|
}))
|
|
123
|
-
await cmd(writeFile(
|
|
169
|
+
await cmd(writeFile(annotated_cssBundle_path, result.css))
|
|
124
170
|
if (result.map) {
|
|
125
|
-
|
|
171
|
+
const map_json = JSON.stringify(result.map)
|
|
172
|
+
await cmd(writeFile(annotated_cssBundle_path + '.map', map_json))
|
|
173
|
+
await cmd(file_exists__waitfor(()=>
|
|
174
|
+
readFile(annotated_cssBundle_path + '.map')
|
|
175
|
+
.then(buf=>'' + buf === map_json),
|
|
176
|
+
5_000))
|
|
126
177
|
}
|
|
178
|
+
await cmd(file_exists__waitfor(()=>
|
|
179
|
+
readFile(annotated_cssBundle_path)
|
|
180
|
+
.then(buf=>'' + buf === result.css),
|
|
181
|
+
5_000))
|
|
182
|
+
return metafile_updated
|
|
127
183
|
}
|
|
128
184
|
async function cmd(promise) {
|
|
129
185
|
if (cancel_()) promise__cancel__throw(promise)
|
|
@@ -133,10 +189,10 @@ export function rebuild_tailwind_plugin_(config) {
|
|
|
133
189
|
}
|
|
134
190
|
function cancel_() {
|
|
135
191
|
return (
|
|
136
|
-
build_id_(
|
|
137
|
-
|| rebuildjs__build_id_(
|
|
192
|
+
build_id_(app_ctx) !== build_id
|
|
193
|
+
|| rebuildjs__build_id_(app_ctx) !== rebuildjs__build_id
|
|
138
194
|
|| server__output__relative_path_M_middleware_ctx_(
|
|
139
|
-
|
|
195
|
+
app_ctx) !== server__output__relative_path_M_middleware_ctx
|
|
140
196
|
)
|
|
141
197
|
}
|
|
142
198
|
})
|