@node-minify/terser 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.
@@ -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 OptionsTerser extends Omit<Options, 'sourceMap'> {
10
+ sourceMap?: {
11
+ url: string;
12
+ };
13
+ }
14
+ interface SettingsTerser extends Omit<Settings, 'options'> {
15
+ options: OptionsTerser;
16
+ }
17
+ interface MinifierOptionsTerser extends Omit<MinifierOptions, 'settings'> {
18
+ settings: SettingsTerser;
19
+ }
20
+ /**
21
+ * Run terser.
22
+ *
23
+ * @param {Object} settings
24
+ * @param {String} content
25
+ * @param {Function} callback
26
+ */
27
+ declare const minifyTerser: ({ settings, content, callback, index }: MinifierOptionsTerser) => Promise<any>;
28
+
29
+ export { minifyTerser as default };
package/dist/index.js ADDED
@@ -0,0 +1,52 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.ts
20
+ var src_exports = {};
21
+ __export(src_exports, {
22
+ default: () => src_default
23
+ });
24
+ module.exports = __toCommonJS(src_exports);
25
+ var import_terser = require("terser");
26
+ var import_utils = require("@node-minify/utils");
27
+ var minifyTerser = async ({ settings, content, callback, index }) => {
28
+ try {
29
+ const contentMinified = await (0, import_terser.minify)(content || "", settings && settings.options);
30
+ if (contentMinified.map && settings && settings.options && typeof settings.options.sourceMap === "object" && typeof settings.options.sourceMap.url === "string") {
31
+ import_utils.utils.writeFile({ file: settings.options.sourceMap.url, content: contentMinified.map, index });
32
+ }
33
+ if (settings && !settings.content) {
34
+ import_utils.utils.writeFile({ file: settings.output, content: contentMinified.code, index });
35
+ }
36
+ if (callback) {
37
+ return callback(null, contentMinified.code);
38
+ }
39
+ return contentMinified.code;
40
+ } catch (error) {
41
+ return callback && callback(error);
42
+ }
43
+ };
44
+ var src_default = minifyTerser;
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {});
47
+ /*!
48
+ * node-minify
49
+ * Copyright(c) 2011-2022 Rodolphe Stoclin
50
+ * MIT Licensed
51
+ */
52
+ //# 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 { minify } from 'terser';\nimport { utils } from '@node-minify/utils';\nimport { MinifierOptions, Options, Settings } from '@node-minify/types';\n\ninterface OptionsTerser extends Omit<Options, 'sourceMap'> {\n sourceMap?: { url: string };\n}\n\ninterface SettingsTerser extends Omit<Settings, 'options'> {\n options: OptionsTerser;\n}\n\ninterface MinifierOptionsTerser extends Omit<MinifierOptions, 'settings'> {\n settings: SettingsTerser;\n}\n\n// interface Options {\n// sourceMap?: { url: string };\n// // _sourceMap?: { url: string } | boolean;\n// }\n\n// interface Settings {\n// options: Options;\n// content: string;\n// output: string;\n// }\n\n// interface MinifierOptions {\n// settings: Settings;\n// content: string;\n// callback: Function;\n// index: number;\n// }\n\n/**\n * Run terser.\n *\n * @param {Object} settings\n * @param {String} content\n * @param {Function} callback\n */\nconst minifyTerser = async ({ settings, content, callback, index }: MinifierOptionsTerser) => {\n try {\n const contentMinified = await minify(content || '', settings && settings.options);\n if (\n contentMinified.map &&\n settings &&\n settings.options &&\n typeof settings.options.sourceMap === 'object' &&\n typeof settings.options.sourceMap.url === 'string'\n ) {\n utils.writeFile({ file: settings.options.sourceMap.url, 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 } catch (error) {\n return callback && callback(error);\n }\n};\n\n/**\n * Expose `minifyTerser()`.\n */\nexport default minifyTerser;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,oBAAuB;AACvB,mBAAsB;AAwCtB,IAAM,eAAe,OAAO,EAAE,UAAU,SAAS,UAAU,MAAM,MAA6B;AAC5F,MAAI;AACF,UAAM,kBAAkB,UAAM,sBAAO,WAAW,IAAI,YAAY,SAAS,OAAO;AAChF,QACE,gBAAgB,OAChB,YACA,SAAS,WACT,OAAO,SAAS,QAAQ,cAAc,YACtC,OAAO,SAAS,QAAQ,UAAU,QAAQ,UAC1C;AACA,yBAAM,UAAU,EAAE,MAAM,SAAS,QAAQ,UAAU,KAAK,SAAS,gBAAgB,KAAK,MAAM,CAAC;AAAA,IAC/F;AACA,QAAI,YAAY,CAAC,SAAS,SAAS;AACjC,yBAAM,UAAU,EAAE,MAAM,SAAS,QAAQ,SAAS,gBAAgB,MAAM,MAAM,CAAC;AAAA,IACjF;AACA,QAAI,UAAU;AACZ,aAAO,SAAS,MAAM,gBAAgB,IAAI;AAAA,IAC5C;AACA,WAAO,gBAAgB;AAAA,EACzB,SAAS,OAAP;AACA,WAAO,YAAY,SAAS,KAAK;AAAA,EACnC;AACF;AAKA,IAAO,cAAQ;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,30 @@
1
+ // src/index.ts
2
+ import { minify } from "terser";
3
+ import { utils } from "@node-minify/utils";
4
+ var minifyTerser = async ({ settings, content, callback, index }) => {
5
+ try {
6
+ const contentMinified = await minify(content || "", settings && settings.options);
7
+ if (contentMinified.map && settings && settings.options && typeof settings.options.sourceMap === "object" && typeof settings.options.sourceMap.url === "string") {
8
+ utils.writeFile({ file: settings.options.sourceMap.url, content: contentMinified.map, index });
9
+ }
10
+ if (settings && !settings.content) {
11
+ utils.writeFile({ file: settings.output, content: contentMinified.code, index });
12
+ }
13
+ if (callback) {
14
+ return callback(null, contentMinified.code);
15
+ }
16
+ return contentMinified.code;
17
+ } catch (error) {
18
+ return callback && callback(error);
19
+ }
20
+ };
21
+ var src_default = minifyTerser;
22
+ export {
23
+ src_default as default
24
+ };
25
+ /*!
26
+ * node-minify
27
+ * Copyright(c) 2011-2022 Rodolphe Stoclin
28
+ * MIT Licensed
29
+ */
30
+ //# 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 { minify } from 'terser';\nimport { utils } from '@node-minify/utils';\nimport { MinifierOptions, Options, Settings } from '@node-minify/types';\n\ninterface OptionsTerser extends Omit<Options, 'sourceMap'> {\n sourceMap?: { url: string };\n}\n\ninterface SettingsTerser extends Omit<Settings, 'options'> {\n options: OptionsTerser;\n}\n\ninterface MinifierOptionsTerser extends Omit<MinifierOptions, 'settings'> {\n settings: SettingsTerser;\n}\n\n// interface Options {\n// sourceMap?: { url: string };\n// // _sourceMap?: { url: string } | boolean;\n// }\n\n// interface Settings {\n// options: Options;\n// content: string;\n// output: string;\n// }\n\n// interface MinifierOptions {\n// settings: Settings;\n// content: string;\n// callback: Function;\n// index: number;\n// }\n\n/**\n * Run terser.\n *\n * @param {Object} settings\n * @param {String} content\n * @param {Function} callback\n */\nconst minifyTerser = async ({ settings, content, callback, index }: MinifierOptionsTerser) => {\n try {\n const contentMinified = await minify(content || '', settings && settings.options);\n if (\n contentMinified.map &&\n settings &&\n settings.options &&\n typeof settings.options.sourceMap === 'object' &&\n typeof settings.options.sourceMap.url === 'string'\n ) {\n utils.writeFile({ file: settings.options.sourceMap.url, 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 } catch (error) {\n return callback && callback(error);\n }\n};\n\n/**\n * Expose `minifyTerser()`.\n */\nexport default minifyTerser;\n"],"mappings":";AASA,SAAS,cAAc;AACvB,SAAS,aAAa;AAwCtB,IAAM,eAAe,OAAO,EAAE,UAAU,SAAS,UAAU,MAAM,MAA6B;AAC5F,MAAI;AACF,UAAM,kBAAkB,MAAM,OAAO,WAAW,IAAI,YAAY,SAAS,OAAO;AAChF,QACE,gBAAgB,OAChB,YACA,SAAS,WACT,OAAO,SAAS,QAAQ,cAAc,YACtC,OAAO,SAAS,QAAQ,UAAU,QAAQ,UAC1C;AACA,YAAM,UAAU,EAAE,MAAM,SAAS,QAAQ,UAAU,KAAK,SAAS,gBAAgB,KAAK,MAAM,CAAC;AAAA,IAC/F;AACA,QAAI,YAAY,CAAC,SAAS,SAAS;AACjC,YAAM,UAAU,EAAE,MAAM,SAAS,QAAQ,SAAS,gBAAgB,MAAM,MAAM,CAAC;AAAA,IACjF;AACA,QAAI,UAAU;AACZ,aAAO,SAAS,MAAM,gBAAgB,IAAI;AAAA,IAC5C;AACA,WAAO,gBAAgB;AAAA,EACzB,SAAS,OAAP;AACA,WAAO,YAAY,SAAS,KAAK;AAAA,EACnC;AACF;AAKA,IAAO,cAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-minify/terser",
3
- "version": "7.1.0",
3
+ "version": "8.0.1-beta.0",
4
4
  "description": "terser 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/terser#readme",
13
13
  "license": "MIT",
14
- "main": "lib/terser.js",
15
14
  "engines": {
16
15
  "node": ">=14.0.0"
17
16
  },
18
17
  "directories": {
19
- "lib": "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
- "lib"
30
+ "dist/**/*"
24
31
  ],
25
32
  "publishConfig": {
26
33
  "access": "public"
@@ -32,9 +39,17 @@
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": "^7.1.0",
37
- "terser": "5.15.1"
48
+ "@node-minify/utils": "8.0.1-beta.0",
49
+ "terser": "5.16.1"
50
+ },
51
+ "devDependencies": {
52
+ "@node-minify/types": "8.0.1-beta.0"
38
53
  },
39
- "gitHead": "94cef2d5d653c3bddc3e603b4e25c135b0b6f4b3"
54
+ "gitHead": "35a8a41ec86a11cbec05d8a7db9113475ece2cef"
40
55
  }
package/lib/terser.js DELETED
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- var _terser = _interopRequireDefault(require("terser"));
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 terser.
18
- *
19
- * @param {Object} settings
20
- * @param {String} content
21
- * @param {Function} callback
22
- */
23
- const minifyTerser = async ({
24
- settings,
25
- content,
26
- callback,
27
- index
28
- }) => {
29
- try {
30
- const contentMinified = await _terser.default.minify(content, settings.options);
31
- if (contentMinified.error) {
32
- if (callback) {
33
- return callback(contentMinified.error);
34
- }
35
- }
36
- if (contentMinified.map && settings.options.sourceMap) {
37
- _utils.utils.writeFile({
38
- file: settings.options.sourceMap.url,
39
- content: contentMinified.map,
40
- index
41
- });
42
- }
43
- if (!settings.content) {
44
- _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
-
59
- /**
60
- * Expose `minifyTerser()`.
61
- */
62
- module.exports = minifyTerser;