bun_bun_bundle 0.10.0 → 0.11.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 +35 -13
- 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: d45723ba4d7826f7a860af793c4acf6fbceda366e442f9b9858ec2c1f340e5ec
|
|
4
|
+
data.tar.gz: 13a119627c68cd7009975c40e0caa22f91adc35797b74f7604c35237960a69c8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7e7f845bfaff50c0c3a3b18e5dfcac5900929d9d2f261b3931a5bbac47775629d77a834c9e581a6c0dbea04004cbfd4d7a561a7d013524a55a67837e5b3cf42a
|
|
7
|
+
data.tar.gz: 3d17dbcfe26e03538d349bb2a8ba48ec5ecd52b203712ab0296ebaa4502485c7b4275e0a4cfd8764a1d8e6dd2cb56651430ed42ac05c621151d807439eb54e11
|
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,10 @@ export default {
|
|
|
264
279
|
},
|
|
265
280
|
|
|
266
281
|
async watch() {
|
|
282
|
+
const extras = this.config.watchExtensions || {}
|
|
283
|
+
const cssExts = ['css', ...(extras.css || [])]
|
|
284
|
+
const jsExts = ['js', 'ts', 'jsx', 'tsx', ...(extras.js || [])]
|
|
285
|
+
|
|
267
286
|
const handler = (event, filename) => {
|
|
268
287
|
if (!filename) return
|
|
269
288
|
|
|
@@ -280,16 +299,18 @@ export default {
|
|
|
280
299
|
|
|
281
300
|
// Debounce: multiple events for the same file (e.g. actual save + backup)
|
|
282
301
|
if (this.watchTimers.has(normalizedFilename)) return
|
|
283
|
-
this.watchTimers.set(
|
|
284
|
-
|
|
285
|
-
|
|
302
|
+
this.watchTimers.set(
|
|
303
|
+
normalizedFilename,
|
|
304
|
+
setTimeout(() => {
|
|
305
|
+
this.watchTimers.delete(normalizedFilename)
|
|
306
|
+
}, 100)
|
|
307
|
+
)
|
|
286
308
|
|
|
287
309
|
console.log(` ▸ ${normalizedFilename} changed`)
|
|
288
|
-
|
|
289
310
|
;(async () => {
|
|
290
311
|
try {
|
|
291
|
-
if (ext
|
|
292
|
-
else if (
|
|
312
|
+
if (cssExts.includes(ext)) await this.buildCSS()
|
|
313
|
+
else if (jsExts.includes(ext)) await this.buildJS()
|
|
293
314
|
else if (base.includes('.')) await this.copyStaticAssets()
|
|
294
315
|
|
|
295
316
|
await this.writeManifest()
|
|
@@ -336,7 +357,8 @@ export default {
|
|
|
336
357
|
},
|
|
337
358
|
close(ws) {
|
|
338
359
|
wsClients.delete(ws)
|
|
339
|
-
if (debug)
|
|
360
|
+
if (debug)
|
|
361
|
+
console.log(` ▸ Client disconnected (${wsClients.size})\n\n`)
|
|
340
362
|
},
|
|
341
363
|
message() {}
|
|
342
364
|
}
|
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
|
}
|