@rebuildjs/tailwindcss 0.3.20 → 0.4.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebuildjs/tailwindcss",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Tailwindcss integration with rebuildjs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tailwindcss",
|
|
@@ -35,17 +35,17 @@
|
|
|
35
35
|
"./package.json": "./package.json"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"ctx-core": "^5.
|
|
38
|
+
"ctx-core": "^5.37.0",
|
|
39
39
|
"esbuild": "^0.20.0",
|
|
40
40
|
"postcss": "^8.4.33",
|
|
41
|
-
"rebuildjs": "^0.
|
|
41
|
+
"rebuildjs": "^0.53.0",
|
|
42
42
|
"tailwindcss": "^3.4.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"c8": "^9.1.0",
|
|
46
46
|
"check-dts": "^0.7.2",
|
|
47
47
|
"esmock": "^2.6.3",
|
|
48
|
-
"relementjs": "^0.
|
|
48
|
+
"relementjs": "^0.63.0",
|
|
49
49
|
"tsx": "^4.7.0",
|
|
50
50
|
"typescript": "next",
|
|
51
51
|
"uvu": "^0.5.6"
|
|
@@ -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,
|
|
@@ -74,10 +88,18 @@ export function rebuild_tailwind_plugin_(config) {
|
|
|
74
88
|
)=>{
|
|
75
89
|
try {
|
|
76
90
|
for (const middleware_ctx of server__output__relative_path_M_middleware_ctx.values()) {
|
|
77
|
-
await output__process(
|
|
78
|
-
|
|
91
|
+
await output__process(
|
|
92
|
+
server__metafile_(middleware_ctx),
|
|
93
|
+
server__output__relative_path_(middleware_ctx),
|
|
94
|
+
server__output_(middleware_ctx))
|
|
95
|
+
await output__process(
|
|
96
|
+
browser__metafile_(middleware_ctx),
|
|
97
|
+
browser__output__relative_path_(middleware_ctx),
|
|
98
|
+
browser__output_(middleware_ctx))
|
|
79
99
|
}
|
|
80
|
-
|
|
100
|
+
await server__metafile__update(server__metafile_(app_ctx))
|
|
101
|
+
await browser__metafile__update(browser__metafile_(app_ctx))
|
|
102
|
+
rebuild_tailwind_plugin__build_id__set(app_ctx, build_id)
|
|
81
103
|
} catch (err) {
|
|
82
104
|
if (err instanceof Cancel) return
|
|
83
105
|
throw err
|
|
@@ -87,25 +109,36 @@ export function rebuild_tailwind_plugin_(config) {
|
|
|
87
109
|
* @returns {Promise<void>}
|
|
88
110
|
*/
|
|
89
111
|
async function output__process(
|
|
90
|
-
|
|
112
|
+
metafile,
|
|
113
|
+
output__relative_path,
|
|
114
|
+
output,
|
|
91
115
|
) {
|
|
92
116
|
const cssBundle = output?.cssBundle
|
|
93
117
|
if (!cssBundle) return
|
|
94
|
-
const cssBundle_path = join(cwd_(ctx), cssBundle)
|
|
95
118
|
const esbuild_cssBundle = output.esbuild_cssBundle ?? cssBundle
|
|
96
|
-
const esbuild_cssBundle_path = join(cwd_(
|
|
119
|
+
const esbuild_cssBundle_path = join(cwd_(app_ctx), esbuild_cssBundle)
|
|
97
120
|
await file_exists__waitfor(
|
|
98
121
|
esbuild_cssBundle_path,
|
|
99
122
|
1000,
|
|
100
123
|
()=>cmd(sleep(0)))
|
|
101
124
|
const esbuild_cssBundle_map_path = esbuild_cssBundle_path + '.map'
|
|
102
125
|
const esbuild_cssBundle_map_exists = await cmd(file_exists_(esbuild_cssBundle_map_path))
|
|
126
|
+
const output_hash =
|
|
127
|
+
basename(output__relative_path, '.js')
|
|
128
|
+
.split('-')
|
|
129
|
+
.slice(-1)[0]
|
|
130
|
+
const annotated_cssBundle =
|
|
131
|
+
cssBundle.includes('_' + output_hash)
|
|
132
|
+
? cssBundle
|
|
133
|
+
: cssBundle__annotate(cssBundle, '_' + output_hash)
|
|
134
|
+
output.cssBundle = annotated_cssBundle
|
|
135
|
+
const annotated_cssBundle_path = join(cwd_(app_ctx), annotated_cssBundle)
|
|
103
136
|
const result = await cmd(postcss([
|
|
104
137
|
tailwind({
|
|
105
138
|
...config,
|
|
106
139
|
content: [
|
|
107
140
|
...output.cssBundle_content.map(content__relative_path=>
|
|
108
|
-
join(cwd_(
|
|
141
|
+
join(cwd_(app_ctx), content__relative_path)),
|
|
109
142
|
...(config?.content ?? [])
|
|
110
143
|
]
|
|
111
144
|
})
|
|
@@ -113,16 +146,16 @@ export function rebuild_tailwind_plugin_(config) {
|
|
|
113
146
|
await cmd(readFile(esbuild_cssBundle_path)),
|
|
114
147
|
{
|
|
115
148
|
from: esbuild_cssBundle_path,
|
|
116
|
-
to:
|
|
149
|
+
to: join(cwd_(app_ctx), cssBundle),
|
|
117
150
|
map: esbuild_cssBundle_map_exists
|
|
118
151
|
? {
|
|
119
152
|
prev: JSON.parse(await cmd(readFile(esbuild_cssBundle_path + '.map')))
|
|
120
153
|
}
|
|
121
154
|
: false,
|
|
122
155
|
}))
|
|
123
|
-
await cmd(writeFile(
|
|
156
|
+
await cmd(writeFile(annotated_cssBundle_path, result.css))
|
|
124
157
|
if (result.map) {
|
|
125
|
-
await cmd(writeFile(
|
|
158
|
+
await cmd(writeFile(annotated_cssBundle_path + '.map', JSON.stringify(result.map)))
|
|
126
159
|
}
|
|
127
160
|
}
|
|
128
161
|
async function cmd(promise) {
|
|
@@ -133,10 +166,10 @@ export function rebuild_tailwind_plugin_(config) {
|
|
|
133
166
|
}
|
|
134
167
|
function cancel_() {
|
|
135
168
|
return (
|
|
136
|
-
build_id_(
|
|
137
|
-
|| rebuildjs__build_id_(
|
|
169
|
+
build_id_(app_ctx) !== build_id
|
|
170
|
+
|| rebuildjs__build_id_(app_ctx) !== rebuildjs__build_id
|
|
138
171
|
|| server__output__relative_path_M_middleware_ctx_(
|
|
139
|
-
|
|
172
|
+
app_ctx) !== server__output__relative_path_M_middleware_ctx
|
|
140
173
|
)
|
|
141
174
|
}
|
|
142
175
|
})
|