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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 192332541b28477a4d791698cb2469d96b6b8ed30243c8edeb5636c7a131360b
4
- data.tar.gz: 6b5a34372a29e6b53cc0e27b5193db02359f43a508bcbbf451940a438a281b15
3
+ metadata.gz: 4337760da846f05fed302c7aa1da9767ed8f26d0ae1eaabf3f550d79670a0542
4
+ data.tar.gz: f057d109b5f3b89a72b63b4ae0c1022fb9cc71cc4d0aa2a4ba53c03aec9366bf
5
5
  SHA512:
6
- metadata.gz: db8d44d6fdbe8e3ca9513250bdfbeb1bb03b38cf23e7bc01e917effe292300f311e46a7e979ef995cab1fb170bc46f93ab4f514519d85bff9bf3f77f454a0cac
7
- data.tar.gz: e0808d67347e5728e6bc0d76c5cefe313b260f728fe2da44e8519a5c092b3109f050c1bc23d9810db375b9eafe2bc6e53caf9d353ed03ff25133e325050edca1
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
+ [![CI](https://codeberg.org/w0u7/bun_bun_bundle/actions/workflows/test.yml/badge.svg)](https://codeberg.org/w0u7/bun_bun_bundle/actions?workflow=test.yml)
18
+ [![Gem Version](https://badge.fury.io/rb/bun_bun_bundle.svg)](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
- # Production: builds with fingerprinting and minification
176
+ # Build assets
174
177
  bun_bun_bundle build
175
178
 
176
- # Development with a production build (fingerprinting + minification)
177
- bun_bun_bundle dev --prod
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. I hope you enjoy it too!
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, '--prod', *flags)
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 for production (with fingerprinting)
22
+ build Build assets
23
23
 
24
24
  Flags:
25
- --prod Enable fingerprinting and minification
26
- --dev Enable source maps and watch mode
25
+ --prod Enable minification and fingerprinting
26
+ --debug Enable verbose WebSocket logging
27
27
 
28
28
  Examples:
29
- bun_bun_bundle dev # development with live reload
30
- bun_bun_bundle dev --prod # development with production build
31
- bun_bun_bundle build # production 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
@@ -1,6 +1,7 @@
1
1
  import BunBunBundle from "./bun_bundle.js";
2
2
 
3
3
  BunBunBundle.flags({
4
+ debug: process.argv.includes("--debug"),
4
5
  dev: process.argv.includes("--dev"),
5
6
  prod: process.argv.includes("--prod"),
6
7
  });
@@ -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 entries = this.config.entryPoints[type]
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
  }
@@ -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
- return {contents: content, loader: type}
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BunBunBundle
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
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.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wout Fierens