@node-minify/terser 9.0.0 → 10.0.0-next.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/dist/index.cjs +71 -0
- package/dist/{index.d.mts → index.d.cts} +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +9 -9
- package/package.json +20 -19
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -51
- package/dist/index.mjs.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
default: () => src_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
var import_utils = require("@node-minify/utils");
|
|
27
|
+
var import_terser = require("terser");
|
|
28
|
+
var minifyTerser = async ({
|
|
29
|
+
settings,
|
|
30
|
+
content,
|
|
31
|
+
callback,
|
|
32
|
+
index
|
|
33
|
+
}) => {
|
|
34
|
+
try {
|
|
35
|
+
const contentMinified = await (0, import_terser.minify)(content ?? "", settings?.options);
|
|
36
|
+
if (contentMinified.map && typeof settings?.options?.sourceMap?.url === "string") {
|
|
37
|
+
import_utils.utils.writeFile({
|
|
38
|
+
file: settings.options.sourceMap.url,
|
|
39
|
+
content: contentMinified.map,
|
|
40
|
+
index
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (settings && !settings.content && settings.output) {
|
|
44
|
+
import_utils.utils.writeFile({
|
|
45
|
+
file: settings.output,
|
|
46
|
+
content: contentMinified.code,
|
|
47
|
+
index
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (callback) {
|
|
51
|
+
return callback(null, contentMinified.code);
|
|
52
|
+
}
|
|
53
|
+
return contentMinified.code;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return callback?.(error);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
minifyTerser.default = minifyTerser;
|
|
59
|
+
var src_default = minifyTerser;
|
|
60
|
+
/*!
|
|
61
|
+
* node-minify
|
|
62
|
+
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
63
|
+
* MIT Licensed
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
// fix-cjs-exports
|
|
67
|
+
if (module.exports.default) {
|
|
68
|
+
Object.assign(module.exports.default, module.exports);
|
|
69
|
+
module.exports = module.exports.default;
|
|
70
|
+
delete module.exports.default;
|
|
71
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
1
|
// src/index.ts
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { utils } from "@node-minify/utils";
|
|
3
|
+
import { minify } from "terser";
|
|
6
4
|
var minifyTerser = async ({
|
|
7
5
|
settings,
|
|
8
6
|
content,
|
|
@@ -10,16 +8,16 @@ var minifyTerser = async ({
|
|
|
10
8
|
index
|
|
11
9
|
}) => {
|
|
12
10
|
try {
|
|
13
|
-
const contentMinified = await
|
|
11
|
+
const contentMinified = await minify(content ?? "", settings?.options);
|
|
14
12
|
if (contentMinified.map && typeof settings?.options?.sourceMap?.url === "string") {
|
|
15
|
-
|
|
13
|
+
utils.writeFile({
|
|
16
14
|
file: settings.options.sourceMap.url,
|
|
17
15
|
content: contentMinified.map,
|
|
18
16
|
index
|
|
19
17
|
});
|
|
20
18
|
}
|
|
21
19
|
if (settings && !settings.content && settings.output) {
|
|
22
|
-
|
|
20
|
+
utils.writeFile({
|
|
23
21
|
file: settings.output,
|
|
24
22
|
content: contentMinified.code,
|
|
25
23
|
index
|
|
@@ -34,10 +32,12 @@ var minifyTerser = async ({
|
|
|
34
32
|
}
|
|
35
33
|
};
|
|
36
34
|
minifyTerser.default = minifyTerser;
|
|
37
|
-
|
|
35
|
+
var src_default = minifyTerser;
|
|
36
|
+
export {
|
|
37
|
+
src_default as default
|
|
38
|
+
};
|
|
38
39
|
/*!
|
|
39
40
|
* node-minify
|
|
40
41
|
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
41
42
|
* MIT Licensed
|
|
42
43
|
*/
|
|
43
|
-
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-minify/terser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0-next.0",
|
|
4
4
|
"description": "terser plugin for @node-minify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compressor",
|
|
@@ -9,23 +9,22 @@
|
|
|
9
9
|
"terser"
|
|
10
10
|
],
|
|
11
11
|
"author": "Rodolphe Stoclin <srodolphe@gmail.com>",
|
|
12
|
-
"homepage": "https://github.com/srod/node-minify/tree/
|
|
12
|
+
"homepage": "https://github.com/srod/node-minify/tree/main/packages/terser#readme",
|
|
13
13
|
"license": "MIT",
|
|
14
|
+
"type": "module",
|
|
14
15
|
"engines": {
|
|
15
|
-
"node": ">=
|
|
16
|
+
"node": ">=22.0.0"
|
|
16
17
|
},
|
|
17
18
|
"directories": {
|
|
18
19
|
"lib": "dist",
|
|
19
20
|
"test": "__tests__"
|
|
20
21
|
},
|
|
21
|
-
"main": "./dist/index.
|
|
22
|
-
"module": "./dist/index.mjs",
|
|
23
|
-
"types": "./dist/index.d.ts",
|
|
22
|
+
"main": "./dist/index.cjs",
|
|
24
23
|
"exports": {
|
|
24
|
+
"./package.json": "./package.json",
|
|
25
25
|
".": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"require": "./dist/index.cjs"
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"default": "./dist/index.cjs"
|
|
29
28
|
}
|
|
30
29
|
},
|
|
31
30
|
"files": [
|
|
@@ -41,19 +40,21 @@
|
|
|
41
40
|
"bugs": {
|
|
42
41
|
"url": "https://github.com/srod/node-minify/issues"
|
|
43
42
|
},
|
|
44
|
-
"dependencies": {
|
|
45
|
-
"terser": "5.36.0",
|
|
46
|
-
"@node-minify/utils": "9.0.0"
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@node-minify/types": "9.0.0"
|
|
50
|
-
},
|
|
51
43
|
"scripts": {
|
|
52
|
-
"
|
|
53
|
-
"
|
|
44
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean && bunx fix-tsup-cjs",
|
|
45
|
+
"check-exports": "attw --pack .",
|
|
46
|
+
"format:check": "biome check .",
|
|
54
47
|
"lint": "biome lint .",
|
|
48
|
+
"prepublishOnly": "bun run build",
|
|
55
49
|
"test": "vitest run",
|
|
56
50
|
"test:ci": "vitest run --coverage",
|
|
57
51
|
"test:watch": "vitest"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@node-minify/utils": "workspace:*",
|
|
55
|
+
"terser": "5.36.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@node-minify/types": "workspace:*"
|
|
58
59
|
}
|
|
59
|
-
}
|
|
60
|
+
}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { MinifierOptions } from \"@node-minify/types\";\nimport { utils } from \"@node-minify/utils\";\n// @ts-expect-error moduleResolution:nodenext issue 54523\nimport { minify } from \"terser\";\n\ntype OptionsTerser = {\n sourceMap?: { url: string };\n};\n\ntype SettingsTerser = {\n options: OptionsTerser;\n};\n\ntype MinifierOptionsTerser = {\n settings: SettingsTerser;\n};\n\n/**\n * Run terser.\n * @param settings Terser options\n * @param content Content to minify\n * @param callback Callback\n * @param index Index of current file in array\n * @returns Minified content\n */\nconst minifyTerser = async ({\n settings,\n content,\n callback,\n index,\n}: MinifierOptions & MinifierOptionsTerser) => {\n try {\n const contentMinified = await minify(content ?? \"\", settings?.options);\n if (\n contentMinified.map &&\n typeof settings?.options?.sourceMap?.url === \"string\"\n ) {\n utils.writeFile({\n file: settings.options.sourceMap.url,\n content: contentMinified.map,\n index,\n });\n }\n if (settings && !settings.content && settings.output) {\n utils.writeFile({\n file: settings.output,\n content: contentMinified.code,\n index,\n });\n }\n if (callback) {\n return callback(null, contentMinified.code);\n }\n return contentMinified.code;\n } catch (error) {\n return callback?.(error);\n }\n};\n\n/**\n * Expose `minifyTerser()`.\n */\nminifyTerser.default = minifyTerser;\nexport = minifyTerser;\n"],"mappings":";;;AAUA,mBAAsB;AAEtB,oBAAuB;AAsBvB,IAAM,eAAe,OAAO;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,MAA+C;AAC3C,MAAI;AACA,UAAM,kBAAkB,UAAM,sBAAO,WAAW,IAAI,UAAU,OAAO;AACrE,QACI,gBAAgB,OAChB,OAAO,UAAU,SAAS,WAAW,QAAQ,UAC/C;AACE,yBAAM,UAAU;AAAA,QACZ,MAAM,SAAS,QAAQ,UAAU;AAAA,QACjC,SAAS,gBAAgB;AAAA,QACzB;AAAA,MACJ,CAAC;AAAA,IACL;AACA,QAAI,YAAY,CAAC,SAAS,WAAW,SAAS,QAAQ;AAClD,yBAAM,UAAU;AAAA,QACZ,MAAM,SAAS;AAAA,QACf,SAAS,gBAAgB;AAAA,QACzB;AAAA,MACJ,CAAC;AAAA,IACL;AACA,QAAI,UAAU;AACV,aAAO,SAAS,MAAM,gBAAgB,IAAI;AAAA,IAC9C;AACA,WAAO,gBAAgB;AAAA,EAC3B,SAAS,OAAO;AACZ,WAAO,WAAW,KAAK;AAAA,EAC3B;AACJ;AAKA,aAAa,UAAU;AACvB,iBAAS;","names":[]}
|
package/dist/index.mjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
// src/index.ts
|
|
7
|
-
import { utils } from "@node-minify/utils";
|
|
8
|
-
import { minify } from "terser";
|
|
9
|
-
var require_src = __commonJS({
|
|
10
|
-
"src/index.ts"(exports, module) {
|
|
11
|
-
var minifyTerser = async ({
|
|
12
|
-
settings,
|
|
13
|
-
content,
|
|
14
|
-
callback,
|
|
15
|
-
index
|
|
16
|
-
}) => {
|
|
17
|
-
try {
|
|
18
|
-
const contentMinified = await minify(content ?? "", settings?.options);
|
|
19
|
-
if (contentMinified.map && typeof settings?.options?.sourceMap?.url === "string") {
|
|
20
|
-
utils.writeFile({
|
|
21
|
-
file: settings.options.sourceMap.url,
|
|
22
|
-
content: contentMinified.map,
|
|
23
|
-
index
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
if (settings && !settings.content && settings.output) {
|
|
27
|
-
utils.writeFile({
|
|
28
|
-
file: settings.output,
|
|
29
|
-
content: contentMinified.code,
|
|
30
|
-
index
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
if (callback) {
|
|
34
|
-
return callback(null, contentMinified.code);
|
|
35
|
-
}
|
|
36
|
-
return contentMinified.code;
|
|
37
|
-
} catch (error) {
|
|
38
|
-
return callback?.(error);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
minifyTerser.default = minifyTerser;
|
|
42
|
-
module.exports = minifyTerser;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
export default require_src();
|
|
46
|
-
/*!
|
|
47
|
-
* node-minify
|
|
48
|
-
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
49
|
-
* MIT Licensed
|
|
50
|
-
*/
|
|
51
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { MinifierOptions } from \"@node-minify/types\";\nimport { utils } from \"@node-minify/utils\";\n// @ts-expect-error moduleResolution:nodenext issue 54523\nimport { minify } from \"terser\";\n\ntype OptionsTerser = {\n sourceMap?: { url: string };\n};\n\ntype SettingsTerser = {\n options: OptionsTerser;\n};\n\ntype MinifierOptionsTerser = {\n settings: SettingsTerser;\n};\n\n/**\n * Run terser.\n * @param settings Terser options\n * @param content Content to minify\n * @param callback Callback\n * @param index Index of current file in array\n * @returns Minified content\n */\nconst minifyTerser = async ({\n settings,\n content,\n callback,\n index,\n}: MinifierOptions & MinifierOptionsTerser) => {\n try {\n const contentMinified = await minify(content ?? \"\", settings?.options);\n if (\n contentMinified.map &&\n typeof settings?.options?.sourceMap?.url === \"string\"\n ) {\n utils.writeFile({\n file: settings.options.sourceMap.url,\n content: contentMinified.map,\n index,\n });\n }\n if (settings && !settings.content && settings.output) {\n utils.writeFile({\n file: settings.output,\n content: contentMinified.code,\n index,\n });\n }\n if (callback) {\n return callback(null, contentMinified.code);\n }\n return contentMinified.code;\n } catch (error) {\n return callback?.(error);\n }\n};\n\n/**\n * Expose `minifyTerser()`.\n */\nminifyTerser.default = minifyTerser;\nexport = minifyTerser;\n"],"mappings":";;;;;;AAUA,SAAS,aAAa;AAEtB,SAAS,cAAc;AAZvB;AAAA;AAkCA,QAAM,eAAe,OAAO;AAAA,MACxB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ,MAA+C;AAC3C,UAAI;AACA,cAAM,kBAAkB,MAAM,OAAO,WAAW,IAAI,UAAU,OAAO;AACrE,YACI,gBAAgB,OAChB,OAAO,UAAU,SAAS,WAAW,QAAQ,UAC/C;AACE,gBAAM,UAAU;AAAA,YACZ,MAAM,SAAS,QAAQ,UAAU;AAAA,YACjC,SAAS,gBAAgB;AAAA,YACzB;AAAA,UACJ,CAAC;AAAA,QACL;AACA,YAAI,YAAY,CAAC,SAAS,WAAW,SAAS,QAAQ;AAClD,gBAAM,UAAU;AAAA,YACZ,MAAM,SAAS;AAAA,YACf,SAAS,gBAAgB;AAAA,YACzB;AAAA,UACJ,CAAC;AAAA,QACL;AACA,YAAI,UAAU;AACV,iBAAO,SAAS,MAAM,gBAAgB,IAAI;AAAA,QAC9C;AACA,eAAO,gBAAgB;AAAA,MAC3B,SAAS,OAAO;AACZ,eAAO,WAAW,KAAK;AAAA,MAC3B;AAAA,IACJ;AAKA,iBAAa,UAAU;AACvB,qBAAS;AAAA;AAAA;","names":[]}
|