@node-minify/uglify-es 7.1.0 → 8.0.1-beta.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.d.ts +29 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +35 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +22 -6
- package/lib/uglify-es.js +0 -63
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MinifierOptions, Settings, Options } from '@node-minify/types';
|
|
2
|
+
|
|
3
|
+
/*!
|
|
4
|
+
* node-minify
|
|
5
|
+
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
6
|
+
* MIT Licensed
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface OptionsUglifyES extends Omit<Options, 'sourceMap'> {
|
|
10
|
+
sourceMap?: {
|
|
11
|
+
filename: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface SettingsUglifyES extends Omit<Settings, 'options'> {
|
|
15
|
+
options: OptionsUglifyES;
|
|
16
|
+
}
|
|
17
|
+
interface MinifierOptionsUglifyES extends Omit<MinifierOptions, 'settings'> {
|
|
18
|
+
settings: SettingsUglifyES;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Run uglifyES.
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} settings
|
|
24
|
+
* @param {String} content
|
|
25
|
+
* @param {Function} callback
|
|
26
|
+
*/
|
|
27
|
+
declare const minifyUglifyES: ({ settings, content, callback, index }: MinifierOptionsUglifyES) => any;
|
|
28
|
+
|
|
29
|
+
export { minifyUglifyES as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
|
|
25
|
+
// src/index.ts
|
|
26
|
+
var src_exports = {};
|
|
27
|
+
__export(src_exports, {
|
|
28
|
+
default: () => src_default
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(src_exports);
|
|
31
|
+
var import_uglify_es = __toESM(require("uglify-es"));
|
|
32
|
+
var import_utils = require("@node-minify/utils");
|
|
33
|
+
var minifyUglifyES = ({ settings, content, callback, index }) => {
|
|
34
|
+
let content2 = content || "";
|
|
35
|
+
if (settings && typeof settings.options.sourceMap === "object") {
|
|
36
|
+
content2 = { [settings.options.sourceMap.filename || ""]: content || "" };
|
|
37
|
+
}
|
|
38
|
+
const contentMinified = import_uglify_es.default.minify(content2, settings && settings.options);
|
|
39
|
+
if (contentMinified.error) {
|
|
40
|
+
if (callback) {
|
|
41
|
+
return callback(contentMinified.error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (contentMinified.map && settings && settings.options.sourceMap) {
|
|
45
|
+
import_utils.utils.writeFile({ file: `${settings.output}.map`, content: contentMinified.map, index });
|
|
46
|
+
}
|
|
47
|
+
if (settings && !settings.content) {
|
|
48
|
+
import_utils.utils.writeFile({ file: settings.output, content: contentMinified.code, index });
|
|
49
|
+
}
|
|
50
|
+
if (callback) {
|
|
51
|
+
return callback(null, contentMinified.code);
|
|
52
|
+
}
|
|
53
|
+
return contentMinified.code;
|
|
54
|
+
};
|
|
55
|
+
var src_default = minifyUglifyES;
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {});
|
|
58
|
+
/*!
|
|
59
|
+
* node-minify
|
|
60
|
+
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
61
|
+
* MIT Licensed
|
|
62
|
+
*/
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport uglifyES from 'uglify-es';\nimport { utils } from '@node-minify/utils';\nimport { MinifierOptions, Options, Settings, Dictionary } from '@node-minify/types';\n\ninterface OptionsUglifyES extends Omit<Options, 'sourceMap'> {\n sourceMap?: { filename: string };\n}\n\n// interface Options {\n// sourceMap?: { filename: string };\n// // _sourceMap?: { url: string } | boolean;\n// }\n\n// interface Settings {\n// options: Options;\n// content: string;\n// output: string;\n// }\n\ninterface SettingsUglifyES extends Omit<Settings, 'options'> {\n options: OptionsUglifyES;\n}\n\ninterface MinifierOptionsUglifyES extends Omit<MinifierOptions, 'settings'> {\n settings: SettingsUglifyES;\n}\n\n// interface MinifierOptions {\n// settings: Settings;\n// content: string /* | Dictionary<string> */;\n// callback: Function;\n// index: number;\n// }\n\n// interface Dictionary<T> {\n// [Key: string]: T;\n// }\n\n/**\n * Run uglifyES.\n *\n * @param {Object} settings\n * @param {String} content\n * @param {Function} callback\n */\nconst minifyUglifyES = ({ settings, content, callback, index }: MinifierOptionsUglifyES) => {\n let content2: string | Dictionary<string> = content || '';\n if (settings && typeof settings.options.sourceMap === 'object') {\n content2 = { [settings.options.sourceMap.filename || '']: content || '' };\n }\n const contentMinified = uglifyES.minify(content2, settings && settings.options);\n if (contentMinified.error) {\n if (callback) {\n return callback(contentMinified.error);\n }\n }\n if (contentMinified.map && settings && settings.options.sourceMap) {\n utils.writeFile({ file: `${settings.output}.map`, content: contentMinified.map, index });\n }\n if (settings && !settings.content) {\n utils.writeFile({ file: settings.output, content: contentMinified.code, index });\n }\n if (callback) {\n return callback(null, contentMinified.code);\n }\n return contentMinified.code;\n};\n\n/**\n * Expose `minifyUglifyES()`.\n */\nexport default minifyUglifyES;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,uBAAqB;AACrB,mBAAsB;AA4CtB,IAAM,iBAAiB,CAAC,EAAE,UAAU,SAAS,UAAU,MAAM,MAA+B;AAC1F,MAAI,WAAwC,WAAW;AACvD,MAAI,YAAY,OAAO,SAAS,QAAQ,cAAc,UAAU;AAC9D,eAAW,EAAE,CAAC,SAAS,QAAQ,UAAU,YAAY,KAAK,WAAW,GAAG;AAAA,EAC1E;AACA,QAAM,kBAAkB,iBAAAA,QAAS,OAAO,UAAU,YAAY,SAAS,OAAO;AAC9E,MAAI,gBAAgB,OAAO;AACzB,QAAI,UAAU;AACZ,aAAO,SAAS,gBAAgB,KAAK;AAAA,IACvC;AAAA,EACF;AACA,MAAI,gBAAgB,OAAO,YAAY,SAAS,QAAQ,WAAW;AACjE,uBAAM,UAAU,EAAE,MAAM,GAAG,SAAS,cAAc,SAAS,gBAAgB,KAAK,MAAM,CAAC;AAAA,EACzF;AACA,MAAI,YAAY,CAAC,SAAS,SAAS;AACjC,uBAAM,UAAU,EAAE,MAAM,SAAS,QAAQ,SAAS,gBAAgB,MAAM,MAAM,CAAC;AAAA,EACjF;AACA,MAAI,UAAU;AACZ,WAAO,SAAS,MAAM,gBAAgB,IAAI;AAAA,EAC5C;AACA,SAAO,gBAAgB;AACzB;AAKA,IAAO,cAAQ;","names":["uglifyES"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import uglifyES from "uglify-es";
|
|
3
|
+
import { utils } from "@node-minify/utils";
|
|
4
|
+
var minifyUglifyES = ({ settings, content, callback, index }) => {
|
|
5
|
+
let content2 = content || "";
|
|
6
|
+
if (settings && typeof settings.options.sourceMap === "object") {
|
|
7
|
+
content2 = { [settings.options.sourceMap.filename || ""]: content || "" };
|
|
8
|
+
}
|
|
9
|
+
const contentMinified = uglifyES.minify(content2, settings && settings.options);
|
|
10
|
+
if (contentMinified.error) {
|
|
11
|
+
if (callback) {
|
|
12
|
+
return callback(contentMinified.error);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (contentMinified.map && settings && settings.options.sourceMap) {
|
|
16
|
+
utils.writeFile({ file: `${settings.output}.map`, content: contentMinified.map, index });
|
|
17
|
+
}
|
|
18
|
+
if (settings && !settings.content) {
|
|
19
|
+
utils.writeFile({ file: settings.output, content: contentMinified.code, index });
|
|
20
|
+
}
|
|
21
|
+
if (callback) {
|
|
22
|
+
return callback(null, contentMinified.code);
|
|
23
|
+
}
|
|
24
|
+
return contentMinified.code;
|
|
25
|
+
};
|
|
26
|
+
var src_default = minifyUglifyES;
|
|
27
|
+
export {
|
|
28
|
+
src_default as default
|
|
29
|
+
};
|
|
30
|
+
/*!
|
|
31
|
+
* node-minify
|
|
32
|
+
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
33
|
+
* MIT Licensed
|
|
34
|
+
*/
|
|
35
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport uglifyES from 'uglify-es';\nimport { utils } from '@node-minify/utils';\nimport { MinifierOptions, Options, Settings, Dictionary } from '@node-minify/types';\n\ninterface OptionsUglifyES extends Omit<Options, 'sourceMap'> {\n sourceMap?: { filename: string };\n}\n\n// interface Options {\n// sourceMap?: { filename: string };\n// // _sourceMap?: { url: string } | boolean;\n// }\n\n// interface Settings {\n// options: Options;\n// content: string;\n// output: string;\n// }\n\ninterface SettingsUglifyES extends Omit<Settings, 'options'> {\n options: OptionsUglifyES;\n}\n\ninterface MinifierOptionsUglifyES extends Omit<MinifierOptions, 'settings'> {\n settings: SettingsUglifyES;\n}\n\n// interface MinifierOptions {\n// settings: Settings;\n// content: string /* | Dictionary<string> */;\n// callback: Function;\n// index: number;\n// }\n\n// interface Dictionary<T> {\n// [Key: string]: T;\n// }\n\n/**\n * Run uglifyES.\n *\n * @param {Object} settings\n * @param {String} content\n * @param {Function} callback\n */\nconst minifyUglifyES = ({ settings, content, callback, index }: MinifierOptionsUglifyES) => {\n let content2: string | Dictionary<string> = content || '';\n if (settings && typeof settings.options.sourceMap === 'object') {\n content2 = { [settings.options.sourceMap.filename || '']: content || '' };\n }\n const contentMinified = uglifyES.minify(content2, settings && settings.options);\n if (contentMinified.error) {\n if (callback) {\n return callback(contentMinified.error);\n }\n }\n if (contentMinified.map && settings && settings.options.sourceMap) {\n utils.writeFile({ file: `${settings.output}.map`, content: contentMinified.map, index });\n }\n if (settings && !settings.content) {\n utils.writeFile({ file: settings.output, content: contentMinified.code, index });\n }\n if (callback) {\n return callback(null, contentMinified.code);\n }\n return contentMinified.code;\n};\n\n/**\n * Expose `minifyUglifyES()`.\n */\nexport default minifyUglifyES;\n"],"mappings":";AASA,OAAO,cAAc;AACrB,SAAS,aAAa;AA4CtB,IAAM,iBAAiB,CAAC,EAAE,UAAU,SAAS,UAAU,MAAM,MAA+B;AAC1F,MAAI,WAAwC,WAAW;AACvD,MAAI,YAAY,OAAO,SAAS,QAAQ,cAAc,UAAU;AAC9D,eAAW,EAAE,CAAC,SAAS,QAAQ,UAAU,YAAY,KAAK,WAAW,GAAG;AAAA,EAC1E;AACA,QAAM,kBAAkB,SAAS,OAAO,UAAU,YAAY,SAAS,OAAO;AAC9E,MAAI,gBAAgB,OAAO;AACzB,QAAI,UAAU;AACZ,aAAO,SAAS,gBAAgB,KAAK;AAAA,IACvC;AAAA,EACF;AACA,MAAI,gBAAgB,OAAO,YAAY,SAAS,QAAQ,WAAW;AACjE,UAAM,UAAU,EAAE,MAAM,GAAG,SAAS,cAAc,SAAS,gBAAgB,KAAK,MAAM,CAAC;AAAA,EACzF;AACA,MAAI,YAAY,CAAC,SAAS,SAAS;AACjC,UAAM,UAAU,EAAE,MAAM,SAAS,QAAQ,SAAS,gBAAgB,MAAM,MAAM,CAAC;AAAA,EACjF;AACA,MAAI,UAAU;AACZ,WAAO,SAAS,MAAM,gBAAgB,IAAI;AAAA,EAC5C;AACA,SAAO,gBAAgB;AACzB;AAKA,IAAO,cAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-minify/uglify-es",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.1-beta.0",
|
|
4
4
|
"description": "uglify-es plugin for @node-minify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compressor",
|
|
@@ -11,16 +11,23 @@
|
|
|
11
11
|
"author": "Rodolphe Stoclin <srodolphe@gmail.com>",
|
|
12
12
|
"homepage": "https://github.com/srod/node-minify/tree/master/packages/uglify-es#readme",
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"main": "lib/uglify-es.js",
|
|
15
14
|
"engines": {
|
|
16
15
|
"node": ">=14.0.0"
|
|
17
16
|
},
|
|
18
17
|
"directories": {
|
|
19
|
-
"lib": "
|
|
18
|
+
"lib": "dist",
|
|
20
19
|
"test": "__tests__"
|
|
21
20
|
},
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"module": "./dist/index.mjs",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
"require": "./dist/index.js",
|
|
26
|
+
"import": "./dist/index.mjs",
|
|
27
|
+
"types": "./dist/index.d.ts"
|
|
28
|
+
},
|
|
22
29
|
"files": [
|
|
23
|
-
"
|
|
30
|
+
"dist/**/*"
|
|
24
31
|
],
|
|
25
32
|
"publishConfig": {
|
|
26
33
|
"access": "public"
|
|
@@ -32,9 +39,18 @@
|
|
|
32
39
|
"bugs": {
|
|
33
40
|
"url": "https://github.com/srod/node-minify/issues"
|
|
34
41
|
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"clean": "pnpm dlx rimraf dist",
|
|
44
|
+
"build": "npm run clean && tsup src/index.ts --format cjs,esm --dts --clean --sourcemap",
|
|
45
|
+
"prepublishOnly": "npm run build"
|
|
46
|
+
},
|
|
35
47
|
"dependencies": {
|
|
36
|
-
"@node-minify/utils": "
|
|
48
|
+
"@node-minify/utils": "8.0.1-beta.0",
|
|
37
49
|
"uglify-es": "3.3.9"
|
|
38
50
|
},
|
|
39
|
-
"
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@node-minify/types": "8.0.1-beta.0",
|
|
53
|
+
"@types/uglify-es": "^3.0.0"
|
|
54
|
+
},
|
|
55
|
+
"gitHead": "35a8a41ec86a11cbec05d8a7db9113475ece2cef"
|
|
40
56
|
}
|
package/lib/uglify-es.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _uglifyEs = _interopRequireDefault(require("uglify-es"));
|
|
4
|
-
var _utils = require("@node-minify/utils");
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
/*!
|
|
7
|
-
* node-minify
|
|
8
|
-
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
9
|
-
* MIT Licensed
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Module dependencies.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Run uglifyES.
|
|
18
|
-
*
|
|
19
|
-
* @param {Object} settings
|
|
20
|
-
* @param {String} content
|
|
21
|
-
* @param {Function} callback
|
|
22
|
-
*/
|
|
23
|
-
const minifyUglifyES = ({
|
|
24
|
-
settings,
|
|
25
|
-
content,
|
|
26
|
-
callback,
|
|
27
|
-
index
|
|
28
|
-
}) => {
|
|
29
|
-
if (settings.options.sourceMap) {
|
|
30
|
-
content = {
|
|
31
|
-
[settings.options.sourceMap.filename]: content
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
const contentMinified = _uglifyEs.default.minify(content, settings.options);
|
|
35
|
-
if (contentMinified.error) {
|
|
36
|
-
if (callback) {
|
|
37
|
-
return callback(contentMinified.error);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (contentMinified.map && settings.options.sourceMap) {
|
|
41
|
-
_utils.utils.writeFile({
|
|
42
|
-
file: `${settings.output}.map`,
|
|
43
|
-
content: contentMinified.map,
|
|
44
|
-
index
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
if (!settings.content) {
|
|
48
|
-
_utils.utils.writeFile({
|
|
49
|
-
file: settings.output,
|
|
50
|
-
content: contentMinified.code,
|
|
51
|
-
index
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
if (callback) {
|
|
55
|
-
return callback(null, contentMinified.code);
|
|
56
|
-
}
|
|
57
|
-
return contentMinified.code;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Expose `minifyUglifyES()`.
|
|
62
|
-
*/
|
|
63
|
-
module.exports = minifyUglifyES;
|