@rebuildjs/tailwindcss 0.4.0 → 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
- "name": "@rebuildjs/tailwindcss",
3
- "version": "0.4.0",
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
- "dependencies": {
38
- "ctx-core": "^5.37.0",
39
- "esbuild": "^0.20.0",
40
- "postcss": "^8.4.33",
41
- "rebuildjs": "^0.53.0",
42
- "tailwindcss": "^3.4.1"
43
- },
44
- "devDependencies": {
45
- "c8": "^9.1.0",
46
- "check-dts": "^0.7.2",
47
- "esmock": "^2.6.3",
48
- "relementjs": "^0.63.0",
49
- "tsx": "^4.7.0",
50
- "typescript": "next",
51
- "uvu": "^0.5.6"
52
- },
53
- "publishConfig": {
54
- "access": "public",
55
- "cache": "~/.npm"
56
- },
57
- "sideEffects": false,
58
- "scripts": {
59
- "build": ":",
60
- "clean": ":",
61
- "exec": "$@",
62
- "test": "pnpm test:unit && pnpm test:types",
63
- "test:types": "check-dts",
64
- "test:unit": "NODE_OPTIONS=--loader=esmock tsx node_modules/uvu/bin.js . '\\.test\\.(ts|js)$'",
65
- "test:unit:coverage": "c8 pnpm test:unit"
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
  }
@@ -87,19 +87,27 @@ export function rebuild_tailwind_plugin_(config) {
87
87
  server__output__relative_path_M_middleware_ctx,
88
88
  )=>{
89
89
  try {
90
+ let server__metafile_updated
91
+ let browser_metafile_updated
90
92
  for (const middleware_ctx of server__output__relative_path_M_middleware_ctx.values()) {
91
- await output__process(
93
+ server__metafile_updated = await output__process(
92
94
  server__metafile_(middleware_ctx),
93
95
  server__output__relative_path_(middleware_ctx),
94
96
  server__output_(middleware_ctx))
95
- await output__process(
97
+ browser_metafile_updated = await output__process(
96
98
  browser__metafile_(middleware_ctx),
97
99
  browser__output__relative_path_(middleware_ctx),
98
100
  browser__output_(middleware_ctx))
99
101
  }
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)
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)
110
+ }
103
111
  } catch (err) {
104
112
  if (err instanceof Cancel) return
105
113
  throw err
@@ -113,25 +121,30 @@ export function rebuild_tailwind_plugin_(config) {
113
121
  output__relative_path,
114
122
  output,
115
123
  ) {
124
+ let metafile_updated = false
116
125
  const cssBundle = output?.cssBundle
117
- if (!cssBundle) return
126
+ if (!cssBundle) return metafile_updated
118
127
  const esbuild_cssBundle = output.esbuild_cssBundle ?? cssBundle
119
128
  const esbuild_cssBundle_path = join(cwd_(app_ctx), esbuild_cssBundle)
120
- await file_exists__waitfor(
129
+ await cmd(file_exists__waitfor(
121
130
  esbuild_cssBundle_path,
122
131
  1000,
123
- ()=>cmd(sleep(0)))
132
+ ()=>cmd(sleep(0))))
124
133
  const esbuild_cssBundle_map_path = esbuild_cssBundle_path + '.map'
125
134
  const esbuild_cssBundle_map_exists = await cmd(file_exists_(esbuild_cssBundle_map_path))
126
135
  const output_hash =
127
136
  basename(output__relative_path, '.js')
128
137
  .split('-')
129
138
  .slice(-1)[0]
139
+ metafile_updated = !cssBundle.includes('_' + output_hash)
130
140
  const annotated_cssBundle =
131
- cssBundle.includes('_' + output_hash)
132
- ? cssBundle
133
- : cssBundle__annotate(cssBundle, '_' + output_hash)
141
+ metafile_updated
142
+ ? cssBundle__annotate(cssBundle, '_' + output_hash)
143
+ : cssBundle
134
144
  output.cssBundle = annotated_cssBundle
145
+ if (metafile_updated) {
146
+ metafile.outputs[annotated_cssBundle] = metafile.outputs[cssBundle]
147
+ }
135
148
  const annotated_cssBundle_path = join(cwd_(app_ctx), annotated_cssBundle)
136
149
  const result = await cmd(postcss([
137
150
  tailwind({
@@ -155,8 +168,18 @@ export function rebuild_tailwind_plugin_(config) {
155
168
  }))
156
169
  await cmd(writeFile(annotated_cssBundle_path, result.css))
157
170
  if (result.map) {
158
- await cmd(writeFile(annotated_cssBundle_path + '.map', JSON.stringify(result.map)))
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))
159
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
160
183
  }
161
184
  async function cmd(promise) {
162
185
  if (cancel_()) promise__cancel__throw(promise)