bun_bun_bundle 0.13.0 → 0.15.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/README.md +17 -0
- data/lib/bun/bun_bundle.js +23 -9
- data/lib/bun_bun_bundle/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 83cae9e5463f7df2c26023e77369676ee32206ee5460fe8e9aa3a9448bf69fae
|
|
4
|
+
data.tar.gz: a800d5ce3030e40a0fce533a8adee35036956406dc27e000bd59aa850f6c356a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8dc2812c44a0a19e59ec112528279a0ba3454808bf8cbab7b650adbf4ec27399f12667c6d85486e8b0ab60a5eb11ac24af728635b8ae0c72b8b0e8d78542affc
|
|
7
|
+
data.tar.gz: c8a21adc9822064299c0fa8db67570837ce04b18395b2b0932f4a7bffa33cb9faf6752effe538b62005c737f076d917c8544bdea96e58c2107f3a7149931f8e8
|
data/README.md
CHANGED
|
@@ -82,6 +82,19 @@ replaces it entirely, you can clean up the default setup:
|
|
|
82
82
|
- Delete `config/assets.js`
|
|
83
83
|
- Remove all dev dependencies from `package.json`
|
|
84
84
|
|
|
85
|
+
> [!NOTE]
|
|
86
|
+
> BunBunBundle takes a different approach from `hanami-assets`, it doesn't
|
|
87
|
+
> integrate (well) with it. The key difference is coupling. `hanami-assets`
|
|
88
|
+
> ties front-end organisation to back-end slice structure: each slice gets its
|
|
89
|
+
> own `:assets` provider, its own manifest, and its own bundle, and helpers
|
|
90
|
+
> resolve through the slice container. BunBunBundle leaves the two independent.
|
|
91
|
+
> You can still bundle per slice though; just add the slice's entry point to
|
|
92
|
+
> `bun.json` and reference it like any other asset, but the front-end is free
|
|
93
|
+
> to organise itself differently from the slices (one shared bundle, multiple
|
|
94
|
+
> bundles split by audience or weight, whatever makes sense). On top of that,
|
|
95
|
+
> BunBunBundle ships live reload, CSS hot-reloading, and a plugin system that
|
|
96
|
+
> `hanami-assets` does not. Mixing the two is possible but not recommended.
|
|
97
|
+
|
|
85
98
|
1. Set up the Hanami integration:
|
|
86
99
|
|
|
87
100
|
```ruby
|
|
@@ -244,6 +257,10 @@ Place a `config/bun.json` in your project root:
|
|
|
244
257
|
> Creating a `bun.json` file is entirely optional. All values shown above are
|
|
245
258
|
> defaults, you only need to specify what you want to override.
|
|
246
259
|
|
|
260
|
+
`watchDirs` entries may be glob patterns. For example, in a Hanami app with
|
|
261
|
+
multiple slices, `"slices/*/assets"` will watch every slice's assets directory
|
|
262
|
+
without having to list them explicitly.
|
|
263
|
+
|
|
247
264
|
If you're developing inside a Docker container, set `listenHost` so the
|
|
248
265
|
WebSocket server accepts connections from the host machine:
|
|
249
266
|
|
data/lib/bun/bun_bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {mkdirSync, readFileSync, existsSync, rmSync, watch} from 'fs'
|
|
1
|
+
import {mkdirSync, readFileSync, existsSync, rmSync, statSync, watch} from 'fs'
|
|
2
2
|
import {join, dirname, basename, extname} from 'path'
|
|
3
3
|
import {Glob} from 'bun'
|
|
4
4
|
import {resolvePlugins} from './plugins/index.js'
|
|
@@ -29,6 +29,7 @@ export default {
|
|
|
29
29
|
watchTimers: new Map(),
|
|
30
30
|
watchers: [],
|
|
31
31
|
plugins: [],
|
|
32
|
+
ok: true,
|
|
32
33
|
|
|
33
34
|
SRI_ALGORITHMS: ['sha256', 'sha384', 'sha512'],
|
|
34
35
|
|
|
@@ -201,18 +202,21 @@ export default {
|
|
|
201
202
|
console.error(` ▸ Failed to build ${entry}`)
|
|
202
203
|
if (err.errors) for (const e of err.errors) console.error(e)
|
|
203
204
|
else console.error(err)
|
|
205
|
+
this.ok = false
|
|
204
206
|
continue
|
|
205
207
|
}
|
|
206
208
|
|
|
207
209
|
if (!result.success) {
|
|
208
210
|
console.error(` ▸ Failed to build ${entry}`)
|
|
209
211
|
for (const log of result.logs) console.error(log)
|
|
212
|
+
this.ok = false
|
|
210
213
|
continue
|
|
211
214
|
}
|
|
212
215
|
|
|
213
216
|
const mainOutput = result.outputs.find(o => o.path.endsWith(ext))
|
|
214
217
|
if (!mainOutput) {
|
|
215
218
|
console.error(` ▸ No ${type.toUpperCase()} output for ${entry}`)
|
|
219
|
+
this.ok = false
|
|
216
220
|
continue
|
|
217
221
|
}
|
|
218
222
|
const mapOutput = result.outputs.find(o => o.kind === 'sourcemap')
|
|
@@ -294,6 +298,7 @@ export default {
|
|
|
294
298
|
const env = this.prod ? 'production' : 'development'
|
|
295
299
|
console.log(`Building manifest for ${env}...`)
|
|
296
300
|
const start = performance.now()
|
|
301
|
+
this.ok = true
|
|
297
302
|
this.loadConfig()
|
|
298
303
|
await this.loadPlugins()
|
|
299
304
|
this.cleanOutDir()
|
|
@@ -302,7 +307,9 @@ export default {
|
|
|
302
307
|
await this.buildCSS()
|
|
303
308
|
await this.writeManifest()
|
|
304
309
|
const ms = Math.round(performance.now() - start)
|
|
305
|
-
|
|
310
|
+
const status = this.ok ? 'DONE Built successfully' : ' ✖ Built with errors'
|
|
311
|
+
console.log(`${status} in ${ms} ms`, this.prettyManifest())
|
|
312
|
+
return this.ok
|
|
306
313
|
},
|
|
307
314
|
|
|
308
315
|
prettyManifest() {
|
|
@@ -382,13 +389,18 @@ export default {
|
|
|
382
389
|
})()
|
|
383
390
|
}
|
|
384
391
|
|
|
385
|
-
for (const
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
392
|
+
for (const pattern of this.config.watchDirs) {
|
|
393
|
+
const dirs = pattern.includes('*')
|
|
394
|
+
? await Array.fromAsync(new Glob(pattern).scan({cwd: this.root, onlyFiles: false}))
|
|
395
|
+
: [pattern]
|
|
396
|
+
for (const dir of dirs) {
|
|
397
|
+
const fullDir = join(this.root, dir)
|
|
398
|
+
if (!existsSync(fullDir) || !statSync(fullDir).isDirectory()) {
|
|
399
|
+
console.warn(` ▸ Watch directory ${dir} does not exist, skipping...`)
|
|
400
|
+
continue
|
|
401
|
+
}
|
|
402
|
+
this.watchers.push(watch(fullDir, {recursive: true}, handler))
|
|
390
403
|
}
|
|
391
|
-
this.watchers.push(watch(fullDir, {recursive: true}, handler))
|
|
392
404
|
}
|
|
393
405
|
|
|
394
406
|
console.log('Beginning to watch your project')
|
|
@@ -453,6 +465,8 @@ export default {
|
|
|
453
465
|
},
|
|
454
466
|
|
|
455
467
|
async bake() {
|
|
456
|
-
this.dev
|
|
468
|
+
if (this.dev) return this.serve()
|
|
469
|
+
const ok = await this.build()
|
|
470
|
+
if (!ok) process.exit(1)
|
|
457
471
|
}
|
|
458
472
|
}
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bun_bun_bundle
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.15.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Wout Fierens
|
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
74
|
version: '0'
|
|
75
75
|
requirements: []
|
|
76
|
-
rubygems_version: 4.0.
|
|
76
|
+
rubygems_version: 4.0.19
|
|
77
77
|
specification_version: 4
|
|
78
78
|
summary: A self-contained asset bundler powered by Bun
|
|
79
79
|
test_files: []
|