bun_bun_bundle 0.10.0 → 0.12.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.
- checksums.yaml +4 -4
- data/lib/bun/bun_bundle.js +47 -15
- data/lib/bun/plugins/aliases.js +7 -2
- data/lib/bun_bun_bundle/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e88344a8027274fd0bf210fd826b6a8eb4cd80b34e48db2cc886fdb9c011972a
|
|
4
|
+
data.tar.gz: 89491a62dde5fd360eb425beae246e86ff864aaab65bf6a36b8eea06206b2480
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 075a8083d7f4c3475baf35338945f2342165bcad6da5fc801f656be6fbef9f4448b6231d2b11abc720b4bb02974abeb0ea1dfa1c5db7bc4d50e705601b4f0b5b
|
|
7
|
+
data.tar.gz: 1b5efa9b78a883cb40d4d266534f93193bcb5d3c74095ccb2a8d2293da7a7cd922f727a60c6c9850478b64530456fcaa9bf3908ad45d05756ab94b7decfd0a69
|
data/lib/bun/bun_bundle.js
CHANGED
|
@@ -29,8 +29,11 @@ export default {
|
|
|
29
29
|
plugins: [],
|
|
30
30
|
|
|
31
31
|
flags(input) {
|
|
32
|
-
const {debug, dev, prod, fingerprint, minify, sourcemap} =
|
|
33
|
-
|
|
32
|
+
const {debug, dev, prod, fingerprint, minify, sourcemap} = Array.isArray(
|
|
33
|
+
input
|
|
34
|
+
)
|
|
35
|
+
? this.parseArgv(input)
|
|
36
|
+
: input
|
|
34
37
|
if (debug != null) this.debug = debug
|
|
35
38
|
if (dev != null) this.dev = dev
|
|
36
39
|
if (prod != null) this.prod = prod
|
|
@@ -50,11 +53,16 @@ export default {
|
|
|
50
53
|
if (argv.includes('--prod')) opts.prod = true
|
|
51
54
|
if (argv.includes('--fingerprint')) opts.fingerprint = true
|
|
52
55
|
if (argv.includes('--minify')) opts.minify = true
|
|
53
|
-
const sm = argv.find(
|
|
56
|
+
const sm = argv.find(
|
|
57
|
+
a => a === '--sourcemap' || a.startsWith('--sourcemap=')
|
|
58
|
+
)
|
|
54
59
|
if (sm) {
|
|
55
60
|
const value = sm.includes('=') ? sm.split('=')[1] : 'linked'
|
|
56
61
|
if (this.SOURCEMAP_KINDS.includes(value)) opts.sourcemap = value
|
|
57
|
-
else
|
|
62
|
+
else
|
|
63
|
+
console.warn(
|
|
64
|
+
` ▸ Ignoring --sourcemap=${value} (valid: ${this.SOURCEMAP_KINDS.join(', ')})`
|
|
65
|
+
)
|
|
58
66
|
}
|
|
59
67
|
return opts
|
|
60
68
|
},
|
|
@@ -71,7 +79,10 @@ export default {
|
|
|
71
79
|
|
|
72
80
|
loadConfig() {
|
|
73
81
|
const defaults = {
|
|
74
|
-
entryPoints: {
|
|
82
|
+
entryPoints: {
|
|
83
|
+
js: ['app/assets/js/app.js'],
|
|
84
|
+
css: ['app/assets/css/app.css']
|
|
85
|
+
},
|
|
75
86
|
plugins: {css: ['aliases', 'cssGlobs'], js: ['aliases', 'jsGlobs']},
|
|
76
87
|
watchDirs: ['app/assets'],
|
|
77
88
|
staticDirs: ['app/assets/images', 'app/assets/fonts'],
|
|
@@ -207,7 +218,11 @@ export default {
|
|
|
207
218
|
|
|
208
219
|
const ext = extname(file)
|
|
209
220
|
const name = file.slice(0, -ext.length) || file
|
|
210
|
-
const fileName = this.fingerprintName(
|
|
221
|
+
const fileName = this.fingerprintName(
|
|
222
|
+
name,
|
|
223
|
+
ext,
|
|
224
|
+
new Uint8Array(content)
|
|
225
|
+
)
|
|
211
226
|
const destPath = join(destDir, fileName)
|
|
212
227
|
|
|
213
228
|
mkdirSync(dirname(destPath), {recursive: true})
|
|
@@ -264,6 +279,12 @@ export default {
|
|
|
264
279
|
},
|
|
265
280
|
|
|
266
281
|
async watch() {
|
|
282
|
+
const cssBase = ['css']
|
|
283
|
+
const jsBase = ['js', 'ts', 'jsx', 'tsx']
|
|
284
|
+
const extras = this.config.watchExtensions || {}
|
|
285
|
+
const cssExts = [...cssBase, ...(extras.css || [])]
|
|
286
|
+
const jsExts = [...jsBase, ...(extras.js || [])]
|
|
287
|
+
|
|
267
288
|
const handler = (event, filename) => {
|
|
268
289
|
if (!filename) return
|
|
269
290
|
|
|
@@ -280,20 +301,30 @@ export default {
|
|
|
280
301
|
|
|
281
302
|
// Debounce: multiple events for the same file (e.g. actual save + backup)
|
|
282
303
|
if (this.watchTimers.has(normalizedFilename)) return
|
|
283
|
-
this.watchTimers.set(
|
|
284
|
-
|
|
285
|
-
|
|
304
|
+
this.watchTimers.set(
|
|
305
|
+
normalizedFilename,
|
|
306
|
+
setTimeout(() => {
|
|
307
|
+
this.watchTimers.delete(normalizedFilename)
|
|
308
|
+
}, 100)
|
|
309
|
+
)
|
|
286
310
|
|
|
287
311
|
console.log(` ▸ ${normalizedFilename} changed`)
|
|
288
|
-
|
|
289
312
|
;(async () => {
|
|
290
313
|
try {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
314
|
+
let kind = null
|
|
315
|
+
if (cssExts.includes(ext)) {
|
|
316
|
+
await this.buildCSS()
|
|
317
|
+
if (cssBase.includes(ext)) kind = 'css'
|
|
318
|
+
} else if (jsExts.includes(ext)) {
|
|
319
|
+
await this.buildJS()
|
|
320
|
+
if (jsBase.includes(ext)) kind = 'full'
|
|
321
|
+
} else if (base.includes('.')) {
|
|
322
|
+
await this.copyStaticAssets()
|
|
323
|
+
kind = 'full'
|
|
324
|
+
}
|
|
294
325
|
|
|
295
326
|
await this.writeManifest()
|
|
296
|
-
this.reload(
|
|
327
|
+
if (kind) this.reload(kind)
|
|
297
328
|
} catch (err) {
|
|
298
329
|
console.error(' ✖ Build error:', err.message)
|
|
299
330
|
if (err.errors) for (const e of err.errors) console.error(e)
|
|
@@ -336,7 +367,8 @@ export default {
|
|
|
336
367
|
},
|
|
337
368
|
close(ws) {
|
|
338
369
|
wsClients.delete(ws)
|
|
339
|
-
if (debug)
|
|
370
|
+
if (debug)
|
|
371
|
+
console.log(` ▸ Client disconnected (${wsClients.size})\n\n`)
|
|
340
372
|
},
|
|
341
373
|
message() {}
|
|
342
374
|
}
|
data/lib/bun/plugins/aliases.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
const
|
|
1
|
+
const CSS_REGEX = /((?:url\(\s*|@import\s+)['"]?(?:glob:)?)\$\//g
|
|
2
|
+
const JS_REGEX =
|
|
3
|
+
/((?:from\s+|require\s*\(\s*|import\s*\(\s*)['"](?:glob:)?)\$\//g
|
|
2
4
|
|
|
3
5
|
// Resolves `$/` root aliases in CSS url() references and JS/CSS imports.
|
|
4
6
|
// e.g. url('$/app/assets/images/foo.png') → url('/absolute/root/app/assets/images/foo.png')
|
|
5
7
|
// import x from '$/lib/utils.js' → import x from '/absolute/root/lib/utils.js'
|
|
6
8
|
// @import '$/app/assets/css/reset.css' → @import '/absolute/root/app/assets/css/reset.css'
|
|
7
9
|
export default function aliases({root}) {
|
|
8
|
-
return content =>
|
|
10
|
+
return (content, args) => {
|
|
11
|
+
const regex = args.path.endsWith('.css') ? CSS_REGEX : JS_REGEX
|
|
12
|
+
return content.replace(regex, `$1${root}/`)
|
|
13
|
+
}
|
|
9
14
|
}
|