rebuildjs 0.24.2 → 0.24.3
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/browser/index.js +6 -4
- package/build/index.js +34 -18
- package/package.json +1 -1
- package/server/index.js +6 -4
package/browser/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { file_exists_ } from 'ctx-core/fs'
|
|
2
2
|
import { nullish__none_, waitfor } from 'ctx-core/function'
|
|
3
3
|
import { be_lock_memosig_triple_, be_memo_pair_ } from 'ctx-core/rmemo'
|
|
4
|
-
import { readFile, writeFile } from 'node:fs/promises'
|
|
4
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises'
|
|
5
5
|
import { join, relative } from 'path'
|
|
6
6
|
import { browser__relative_path_, browser_path_ } from '../app/index.js'
|
|
7
7
|
import { app_ctx } from '../ctx/index.js'
|
|
@@ -38,10 +38,12 @@ export function browser__metafile__persist() {
|
|
|
38
38
|
return nullish__none_([
|
|
39
39
|
browser__metafile_path_(app_ctx),
|
|
40
40
|
browser__metafile_(app_ctx)
|
|
41
|
-
], (browser__metafile_path, browser__metafile)=>
|
|
42
|
-
|
|
41
|
+
], async (browser__metafile_path, browser__metafile)=>{
|
|
42
|
+
await mkdir(browser_path_(app_ctx), { recursive: true })
|
|
43
|
+
await writeFile(
|
|
43
44
|
browser__metafile_path,
|
|
44
|
-
JSON.stringify(browser__metafile, null, '\t'))
|
|
45
|
+
JSON.stringify(browser__metafile, null, '\t'))
|
|
46
|
+
})
|
|
45
47
|
}
|
|
46
48
|
export const [
|
|
47
49
|
browser__output__relative_path$_,
|
package/build/index.js
CHANGED
|
@@ -209,30 +209,41 @@ export function rebuildjs_plugin_() {
|
|
|
209
209
|
)=>{
|
|
210
210
|
if (build_id === metafile__build_id) {
|
|
211
211
|
run(async ()=>{
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
212
|
+
try {
|
|
213
|
+
const outputs = server__metafile.outputs ?? {}
|
|
214
|
+
for (let output__relative_path in outputs) {
|
|
215
|
+
if (/(\.js|\.mjs)(\.map)?$/.test(output__relative_path)) continue
|
|
216
|
+
const server_asset_path = join(cwd, output__relative_path)
|
|
217
|
+
const browser_asset_path = join(
|
|
218
|
+
browser_path,
|
|
219
|
+
relative(server__relative_path, output__relative_path))
|
|
220
|
+
await cmd(()=>
|
|
221
|
+
rm(browser_asset_path, { force: true }))
|
|
222
|
+
await cmd(()=>
|
|
223
|
+
file_exists__waitfor(server_asset_path))
|
|
224
|
+
await cmd(()=>
|
|
225
|
+
link(server_asset_path, browser_asset_path))
|
|
226
|
+
}
|
|
227
|
+
} catch (err) {
|
|
228
|
+
if (err instanceof RebuildjsInterrupt) return
|
|
229
|
+
throw err
|
|
225
230
|
}
|
|
226
231
|
})
|
|
227
232
|
}
|
|
233
|
+
async function cmd(fn) {
|
|
234
|
+
if (cancel_()) throw new RebuildjsInterrupt()
|
|
235
|
+
const ret = await fn()
|
|
236
|
+
if (cancel_()) throw new RebuildjsInterrupt()
|
|
237
|
+
return ret
|
|
238
|
+
}
|
|
228
239
|
function cancel_() {
|
|
229
240
|
return (
|
|
230
241
|
build_id_(ctx) !== build_id
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
242
|
+
|| metafile__build_id_(ctx) !== metafile__build_id
|
|
243
|
+
|| server__metafile_(ctx) !== server__metafile
|
|
244
|
+
|| cwd_(ctx) !== cwd
|
|
245
|
+
|| browser_path_(ctx) !== browser_path
|
|
246
|
+
|| server__relative_path_(ctx) !== server__relative_path
|
|
236
247
|
)
|
|
237
248
|
}
|
|
238
249
|
})
|
|
@@ -291,3 +302,8 @@ async function browser__metafile__update(browser__metafile, build_id) {
|
|
|
291
302
|
}
|
|
292
303
|
await browser__metafile__persist()
|
|
293
304
|
}
|
|
305
|
+
export class RebuildjsInterrupt extends Error {
|
|
306
|
+
constructor() {
|
|
307
|
+
super('RebuildjsInterrupt')
|
|
308
|
+
}
|
|
309
|
+
}
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { file_exists_ } from 'ctx-core/fs'
|
|
2
2
|
import { nullish__none_, tup, waitfor } from 'ctx-core/function'
|
|
3
3
|
import { be_lock_memosig_triple_, be_memo_pair_, be_sig_triple_ } from 'ctx-core/rmemo'
|
|
4
|
-
import { readFile, writeFile } from 'node:fs/promises'
|
|
4
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises'
|
|
5
5
|
import { join, relative } from 'path'
|
|
6
6
|
import { cwd_, server__relative_path_, server_path_ } from '../app/index.js'
|
|
7
7
|
import { app_ctx, middleware_ctx_ } from '../ctx/index.js'
|
|
@@ -37,10 +37,12 @@ export function server__metafile__persist() {
|
|
|
37
37
|
return nullish__none_([
|
|
38
38
|
server__metafile_path_(app_ctx),
|
|
39
39
|
server__metafile_(app_ctx)
|
|
40
|
-
], (server__metafile_path, server__metafile)=>
|
|
41
|
-
|
|
40
|
+
], async (server__metafile_path, server__metafile)=>{
|
|
41
|
+
await mkdir(server_path_(app_ctx), { recursive: true })
|
|
42
|
+
await writeFile(
|
|
42
43
|
server__metafile_path,
|
|
43
|
-
JSON.stringify(server__metafile, null, '\t'))
|
|
44
|
+
JSON.stringify(server__metafile, null, '\t'))
|
|
45
|
+
})
|
|
44
46
|
}
|
|
45
47
|
export const [
|
|
46
48
|
server__output__relative_path_M_middleware_ctx$_,
|