vite-plugin-singlefile-compression 2.0.9 → 2.0.10
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 +3 -2
- package/dist/compress.js +11 -8
- package/dist/getTemplate.js +1 -1
- package/dist/getVersion.js +1 -1
- package/dist/index.js +13 -12
- package/dist/options.d.ts +1 -0
- package/dist/options.js +1 -1
- package/package.json +10 -8
package/README.md
CHANGED
|
@@ -95,6 +95,7 @@ export interface Options {
|
|
|
95
95
|
/**
|
|
96
96
|
* Compress format.
|
|
97
97
|
* https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream/DecompressionStream
|
|
98
|
+
* @type "deflate-raw" | "deflate" | "gzip" | "brotli" | "zstd"
|
|
98
99
|
* @default "deflate-raw"
|
|
99
100
|
*/
|
|
100
101
|
compressFormat?: compressFormat
|
|
@@ -121,7 +122,7 @@ vite v7.3.1 building client environment for production...
|
|
|
121
122
|
✓ 46 modules transformed.
|
|
122
123
|
rendering chunks (1)...
|
|
123
124
|
|
|
124
|
-
vite-plugin-singlefile-compression 2.0.
|
|
125
|
+
vite-plugin-singlefile-compression 2.0.10 building...
|
|
125
126
|
|
|
126
127
|
file:///D:/code/js/vite-plugin-singlefile-compression/test/dist/index.html
|
|
127
128
|
107.149 kB -> 48.323 kB
|
|
@@ -129,7 +130,7 @@ vite-plugin-singlefile-compression 2.0.9 building...
|
|
|
129
130
|
Finish.
|
|
130
131
|
|
|
131
132
|
dist/index.html 48.32 kB
|
|
132
|
-
✓ built in
|
|
133
|
+
✓ built in 829ms
|
|
133
134
|
```
|
|
134
135
|
|
|
135
136
|

|
package/dist/compress.js
CHANGED
|
@@ -17,16 +17,19 @@ const compressors = {
|
|
|
17
17
|
zstd: zlib.zstdCompressSync,
|
|
18
18
|
};
|
|
19
19
|
function switchCompressor(format) {
|
|
20
|
-
if (
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(compressors, format)) {
|
|
21
|
+
const f = compressors[format];
|
|
22
|
+
if (f)
|
|
23
|
+
return f;
|
|
24
|
+
throw Error(`Could not get compressor: Please upgrade node.js or set your compressor function.`);
|
|
25
|
+
}
|
|
26
|
+
let funcName = format + 'CompressSync';
|
|
27
|
+
if (Object.prototype.hasOwnProperty.call(zlib, funcName)) {
|
|
21
28
|
const f = zlib[format + 'CompressSync'];
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
return f;
|
|
29
|
+
if (typeof f == 'function')
|
|
30
|
+
return f;
|
|
25
31
|
}
|
|
26
|
-
|
|
27
|
-
if (!f)
|
|
28
|
-
throw Error(`Could not get compressor: Please upgrade node.js or set your compressor function.`);
|
|
29
|
-
return f;
|
|
32
|
+
throw Error(`Could not get compressor: Unknown compress format '${format}', please set your compressor function.`);
|
|
30
33
|
}
|
|
31
34
|
export function compress(format, buf, useBase128, compressor) {
|
|
32
35
|
const outBuf = compressor ? compressor(buf) : switchCompressor(format)(buf);
|
package/dist/getTemplate.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
import { compress } from './compress.js';
|
|
4
4
|
function r(name) {
|
|
5
|
-
return fs.readFileSync(fileURLToPath(
|
|
5
|
+
return fs.readFileSync(fileURLToPath(new URL(`./template/${name}.js`, import.meta.url))).toString();
|
|
6
6
|
}
|
|
7
7
|
function rt(name, template) {
|
|
8
8
|
const s = r(name).split(template);
|
package/dist/getVersion.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
|
-
export const
|
|
3
|
+
export const version = JSON.parse(fs.readFileSync(fileURLToPath(new URL("../package.json", import.meta.url))).toString()).version;
|
package/dist/index.js
CHANGED
|
@@ -21,18 +21,19 @@ export function singleFileCompression(opt) {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
export default singleFileCompression;
|
|
24
|
-
function setConfig(config) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
function setConfig(config, env) {
|
|
25
|
+
config.base ??= './';
|
|
26
|
+
const build = (config.build ??= {});
|
|
27
|
+
build.cssCodeSplit ??= false;
|
|
28
|
+
build.assetsInlineLimit ??= () => true;
|
|
29
|
+
build.chunkSizeWarningLimit ??= Number.MAX_SAFE_INTEGER;
|
|
30
|
+
build.modulePreload ??= { polyfill: false };
|
|
31
|
+
build.reportCompressedSize ??= false;
|
|
32
|
+
const rollupOptions = (this.meta.rolldownVersion
|
|
33
|
+
? (build.rolldownOptions ?? build.rollupOptions ?? (build.rolldownOptions = {}))
|
|
34
|
+
: (build.rollupOptions ??= {}));
|
|
35
|
+
for (const output of [rollupOptions.output ??= {}].flat(1)) {
|
|
36
|
+
output.inlineDynamicImports ??= true;
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
async function generateBundle(bundle, config, options) {
|
package/dist/options.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface Options {
|
|
|
40
40
|
/**
|
|
41
41
|
* Compress format.
|
|
42
42
|
* https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream/DecompressionStream
|
|
43
|
+
* @type "deflate-raw" | "deflate" | "gzip" | "brotli" | "zstd"
|
|
43
44
|
* @default "deflate-raw"
|
|
44
45
|
*/
|
|
45
46
|
compressFormat?: compressFormat;
|
package/dist/options.js
CHANGED
|
@@ -7,7 +7,7 @@ export const defaultHtmlMinifierTerserOptions = {
|
|
|
7
7
|
minifyJS: false,
|
|
8
8
|
};
|
|
9
9
|
export function getInnerOptions(opt) {
|
|
10
|
-
opt
|
|
10
|
+
opt ||= {};
|
|
11
11
|
return {
|
|
12
12
|
rename: opt.rename && opt.rename.replace(/(\.(html?)?)?$/, '.html'),
|
|
13
13
|
htmlMinifierTerser: opt.htmlMinifierTerser == null || opt.htmlMinifierTerser === true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-singlefile-compression",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"author": "bddjr",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Compress all assets and embeds them into dist/index.html, making it convenient to share as a single HTML file.",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
],
|
|
14
14
|
"type": "module",
|
|
15
15
|
"scripts": {
|
|
16
|
-
"build": "rimraf dist && tsc && node build.js && cd test && node --run build",
|
|
16
|
+
"build": "rimraf dist && tsc && node build.js && es-check es2021 --checkFeatures --module dist/**/*.js && cd test && node --run build",
|
|
17
17
|
"prepublishOnly": "node --run build"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
@@ -43,20 +43,22 @@
|
|
|
43
43
|
"class"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
+
"@types/html-minifier-terser": ">=7.0.2",
|
|
46
47
|
"base128-ascii": ">=2.1.0",
|
|
47
48
|
"html-minifier-terser": ">=7.2.0",
|
|
48
49
|
"jsdom": ">=26.0.0",
|
|
49
50
|
"mime": ">=4.0.4",
|
|
50
51
|
"mini-svg-data-uri": ">=1.4.4",
|
|
51
|
-
"picocolors": ">=1.1.1"
|
|
52
|
-
"@types/html-minifier-terser": ">=7.0.2"
|
|
52
|
+
"picocolors": ">=1.1.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"vite": ">=6.2.5",
|
|
56
|
-
"rimraf": ">=6.0.1",
|
|
57
55
|
"@types/jsdom": ">=21.1.7",
|
|
58
56
|
"@types/node": ">=22.10.7",
|
|
57
|
+
"es-check": "^9.5.3",
|
|
59
58
|
"esbuild": ">=0.25.0",
|
|
60
|
-
"
|
|
59
|
+
"rimraf": ">=6.0.1",
|
|
60
|
+
"rollup": ">=4.55.1",
|
|
61
|
+
"typescript": ">=5.7.2",
|
|
62
|
+
"vite": ">=6.2.5"
|
|
61
63
|
}
|
|
62
|
-
}
|
|
64
|
+
}
|