bun_bun_bundle 0.4.0 → 0.5.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 +13 -5
- data/exe/bun_bun_bundle +7 -7
- data/lib/bun/bake.js +1 -0
- data/lib/bun/bun_bundle.js +8 -4
- data/lib/bun/plugins/index.js +2 -1
- data/lib/bun_bun_bundle/config.rb +2 -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: 4337760da846f05fed302c7aa1da9767ed8f26d0ae1eaabf3f550d79670a0542
|
|
4
|
+
data.tar.gz: f057d109b5f3b89a72b63b4ae0c1022fb9cc71cc4d0aa2a4ba53c03aec9366bf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 98d7a220fd690cb23664ff8589c0915bfa31d476e6d864127f4f7ae6a8d9ea9277fdb25b25b8d3c158218125f2c68ac5a10cd9db3e8723b4e92f2c23fa4ad264
|
|
7
|
+
data.tar.gz: a7b2ea22fbe70b7077de804b4bdd597bdabaf53bc730b251d825e0e94d8d67e43799f66ba4e840191532e0a68f4ea64633cee6eec2be8bba86f613d3629664cf
|
data/README.md
CHANGED
|
@@ -14,6 +14,9 @@ Works with Rails, Hanami, or any Rack app.
|
|
|
14
14
|
- **Extensible.** Plugins are simple, tiny JavaScript files.
|
|
15
15
|
- **One dependency: Bun.** Everything is included, no other dev dependencies.
|
|
16
16
|
|
|
17
|
+
[](https://codeberg.org/w0u7/bun_bun_bundle/actions?workflow=test.yml)
|
|
18
|
+
[](https://rubygems.org/gems/bun_bun_bundle)
|
|
19
|
+
|
|
17
20
|
> [!Note]
|
|
18
21
|
> The original repository is hosted at
|
|
19
22
|
> [Codeberg](https://codeberg.org/w0u7/bun_bun_bundle). The [GitHub
|
|
@@ -170,11 +173,14 @@ alias):
|
|
|
170
173
|
# Development: builds, watches, and starts the live reload server
|
|
171
174
|
bun_bun_bundle dev
|
|
172
175
|
|
|
173
|
-
#
|
|
176
|
+
# Build assets
|
|
174
177
|
bun_bun_bundle build
|
|
175
178
|
|
|
176
|
-
#
|
|
177
|
-
bun_bun_bundle
|
|
179
|
+
# Build with fingerprinting and minification
|
|
180
|
+
bun_bun_bundle build --prod
|
|
181
|
+
|
|
182
|
+
# Development with verbose WebSocket logging
|
|
183
|
+
bun_bun_bundle dev --debug
|
|
178
184
|
```
|
|
179
185
|
|
|
180
186
|
> [!NOTE]
|
|
@@ -393,7 +399,7 @@ COPY package.json bun.lock ./
|
|
|
393
399
|
RUN bun install --frozen-lockfile
|
|
394
400
|
|
|
395
401
|
COPY . .
|
|
396
|
-
RUN bundle exec bun_bun_bundle build
|
|
402
|
+
RUN bundle exec bun_bun_bundle build --prod
|
|
397
403
|
```
|
|
398
404
|
|
|
399
405
|
> [!NOTE]
|
|
@@ -420,7 +426,9 @@ It's also fast and reliable. We use this setup heavily in two Lucky apps and it
|
|
|
420
426
|
is rock solid. It has since been adopted by Lucky as the default builder.
|
|
421
427
|
|
|
422
428
|
This Gem was born because I wanted to have the same setup in my Ruby apps as
|
|
423
|
-
well.
|
|
429
|
+
well. We now use it for an important Rails app in production.
|
|
430
|
+
|
|
431
|
+
I hope you enjoy it too!
|
|
424
432
|
|
|
425
433
|
## Contributing
|
|
426
434
|
|
data/exe/bun_bun_bundle
CHANGED
|
@@ -12,23 +12,23 @@ case command
|
|
|
12
12
|
when 'dev', 'watch'
|
|
13
13
|
exec('bun', 'run', bake, '--dev', *flags)
|
|
14
14
|
when 'build'
|
|
15
|
-
exec('bun', 'run', bake,
|
|
15
|
+
exec('bun', 'run', bake, *flags)
|
|
16
16
|
else
|
|
17
17
|
puts <<~USAGE
|
|
18
18
|
Usage: bun_bun_bundle <command> [flags]
|
|
19
19
|
|
|
20
20
|
Commands:
|
|
21
21
|
dev Start development server with live reload and CSS hot-reloading
|
|
22
|
-
build Build assets
|
|
22
|
+
build Build assets
|
|
23
23
|
|
|
24
24
|
Flags:
|
|
25
|
-
--prod
|
|
26
|
-
--
|
|
25
|
+
--prod Enable minification and fingerprinting
|
|
26
|
+
--debug Enable verbose WebSocket logging
|
|
27
27
|
|
|
28
28
|
Examples:
|
|
29
|
-
bun_bun_bundle dev
|
|
30
|
-
bun_bun_bundle
|
|
31
|
-
bun_bun_bundle build
|
|
29
|
+
bun_bun_bundle dev # development with live reload
|
|
30
|
+
bun_bun_bundle build # build assets
|
|
31
|
+
bun_bun_bundle build --prod # build with fingerprinting and minification
|
|
32
32
|
|
|
33
33
|
Configuration:
|
|
34
34
|
Place a config/bun.json in your project root to customize settings.
|
data/lib/bun/bake.js
CHANGED
data/lib/bun/bun_bundle.js
CHANGED
|
@@ -18,13 +18,15 @@ export default {
|
|
|
18
18
|
root: process.cwd(),
|
|
19
19
|
config: null,
|
|
20
20
|
manifest: {},
|
|
21
|
+
debug: false,
|
|
21
22
|
dev: false,
|
|
22
23
|
prod: false,
|
|
23
24
|
wsClients: new Set(),
|
|
24
25
|
watchTimers: new Map(),
|
|
25
26
|
plugins: [],
|
|
26
27
|
|
|
27
|
-
flags({dev, prod}) {
|
|
28
|
+
flags({debug, dev, prod}) {
|
|
29
|
+
if (debug != null) this.debug = debug
|
|
28
30
|
if (dev != null) this.dev = dev
|
|
29
31
|
if (prod != null) this.prod = prod
|
|
30
32
|
},
|
|
@@ -87,7 +89,8 @@ export default {
|
|
|
87
89
|
const outDir = join(this.outDir, type)
|
|
88
90
|
mkdirSync(outDir, {recursive: true})
|
|
89
91
|
|
|
90
|
-
const
|
|
92
|
+
const raw = this.config.entryPoints[type]
|
|
93
|
+
const entries = Array.isArray(raw) ? raw : [raw]
|
|
91
94
|
const ext = `.${type}`
|
|
92
95
|
|
|
93
96
|
for (const entry of entries) {
|
|
@@ -266,6 +269,7 @@ export default {
|
|
|
266
269
|
await this.watch()
|
|
267
270
|
|
|
268
271
|
const {host, port, secure} = this.config.devServer
|
|
272
|
+
const debug = this.debug
|
|
269
273
|
const wsClients = this.wsClients
|
|
270
274
|
|
|
271
275
|
Bun.serve({
|
|
@@ -278,11 +282,11 @@ export default {
|
|
|
278
282
|
websocket: {
|
|
279
283
|
open(ws) {
|
|
280
284
|
wsClients.add(ws)
|
|
281
|
-
console.log(` ▸ Client connected (${wsClients.size})\n\n`)
|
|
285
|
+
if (debug) console.log(` ▸ Client connected (${wsClients.size})\n\n`)
|
|
282
286
|
},
|
|
283
287
|
close(ws) {
|
|
284
288
|
wsClients.delete(ws)
|
|
285
|
-
console.log(` ▸ Client disconnected (${wsClients.size})\n\n`)
|
|
289
|
+
if (debug) console.log(` ▸ Client disconnected (${wsClients.size})\n\n`)
|
|
286
290
|
},
|
|
287
291
|
message() {}
|
|
288
292
|
}
|
data/lib/bun/plugins/index.js
CHANGED
|
@@ -20,7 +20,8 @@ function transformPipeline(type, transforms) {
|
|
|
20
20
|
let content = await Bun.file(args.path).text()
|
|
21
21
|
for (const transform of transforms)
|
|
22
22
|
content = await transform(content, args)
|
|
23
|
-
|
|
23
|
+
const ext = args.path.split('.').pop()
|
|
24
|
+
return {contents: content, loader: ext}
|
|
24
25
|
})
|
|
25
26
|
}
|
|
26
27
|
}
|
|
@@ -28,8 +28,8 @@ module BunBunBundle
|
|
|
28
28
|
attr_reader :js, :css
|
|
29
29
|
|
|
30
30
|
def initialize(data = {})
|
|
31
|
-
@js = data.fetch('js', %w[app/assets/js/app.js])
|
|
32
|
-
@css = data.fetch('css', %w[app/assets/css/app.css])
|
|
31
|
+
@js = Array(data.fetch('js', %w[app/assets/js/app.js]))
|
|
32
|
+
@css = Array(data.fetch('css', %w[app/assets/css/app.css]))
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|