compress-shader-literals 1.3.0 → 1.3.2
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.
- package/README.md +25 -25
- package/dist/index.cjs +1 -1
- package/dist/index.js +6 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,31 +83,31 @@ Real shaders shipped by popular libraries, run through the built-in minifier:
|
|
|
83
83
|
|
|
84
84
|
<!-- STATS:START -->
|
|
85
85
|
|
|
86
|
-
| Package | Shaders | Before | After | Saved |
|
|
87
|
-
| ----------------------------- | ------: | ----------: | ----------: | --------: |
|
|
88
|
-
| `vtk.js` | 142 | 276,617 B | 159,634 B | **42.3%** |
|
|
89
|
-
| `three-stdlib` | 370 | 429,350 B | 272,486 B | **36.5%** |
|
|
90
|
-
| `curtainsjs` | 7 | 3,406 B | 2,352 B | **30.9%** |
|
|
91
|
-
| `hydra-synth` | 15 | 3,852 B | 2,675 B | **30.6%** |
|
|
92
|
-
| `cesium` | 546 | 951,897 B | 664,581 B | **30.2%** |
|
|
93
|
-
| `troika-three-utils` | 4 | 168 B | 120 B | **28.6%** |
|
|
94
|
-
| `pixi.js` | 162 | 75,768 B | 56,152 B | **25.9%** |
|
|
95
|
-
| `shader-park-core` | 18 | 10,794 B | 8,007 B | **25.8%** |
|
|
96
|
-
| `@luma.gl/shadertools` | 24 | 149,192 B | 111,095 B | **25.5%** |
|
|
97
|
-
| `three` | 281 | 240,906 B | 185,520 B | **23.0%** |
|
|
98
|
-
| `playcanvas` | 856 | 1,297,844 B | 1,039,365 B | **19.9%** |
|
|
99
|
-
| `ogl` | 22 | 6,109 B | 4,925 B | **19.4%** |
|
|
100
|
-
| `deck.gl` | 132 | 242,113 B | 198,706 B | **17.9%** |
|
|
101
|
-
| `@paper-design/shaders` | 30 | 142,466 B | 122,036 B | **14.3%** |
|
|
102
|
-
| `@deck.gl/layers` | 104 | 223,902 B | 195,827 B | **12.5%** |
|
|
103
|
-
| `@deck.gl/core` | 40 | 17,746 B | 15,738 B | **11.3%** |
|
|
104
|
-
| `@deck.gl/aggregation-layers` | 56 | 43,713 B | 39,094 B | **10.6%** |
|
|
105
|
-
| `@luma.gl/engine` | 29 | 11,357 B | 10,384 B | **8.6%** |
|
|
106
|
-
| `@babylonjs/core` | 349 | 669,740 B | 661,013 B | **1.3%** |
|
|
107
|
-
| `postprocessing` | 136 | 179,705 B | 179,705 B | **0.0%** |
|
|
108
|
-
| **Total** | 3323 | 4,976,645 B | 3,929,415 B | **21.0%** |
|
|
109
|
-
|
|
110
|
-
_3323 shaders ·
|
|
86
|
+
| Package | Shaders | Before | After | Saved | Net after Brotli |
|
|
87
|
+
| ----------------------------- | ------: | ----------: | ----------: | --------: | ---------------: |
|
|
88
|
+
| `vtk.js` | 142 | 276,617 B | 159,634 B | **42.3%** | +39.6% |
|
|
89
|
+
| `three-stdlib` | 370 | 429,350 B | 272,486 B | **36.5%** | +35.5% |
|
|
90
|
+
| `curtainsjs` | 7 | 3,406 B | 2,352 B | **30.9%** | +10.1% |
|
|
91
|
+
| `hydra-synth` | 15 | 3,852 B | 2,675 B | **30.6%** | +19.4% |
|
|
92
|
+
| `cesium` | 546 | 951,897 B | 664,581 B | **30.2%** | +32.6% |
|
|
93
|
+
| `troika-three-utils` | 4 | 168 B | 120 B | **28.6%** | — |
|
|
94
|
+
| `pixi.js` | 162 | 75,768 B | 56,152 B | **25.9%** | — |
|
|
95
|
+
| `shader-park-core` | 18 | 10,794 B | 8,007 B | **25.8%** | — |
|
|
96
|
+
| `@luma.gl/shadertools` | 24 | 149,192 B | 111,095 B | **25.5%** | — |
|
|
97
|
+
| `three` | 281 | 240,906 B | 185,520 B | **23.0%** | — |
|
|
98
|
+
| `playcanvas` | 856 | 1,297,844 B | 1,039,365 B | **19.9%** | — |
|
|
99
|
+
| `ogl` | 22 | 6,109 B | 4,925 B | **19.4%** | — |
|
|
100
|
+
| `deck.gl` | 132 | 242,113 B | 198,706 B | **17.9%** | — |
|
|
101
|
+
| `@paper-design/shaders` | 30 | 142,466 B | 122,036 B | **14.3%** | — |
|
|
102
|
+
| `@deck.gl/layers` | 104 | 223,902 B | 195,827 B | **12.5%** | — |
|
|
103
|
+
| `@deck.gl/core` | 40 | 17,746 B | 15,738 B | **11.3%** | — |
|
|
104
|
+
| `@deck.gl/aggregation-layers` | 56 | 43,713 B | 39,094 B | **10.6%** | — |
|
|
105
|
+
| `@luma.gl/engine` | 29 | 11,357 B | 10,384 B | **8.6%** | — |
|
|
106
|
+
| `@babylonjs/core` | 349 | 669,740 B | 661,013 B | **1.3%** | — |
|
|
107
|
+
| `postprocessing` | 136 | 179,705 B | 179,705 B | **0.0%** | — |
|
|
108
|
+
| **Total** | 3323 | 4,976,645 B | 3,929,415 B | **21.0%** | — |
|
|
109
|
+
|
|
110
|
+
_3323 shaders · 2477/3323 parseable shaders (GLSL + WGSL) verified valid after minify · [how this is measured](docs/stats.md) · 2026-07-08_
|
|
111
111
|
|
|
112
112
|
<!-- STATS:END -->
|
|
113
113
|
|
package/dist/index.cjs
CHANGED
|
@@ -6,4 +6,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
6
6
|
`:n+=n===``||n.endsWith(`
|
|
7
7
|
`)?e:` `+e,r=e.endsWith(`\\`);return r=!1,n=n.split(`
|
|
8
8
|
`).map(e=>{let t=e.startsWith(`#`)||r?e:e.replace(S,`$1`);return r=e.endsWith(`\\`),t}).join(`
|
|
9
|
-
`),n.trim()},E=(0,d.createUnplugin)((e={})=>{let t=e.tags||m,n=e.transform||T,r=(0,c.createFilter)(e.include||h,e.exclude||g),i=``,a
|
|
9
|
+
`),n.trim()},E=(0,d.createUnplugin)((e={})=>{let t=e.tags||m,n=e.transform||T,r=(0,c.createFilter)(e.include||h,e.exclude||g),i=``,a=``,o=0;return{name:`compress-shader-literals`,enforce:`pre`,transform(s,c){if(!r(c)||!t.some(e=>s.includes(e)))return null;let l=w(s,t);if(l.length===0)return null;e.debug&&console.log(`[compress-shader-literals] ${c}: ${l.length} literal(s) — ${l.map(e=>e.tag).join(`, `)}`);let d=new u.default(s),f=!1;for(let t of l){let r=n(t.value);t.value!==r&&(d.overwrite(t.start,t.end,`\`${r}\``),f=!0),e.outputRatio&&(i+=t.value,a+=r,o++)}return f?{code:d.toString(),map:d.generateMap({hires:!0,source:c})}:null},buildEnd(){if(e.outputRatio&&i){let e=`compress-shader-literals: ${o} shader literal${o===1?``:`s`}`;(0,l.diff)(l.snap.text(i),l.snap.text(a)).print(e)}}}});exports.compressShaderLiterals=E,exports.extractShaderLiterals=w,exports.minifyShader=T;
|
package/dist/index.js
CHANGED
|
@@ -61,7 +61,7 @@ var s = [
|
|
|
61
61
|
return r = e.endsWith("\\"), t;
|
|
62
62
|
}).join("\n"), n.trim();
|
|
63
63
|
}, y = i((i = {}) => {
|
|
64
|
-
let a = i.tags || s, o = i.transform || v, u = e(i.include || c, i.exclude || l), d = "", f = "";
|
|
64
|
+
let a = i.tags || s, o = i.transform || v, u = e(i.include || c, i.exclude || l), d = "", f = "", p = 0;
|
|
65
65
|
return {
|
|
66
66
|
name: "compress-shader-literals",
|
|
67
67
|
enforce: "pre",
|
|
@@ -73,7 +73,7 @@ var s = [
|
|
|
73
73
|
let s = new r(e), c = !1;
|
|
74
74
|
for (let e of n) {
|
|
75
75
|
let t = o(e.value);
|
|
76
|
-
e.value !== t && (s.overwrite(e.start, e.end, `\`${t}\``), c = !0), i.outputRatio && (d += e.value, f += t);
|
|
76
|
+
e.value !== t && (s.overwrite(e.start, e.end, `\`${t}\``), c = !0), i.outputRatio && (d += e.value, f += t, p++);
|
|
77
77
|
}
|
|
78
78
|
return c ? {
|
|
79
79
|
code: s.toString(),
|
|
@@ -84,7 +84,10 @@ var s = [
|
|
|
84
84
|
} : null;
|
|
85
85
|
},
|
|
86
86
|
buildEnd() {
|
|
87
|
-
i.outputRatio && d
|
|
87
|
+
if (i.outputRatio && d) {
|
|
88
|
+
let e = `compress-shader-literals: ${p} shader literal${p === 1 ? "" : "s"}`;
|
|
89
|
+
t(n.text(d), n.text(f)).print(e);
|
|
90
|
+
}
|
|
88
91
|
}
|
|
89
92
|
};
|
|
90
93
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compress-shader-literals",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "✂️ Strip comments & whitespace from GLSL/WGSL shader literals in your JS/TS at build time — any bundler, no toolchain, no runtime cost.",
|
|
6
6
|
"main": "./dist/index.cjs",
|