bun_bun_bundle 0.3.6 → 0.3.7

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: ea8665deac6a402f47088b8de4ada9f2e1ac120c8f8b79d3ab6861be9f0efacb
4
- data.tar.gz: 4068228abedaa595b1907dac059d4d28f037d3a4bed43bea2efa919e7289c092
3
+ metadata.gz: 98a722ea47a9c3376749b1db05818efb82f8cba273785d4c44e84a250b7a2b31
4
+ data.tar.gz: f6c2344f88eaf01de284d045dc5b8c3c9558c96ebf8b34f87de9c0accab8aef4
5
5
  SHA512:
6
- metadata.gz: a555adeca44e5e838d44f0bd98e948582217baf3cf8d6382b7d7ff004621bb7b7a9efac0184faf82696dea5bfa169a9c650c93664f4c150cdaf7ff553d9cfc78
7
- data.tar.gz: ffc2455cf858ac6ee545dedfcb82546b90ed35a61d1ea52a32f7d96cd54d16c0454df8f0417ec9df127105a3430ba94015f23d69c377ebd24876e49ed87845dd
6
+ metadata.gz: f4069cbc3d7fb25acba0545c9966d465a3763e472065c34eed0bf2216e75792a2430389ae7a421c1d4caae2fbdb5f10cd07c90fc58b2bb955d99af7cf3418597
7
+ data.tar.gz: 48d6a7b3a6bf8628497586a8a985292ea913387974990d8cb10d90e48791e687197d52be8f5c2e6e2de77e59e31139b97b33ff9880478de4cffec65b4cc7c2cb
data/README.md CHANGED
@@ -198,8 +198,9 @@ Place a `config/bun.json` in your project root:
198
198
  }
199
199
  ```
200
200
 
201
- All values shown above are defaults. You only need to specify what you want to
202
- override.
201
+ > [!TIP]
202
+ > Creating a `bun.json` file is entirely optional. All values shown above are
203
+ > defaults, you only need to specify what you want to override.
203
204
 
204
205
  ## Plugins
205
206
 
@@ -239,10 +240,12 @@ every file, you can import an entire directory at once:
239
240
  ```
240
241
 
241
242
  This will be expanded into individual `@import` lines for each matching file,
242
- sorted alphabetically.
243
+ sorted alphabetically. A warning is logged if the pattern matches no files.
243
244
 
244
- > [!NOTE]
245
- > A warning is logged if the pattern matches no files.
245
+ > [!WARNING]
246
+ > Always include the file extension in glob patterns (e.g., `**/*.css` instead
247
+ > of `**/*`). Without it, editor temp files like Vim's `~` backups will be
248
+ > picked up by the glob, causing build failures during development.
246
249
 
247
250
  ### `jsGlobs`
248
251
 
@@ -8,7 +8,6 @@ export default {
8
8
  IGNORE_PATTERNS: [
9
9
  /^\d+$/,
10
10
  /^\.#/,
11
- /~$/,
12
11
  /\.swp$/,
13
12
  /\.swo$/,
14
13
  /\.tmp$/,
@@ -22,6 +21,7 @@ export default {
22
21
  dev: false,
23
22
  prod: false,
24
23
  wsClients: new Set(),
24
+ watchTimers: new Map(),
25
25
  plugins: [],
26
26
 
27
27
  flags({dev, prod}) {
@@ -99,12 +99,20 @@ export default {
99
99
  continue
100
100
  }
101
101
 
102
- const result = await Bun.build({
103
- entrypoints: [entryPath],
104
- minify: this.prod,
105
- plugins: this.plugins,
106
- ...options
107
- })
102
+ let result
103
+ try {
104
+ result = await Bun.build({
105
+ entrypoints: [entryPath],
106
+ minify: this.prod,
107
+ plugins: this.plugins,
108
+ ...options
109
+ })
110
+ } catch (err) {
111
+ console.error(` ▸ Failed to build ${entry}`)
112
+ if (err.errors) for (const e of err.errors) console.error(e)
113
+ else console.error(err)
114
+ continue
115
+ }
108
116
 
109
117
  if (!result.success) {
110
118
  console.error(` ▸ Failed to build ${entry}`)
@@ -213,27 +221,41 @@ export default {
213
221
  async watch() {
214
222
  const srcDir = join(this.root, this.config.watchDir || 'app/assets')
215
223
 
216
- watch(srcDir, {recursive: true}, async (event, filename) => {
224
+ watch(srcDir, {recursive: true}, (event, filename) => {
217
225
  if (!filename) return
218
226
 
219
- const normalizedFilename = filename.replace(/\\/g, '/')
227
+ let normalizedFilename = filename.replace(/\\/g, '/')
228
+
229
+ // Vim backup files (e.g. app.css~) signal the original file changed
230
+ if (normalizedFilename.endsWith('~'))
231
+ normalizedFilename = normalizedFilename.slice(0, -1)
232
+
220
233
  const base = basename(normalizedFilename)
221
234
  const ext = extname(base).slice(1)
222
235
 
223
236
  if (this.IGNORE_PATTERNS.some(pattern => pattern.test(base))) return
224
237
 
225
- console.log(` ${normalizedFilename} changed`)
238
+ // Debounce: multiple events for the same file (e.g. actual save + backup)
239
+ if (this.watchTimers.has(normalizedFilename)) return
240
+ this.watchTimers.set(normalizedFilename, setTimeout(() => {
241
+ this.watchTimers.delete(normalizedFilename)
242
+ }, 100))
226
243
 
227
- try {
228
- if (ext === 'css') await this.buildCSS()
229
- else if (['js', 'ts', 'jsx', 'tsx'].includes(ext)) await this.buildJS()
230
- else if (base.includes('.')) await this.copyStaticAssets()
244
+ console.log(` ▸ ${normalizedFilename} changed`)
231
245
 
232
- await this.writeManifest()
233
- this.reload(ext === 'css' ? 'css' : 'full')
234
- } catch (err) {
235
- console.error(' Build error:', err.message)
236
- }
246
+ ;(async () => {
247
+ try {
248
+ if (ext === 'css') await this.buildCSS()
249
+ else if (['js', 'ts', 'jsx', 'tsx'].includes(ext)) await this.buildJS()
250
+ else if (base.includes('.')) await this.copyStaticAssets()
251
+
252
+ await this.writeManifest()
253
+ this.reload(ext === 'css' ? 'css' : 'full')
254
+ } catch (err) {
255
+ console.error(' ✖ Build error:', err.message)
256
+ if (err.errors) for (const e of err.errors) console.error(e)
257
+ }
258
+ })()
237
259
  })
238
260
 
239
261
  console.log('Beginning to watch your project')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BunBunBundle
4
- VERSION = '0.3.6'
4
+ VERSION = '0.3.7'
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.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wout Fierens