bun_bun_bundle 0.15.1 → 0.17.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: efbe626f3c9d8abd553a9d2ba4e62bc56616228ca33b7b46638bc9f1b8ae2b34
4
- data.tar.gz: cff4e8780c9cf25bf07cb2417a13a22056a3081558f184b1baa4311b107049bc
3
+ metadata.gz: 9c79743b209590b3032ac218c34f97bb265a730c6d531a8e610535cc7091b904
4
+ data.tar.gz: 72c36c431475e6ae64cd6e9f9b1bfd5e4e6636fe816c08dab890dcd8938d569a
5
5
  SHA512:
6
- metadata.gz: 14946ddc866eb9695bf55eb43c3d0e4e7f5d41e670339baa26a935b931bb1081dc4e2a4a53a08300a29508e39d84c16c6a0fb393118b125b999ecf883b1777e8
7
- data.tar.gz: a5bf6c88fd8c19c8a16599ce41b0e4972a4b5cfacd7994413fe2f6f277568764662b6af89a19d25762ce3f3b0ada63283d7d252089a688b603c40621e8953241
6
+ metadata.gz: 2cb7ae2c2abc22ec33e8476a595c083fc9f380020a5c53d1601b34c4e3937ecda165e3b707037a6873cbc3aef79a6a549ddbded82b7e4dc5b3f8c8fd355a256f
7
+ data.tar.gz: f224269b08ada52408905e18b29f63a9f03f153cd755add16247b199c25ae551cec554c58bdf3f21fa025a104872667806c2a340c9bc2c95149f7569ec3dce14
data/README.md CHANGED
@@ -319,6 +319,20 @@ To exclude specific paths, add one or more `not` clauses:
319
319
  './components/internal/**';
320
320
  ```
321
321
 
322
+ Cascade layer assignments are preserved on each expanded import. Both named
323
+ and anonymous forms are supported:
324
+
325
+ ```css
326
+ @import './components/*.css' layer(components);
327
+ @import './utilities/*.css' layer;
328
+ ```
329
+
330
+ `layer` clauses may be combined with `not` clauses (layer first):
331
+
332
+ ```css
333
+ @import './components/**/*.css' layer(components) not './components/admin/**';
334
+ ```
335
+
322
336
  > [!WARNING]
323
337
  > Always include the file extension in glob patterns (e.g., `**/*.css` instead
324
338
  > of `**/*`). Without it, editor temp files like Vim's `~` backups will be
@@ -433,6 +447,10 @@ Reference custom plugins by their file path in your config:
433
447
  }
434
448
  ```
435
449
 
450
+ A plugin list replaces the built-in list for that asset type only. In the
451
+ example above both lists re-include the defaults, but overriding just `"js"`
452
+ leaves the default `css` plugins (`aliases`, `cssGlobs`) in place.
453
+
436
454
  > [!WARNING]
437
455
  > The order of the plugins matters here. For example, the aliases plugin needs
438
456
  > to resolve the paths first before the glob plugin can do its work. Keep that
@@ -141,7 +141,6 @@ export default {
141
141
  const json = readFileSync(join(this.root, this.CONFIG_PATH), 'utf-8')
142
142
  const user = JSON.parse(json)
143
143
  this.config = this.deepMerge(defaults, user)
144
- if (user.plugins != null) this.config.plugins = user.plugins
145
144
  } catch {
146
145
  this.config = defaults
147
146
  }
@@ -1,6 +1,6 @@
1
1
  const CSS_REGEX = /((?:url\(\s*|@import\s+|not\s+)['"]?(?:glob:)?)\$\//g
2
2
  const JS_REGEX =
3
- /((?:from\s+|require\s*\(\s*|import\s*\(\s*)['"](?:glob:)?)\$\//g
3
+ /((?:from\s+|import\s+|require\s*\(\s*|import\s*\(\s*)['"](?:glob:)?)\$\//g
4
4
 
5
5
  // Resolves `$/` root aliases in CSS url() references and JS/CSS imports.
6
6
  // e.g. url('$/app/assets/images/foo.png') → url('/absolute/root/app/assets/images/foo.png')
@@ -2,12 +2,16 @@ import {dirname, relative, resolve, join} from 'path'
2
2
  import {Glob} from 'bun'
3
3
 
4
4
  const IMPORT_RE =
5
- /@import\s+['"]([^'"]*\*[^'"]*)['"]((?:\s+not\s+['"][^'"]*['"])*)\s*;/g
5
+ /@import\s+['"]([^'"]*\*[^'"]*)['"](?:\s+(layer(?:\([^)]*\))?))?((?:\s+not\s+['"][^'"]*['"])*)\s*;/g
6
6
  const NOT_RE = /not\s+['"]([^'"]*)['"]/g
7
7
 
8
8
  function parseImport(match) {
9
- const nots = [...(match[2] || '').matchAll(NOT_RE)]
10
- return {pattern: match[1], excludes: nots.map(m => m[1])}
9
+ const nots = [...(match[3] || '').matchAll(NOT_RE)]
10
+ return {
11
+ pattern: match[1],
12
+ layer: match[2] || null,
13
+ excludes: nots.map(m => m[1])
14
+ }
11
15
  }
12
16
 
13
17
  function splitGlob(pattern) {
@@ -48,7 +52,7 @@ export default function cssGlobs() {
48
52
  const replacements = []
49
53
 
50
54
  for (const match of content.matchAll(IMPORT_RE)) {
51
- const {pattern, excludes} = parseImport(match)
55
+ const {pattern, layer, excludes} = parseImport(match)
52
56
  const files = (await scanFiles(fileDir, pattern, excludes)).filter(
53
57
  f => resolve(fileDir, f) !== args.path
54
58
  )
@@ -64,9 +68,10 @@ export default function cssGlobs() {
64
68
  const s = files.length !== 1 ? 's' : ''
65
69
  console.log(` CSS glob: ${label} → ${files.length} file${s}`)
66
70
 
71
+ const suffix = layer ? ` ${layer}` : ''
67
72
  replacements.push({
68
73
  fullMatch: match[0],
69
- expanded: files.map(f => `@import '${f}';`).join('\n')
74
+ expanded: files.map(f => `@import '${f}'${suffix};`).join('\n')
70
75
  })
71
76
  }
72
77
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BunBunBundle
4
- VERSION = '0.15.1'
4
+ VERSION = '0.17.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.15.1
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wout Fierens