@divriots/jampack 0.11.3 → 0.11.5

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/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -96,7 +96,7 @@ In a 2nd PASS, `jampack` compresses all untouched assets and keep the same name
96
96
  | Extension | Compressor |
97
97
  | --------------- | --------------------- |
98
98
  | `.html`,`.htm` | [`html-minifier-terser`](https://github.com/terser/html-minifier-terser) |
99
- | `.css` | Best of [`csso`](https://github.com/css/csso) & [`lightningCSS`](https://lightningcss.dev) |
99
+ | `.css` | [`lightningCSS`](https://lightningcss.dev) |
100
100
  | `.js` | [`swc`](https://swc.rs/) |
101
101
  | `.svg` | [`svgo`](https://github.com/svg/svgo) |
102
102
  | `.jpg`,`.jpeg` | [`sharp`](https://sharp.pixelplumbing.com/) |
@@ -1,14 +1,7 @@
1
- import { minify as csso } from 'csso';
2
1
  import { transform as lightcss, transformStyleAttribute as lightcssStyleAttribute, } from 'lightningcss';
3
2
  export async function compressCSS(originalCode, type) {
4
- // csso only support css files. No inline style
5
- let cssoCSSData = undefined;
6
- if (type !== 'inline') {
7
- // Compress with csso
8
- cssoCSSData = Buffer.from(await csso(originalCode.toString(), { comments: false }).css);
9
- }
10
3
  // Compress with lightningcss
11
- let lightCSSData;
4
+ let lightCSSData = undefined;
12
5
  try {
13
6
  const options = {
14
7
  code: originalCode,
@@ -24,18 +17,11 @@ export async function compressCSS(originalCode, type) {
24
17
  }
25
18
  catch (e) {
26
19
  // Error while processing with lightningcss
27
- // Ignore, we have csso as backup
20
+ // Take original code
21
+ // TODO catch SyntaxError and report a Warning
28
22
  }
29
23
  let resultBuffer = undefined;
30
- // Pick the best
31
- if (cssoCSSData && lightCSSData) {
32
- resultBuffer =
33
- cssoCSSData.length <= lightCSSData.length ? cssoCSSData : lightCSSData;
34
- }
35
- else if (cssoCSSData && !lightCSSData) {
36
- resultBuffer = cssoCSSData;
37
- }
38
- else if (!cssoCSSData && lightCSSData) {
24
+ if (lightCSSData && lightCSSData.length < originalCode.length) {
39
25
  resultBuffer = lightCSSData;
40
26
  }
41
27
  return resultBuffer || originalCode;
@@ -5,11 +5,6 @@ const default_options = {
5
5
  image: {
6
6
  embed_size: 1500,
7
7
  srcset_min_width: 640,
8
- external: {
9
- process: 'download',
10
- src_include: /.*/,
11
- src_exclude: null,
12
- },
13
8
  compress: true,
14
9
  jpeg: {
15
10
  options: {
@@ -10,11 +10,6 @@ export type Options = {
10
10
  image: {
11
11
  embed_size: number;
12
12
  srcset_min_width: number;
13
- external: {
14
- process: 'download' | 'add-dimensions-only' | 'off';
15
- src_include: RegExp | undefined;
16
- src_exclude: RegExp | null;
17
- };
18
13
  compress: boolean;
19
14
  jpeg: {
20
15
  options: {
package/dist/index.js CHANGED
File without changes
package/dist/optimize.js CHANGED
@@ -184,21 +184,9 @@ async function processImage(htmlfile, $, imgElement, isAboveTheFold) {
184
184
  * Attribute 'decoding'
185
185
  */
186
186
  img.attr('decoding', 'async');
187
- /*
188
- * Check for external images
189
- */
190
187
  if (!isLocal(attrib_src)) {
191
- switch (config.image.external.process) {
192
- case 'off':
193
- // Don't process external images
194
- return;
195
- case 'download':
196
- // Download external image for local processing
197
- break;
198
- case 'add-dimensions-only':
199
- // Only add dimensions of image
200
- return;
201
- }
188
+ // Image not local, don't touch it
189
+ return;
202
190
  }
203
191
  /*
204
192
  * Loading image
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divriots/jampack",
3
- "version": "0.11.3",
3
+ "version": "0.11.5",
4
4
  "description": "Packer for static websites",
5
5
  "author": "Georges Gomes @georges-gomes",
6
6
  "bin": {
@@ -19,12 +19,7 @@
19
19
  "@divriots/cheerio": "1.0.0-rc.12",
20
20
  "@proload/core": "^0.3.3",
21
21
  "@swc/core": "^1.3.57",
22
- "@types/csso": "^5.0.0",
23
- "@types/html-minifier-terser": "^7.0.0",
24
- "@types/sharp": "^0.32.0",
25
- "@types/svgo": "^3.0.0",
26
22
  "commander": "^10.0.1",
27
- "csso": "^5.0.5",
28
23
  "deepmerge": "^4.3.1",
29
24
  "file-type": "^18.4.0",
30
25
  "globby": "^13.1.4",
@@ -39,22 +34,23 @@
39
34
  "table": "^6.8.1"
40
35
  },
41
36
  "devDependencies": {
37
+ "@types/html-minifier-terser": "^7.0.0",
42
38
  "@types/node": "^16.18.28",
43
39
  "shx": "^0.3.3",
44
40
  "ts-node": "^10.2.1",
45
41
  "tslib": "^2.5.0",
46
42
  "typescript": "^5.0.4"
47
43
  },
48
- "scripts": {
49
- "watch": "pnpm build --watch",
50
- "try": "shx rm -fr demo && cp -R demo_rf demo && node ./dist/index.js ./demo --nocache --onlyoptim",
51
- "build": "shx rm -rf dist && tsc -b",
52
- "lint": "eslint . --ext .ts --config .eslintrc"
53
- },
54
44
  "engines": {
55
45
  "node": ">=14.0.0"
56
46
  },
57
47
  "bugs": "https://github.com/divriots/jampack/issues",
58
48
  "keywords": [],
59
- "types": "dist/index.d.ts"
60
- }
49
+ "types": "dist/index.d.ts",
50
+ "scripts": {
51
+ "watch": "pnpm build --watch",
52
+ "try": "shx rm -fr demo && cp -R demo_rf demo && node ./dist/index.js ./demo --nocache --onlyoptim",
53
+ "build": "shx rm -rf dist && tsc -b",
54
+ "lint": "eslint . --ext .ts --config .eslintrc"
55
+ }
56
+ }