bun_bun_bundle 0.10.0 → 0.12.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: 29e412dc1eeee94ba33c0f47186a649d6a8843b2a4edaf01cf7b72e7f66b29c2
4
- data.tar.gz: 3744a8ccad103452e0099c6cb8e5bae65ed7a8c4eeb820cad2d52e8accb9384f
3
+ metadata.gz: e88344a8027274fd0bf210fd826b6a8eb4cd80b34e48db2cc886fdb9c011972a
4
+ data.tar.gz: 89491a62dde5fd360eb425beae246e86ff864aaab65bf6a36b8eea06206b2480
5
5
  SHA512:
6
- metadata.gz: 9d9e25a4d96f7a17e5231fdb211e01a231114dc6a3cec1c4c29373ed153896943abb13f5b518c954259d39ffd5d6985058323fa95d9125c1baa8bd4fb8c309e2
7
- data.tar.gz: 16530cfc8cbbf16e2f56874b9697fcb0b41aa3aa83266116672f516b9778768b0836886a9456dd24c0dae3b1653e6059290b74a7150e5673400c4847653d9afc
6
+ metadata.gz: 075a8083d7f4c3475baf35338945f2342165bcad6da5fc801f656be6fbef9f4448b6231d2b11abc720b4bb02974abeb0ea1dfa1c5db7bc4d50e705601b4f0b5b
7
+ data.tar.gz: 1b5efa9b78a883cb40d4d266534f93193bcb5d3c74095ccb2a8d2293da7a7cd922f727a60c6c9850478b64530456fcaa9bf3908ad45d05756ab94b7decfd0a69
@@ -29,8 +29,11 @@ export default {
29
29
  plugins: [],
30
30
 
31
31
  flags(input) {
32
- const {debug, dev, prod, fingerprint, minify, sourcemap} =
33
- Array.isArray(input) ? this.parseArgv(input) : input
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(a => a === '--sourcemap' || a.startsWith('--sourcemap='))
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 console.warn(` ▸ Ignoring --sourcemap=${value} (valid: ${this.SOURCEMAP_KINDS.join(', ')})`)
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: {js: ['app/assets/js/app.js'], css: ['app/assets/css/app.css']},
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(name, ext, new Uint8Array(content))
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,12 @@ export default {
264
279
  },
265
280
 
266
281
  async watch() {
282
+ const cssBase = ['css']
283
+ const jsBase = ['js', 'ts', 'jsx', 'tsx']
284
+ const extras = this.config.watchExtensions || {}
285
+ const cssExts = [...cssBase, ...(extras.css || [])]
286
+ const jsExts = [...jsBase, ...(extras.js || [])]
287
+
267
288
  const handler = (event, filename) => {
268
289
  if (!filename) return
269
290
 
@@ -280,20 +301,30 @@ export default {
280
301
 
281
302
  // Debounce: multiple events for the same file (e.g. actual save + backup)
282
303
  if (this.watchTimers.has(normalizedFilename)) return
283
- this.watchTimers.set(normalizedFilename, setTimeout(() => {
284
- this.watchTimers.delete(normalizedFilename)
285
- }, 100))
304
+ this.watchTimers.set(
305
+ normalizedFilename,
306
+ setTimeout(() => {
307
+ this.watchTimers.delete(normalizedFilename)
308
+ }, 100)
309
+ )
286
310
 
287
311
  console.log(` ▸ ${normalizedFilename} changed`)
288
-
289
312
  ;(async () => {
290
313
  try {
291
- if (ext === 'css') await this.buildCSS()
292
- else if (['js', 'ts', 'jsx', 'tsx'].includes(ext)) await this.buildJS()
293
- else if (base.includes('.')) await this.copyStaticAssets()
314
+ let kind = null
315
+ if (cssExts.includes(ext)) {
316
+ await this.buildCSS()
317
+ if (cssBase.includes(ext)) kind = 'css'
318
+ } else if (jsExts.includes(ext)) {
319
+ await this.buildJS()
320
+ if (jsBase.includes(ext)) kind = 'full'
321
+ } else if (base.includes('.')) {
322
+ await this.copyStaticAssets()
323
+ kind = 'full'
324
+ }
294
325
 
295
326
  await this.writeManifest()
296
- this.reload(ext === 'css' ? 'css' : 'full')
327
+ if (kind) this.reload(kind)
297
328
  } catch (err) {
298
329
  console.error(' ✖ Build error:', err.message)
299
330
  if (err.errors) for (const e of err.errors) console.error(e)
@@ -336,7 +367,8 @@ export default {
336
367
  },
337
368
  close(ws) {
338
369
  wsClients.delete(ws)
339
- if (debug) console.log(` ▸ Client disconnected (${wsClients.size})\n\n`)
370
+ if (debug)
371
+ console.log(` ▸ Client disconnected (${wsClients.size})\n\n`)
340
372
  },
341
373
  message() {}
342
374
  }
@@ -1,9 +1,14 @@
1
- const REGEX = /(url\(\s*['"]?|(?<!\w)['"](?:glob:)?)\$\//g
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 => content.replace(REGEX, `$1${root}/`)
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
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BunBunBundle
4
- VERSION = '0.10.0'
4
+ VERSION = '0.12.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.10.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wout Fierens