bun_bun_bundle 0.10.0 → 0.11.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: d45723ba4d7826f7a860af793c4acf6fbceda366e442f9b9858ec2c1f340e5ec
4
+ data.tar.gz: 13a119627c68cd7009975c40e0caa22f91adc35797b74f7604c35237960a69c8
5
5
  SHA512:
6
- metadata.gz: 9d9e25a4d96f7a17e5231fdb211e01a231114dc6a3cec1c4c29373ed153896943abb13f5b518c954259d39ffd5d6985058323fa95d9125c1baa8bd4fb8c309e2
7
- data.tar.gz: 16530cfc8cbbf16e2f56874b9697fcb0b41aa3aa83266116672f516b9778768b0836886a9456dd24c0dae3b1653e6059290b74a7150e5673400c4847653d9afc
6
+ metadata.gz: 7e7f845bfaff50c0c3a3b18e5dfcac5900929d9d2f261b3931a5bbac47775629d77a834c9e581a6c0dbea04004cbfd4d7a561a7d013524a55a67837e5b3cf42a
7
+ data.tar.gz: 3d17dbcfe26e03538d349bb2a8ba48ec5ecd52b203712ab0296ebaa4502485c7b4275e0a4cfd8764a1d8e6dd2cb56651430ed42ac05c621151d807439eb54e11
@@ -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,10 @@ export default {
264
279
  },
265
280
 
266
281
  async watch() {
282
+ const extras = this.config.watchExtensions || {}
283
+ const cssExts = ['css', ...(extras.css || [])]
284
+ const jsExts = ['js', 'ts', 'jsx', 'tsx', ...(extras.js || [])]
285
+
267
286
  const handler = (event, filename) => {
268
287
  if (!filename) return
269
288
 
@@ -280,16 +299,18 @@ export default {
280
299
 
281
300
  // Debounce: multiple events for the same file (e.g. actual save + backup)
282
301
  if (this.watchTimers.has(normalizedFilename)) return
283
- this.watchTimers.set(normalizedFilename, setTimeout(() => {
284
- this.watchTimers.delete(normalizedFilename)
285
- }, 100))
302
+ this.watchTimers.set(
303
+ normalizedFilename,
304
+ setTimeout(() => {
305
+ this.watchTimers.delete(normalizedFilename)
306
+ }, 100)
307
+ )
286
308
 
287
309
  console.log(` ▸ ${normalizedFilename} changed`)
288
-
289
310
  ;(async () => {
290
311
  try {
291
- if (ext === 'css') await this.buildCSS()
292
- else if (['js', 'ts', 'jsx', 'tsx'].includes(ext)) await this.buildJS()
312
+ if (cssExts.includes(ext)) await this.buildCSS()
313
+ else if (jsExts.includes(ext)) await this.buildJS()
293
314
  else if (base.includes('.')) await this.copyStaticAssets()
294
315
 
295
316
  await this.writeManifest()
@@ -336,7 +357,8 @@ export default {
336
357
  },
337
358
  close(ws) {
338
359
  wsClients.delete(ws)
339
- if (debug) console.log(` ▸ Client disconnected (${wsClients.size})\n\n`)
360
+ if (debug)
361
+ console.log(` ▸ Client disconnected (${wsClients.size})\n\n`)
340
362
  },
341
363
  message() {}
342
364
  }
@@ -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.11.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.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wout Fierens