@jsenv/plugin-minification 1.3.2 → 1.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/plugin-minification",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,8 +25,8 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "html-minifier": "4.0.0",
28
- "lightningcss": "1.20.0",
29
- "terser": "5.17.7"
28
+ "lightningcss": "1.21.5",
29
+ "terser": "5.18.2"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@jsenv/core": "*"
@@ -1,9 +1,9 @@
1
1
  import { fileURLToPath } from "node:url";
2
2
 
3
- export const minifyCss = async ({ cssUrlInfo, context }) => {
3
+ export const minifyCss = async (cssUrlInfo) => {
4
4
  const { transform } = await import("lightningcss");
5
5
 
6
- const targets = runtimeCompatToTargets(context.runtimeCompat);
6
+ const targets = runtimeCompatToTargets(cssUrlInfo.context.runtimeCompat);
7
7
  const { code, map } = transform({
8
8
  filename: fileURLToPath(cssUrlInfo.originalUrl),
9
9
  code: Buffer.from(cssUrlInfo.content),
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from "node:module";
2
2
 
3
3
  // https://github.com/kangax/html-minifier#options-quick-reference
4
- export const minifyHtml = ({ htmlUrlInfo, options } = {}) => {
4
+ export const minifyHtml = (htmlUrlInfo, options = {}) => {
5
5
  const require = createRequire(import.meta.url);
6
6
  const { minify } = require("html-minifier");
7
7
 
@@ -1,6 +1,6 @@
1
1
  // https://github.com/terser-js/terser#minify-options
2
2
 
3
- export const minifyJs = async ({ jsUrlInfo, options }) => {
3
+ export const minifyJs = async (jsUrlInfo, options) => {
4
4
  const url = jsUrlInfo.url;
5
5
  const content = jsUrlInfo.content;
6
6
  const sourcemap = jsUrlInfo.sourcemap;
@@ -12,52 +12,22 @@ export const jsenvPluginMinification = ({
12
12
  svg = {},
13
13
  } = {}) => {
14
14
  const htmlMinifier = html
15
- ? (urlInfo, context) =>
16
- minifyHtml({
17
- htmlUrlInfo: urlInfo,
18
- context,
19
- options: html === true ? {} : html,
20
- })
15
+ ? (urlInfo) => minifyHtml(urlInfo, html === true ? {} : html)
21
16
  : null;
22
17
  const svgMinifier = svg
23
- ? (urlInfo, context) =>
24
- minifyHtml({
25
- htmlUrlInfo: urlInfo,
26
- context,
27
- options: svg === true ? {} : svg,
28
- })
18
+ ? (urlInfo) => minifyHtml(urlInfo, svg === true ? {} : svg)
29
19
  : null;
30
20
  const cssMinifier = css
31
- ? (urlInfo, context) =>
32
- minifyCss({
33
- cssUrlInfo: urlInfo,
34
- context,
35
- options: css === true ? {} : css,
36
- })
21
+ ? (urlInfo) => minifyCss(urlInfo, css === true ? {} : css)
37
22
  : null;
38
23
  const jsClassicMinifier = js_classic
39
- ? (urlInfo, context) =>
40
- minifyJs({
41
- jsUrlInfo: urlInfo,
42
- context,
43
- options: js_classic === true ? {} : js_classic,
44
- })
24
+ ? (urlInfo) => minifyJs(urlInfo, js_classic === true ? {} : js_classic)
45
25
  : null;
46
26
  const jsModuleMinifier = js_module
47
- ? (urlInfo, context) =>
48
- minifyJs({
49
- jsUrlInfo: urlInfo,
50
- context,
51
- options: js_module === true ? {} : js_module,
52
- })
27
+ ? (urlInfo) => minifyJs(urlInfo, js_module === true ? {} : js_module)
53
28
  : null;
54
29
  const jsonMinifier = json
55
- ? (urlInfo, context) =>
56
- minifyJson({
57
- jsonUrlInfo: urlInfo,
58
- context,
59
- options: json === true ? {} : html,
60
- })
30
+ ? (urlInfo) => minifyJson(urlInfo, json === true ? {} : html)
61
31
  : null;
62
32
 
63
33
  return {
@@ -1,4 +1,4 @@
1
- export const minifyJson = ({ jsonUrlInfo }) => {
1
+ export const minifyJson = (jsonUrlInfo) => {
2
2
  const { content } = jsonUrlInfo;
3
3
  if (content.startsWith("{\n")) {
4
4
  const jsonWithoutWhitespaces = JSON.stringify(JSON.parse(content));