@node-minify/babel-minify 9.0.1 → 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 ADDED
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ default: () => src_default
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+ var import_utils = require("@node-minify/utils");
37
+ var import_babel_core = require("babel-core");
38
+ var import_babel_preset_minify = __toESM(require("babel-preset-minify"), 1);
39
+ var minifyBabel = ({
40
+ settings,
41
+ content,
42
+ callback,
43
+ index
44
+ }) => {
45
+ let babelOptions = {
46
+ presets: []
47
+ };
48
+ if (settings?.options?.babelrc) {
49
+ babelOptions = JSON.parse(import_utils.utils.readFile(settings.options.babelrc));
50
+ }
51
+ if (settings?.options?.presets) {
52
+ const babelrcPresets = babelOptions.presets || [];
53
+ babelOptions.presets = babelrcPresets.concat(
54
+ Array.isArray(settings.options.presets) ? settings.options.presets : []
55
+ );
56
+ }
57
+ if (babelOptions.presets.indexOf("minify") === -1) {
58
+ babelOptions.presets = babelOptions.presets.concat([import_babel_preset_minify.default]);
59
+ }
60
+ const contentMinified = (0, import_babel_core.transform)(content ?? "", babelOptions);
61
+ if (settings && !settings.content && settings.output) {
62
+ settings.output && import_utils.utils.writeFile({
63
+ file: settings.output,
64
+ content: contentMinified.code,
65
+ index
66
+ });
67
+ }
68
+ if (callback) {
69
+ return callback(null, contentMinified.code);
70
+ }
71
+ return contentMinified.code;
72
+ };
73
+ minifyBabel.default = minifyBabel;
74
+ var src_default = minifyBabel;
75
+ /*!
76
+ * node-minify
77
+ * Copyright(c) 2011-2024 Rodolphe Stoclin
78
+ * MIT Licensed
79
+ */
80
+
81
+ // fix-cjs-exports
82
+ if (module.exports.default) {
83
+ Object.assign(module.exports.default, module.exports);
84
+ module.exports = module.exports.default;
85
+ delete module.exports.default;
86
+ }
@@ -21,3 +21,4 @@ declare const minifyBabel: {
21
21
  };
22
22
 
23
23
  export { minifyBabel as default };
24
+ export = minifyBabel
package/dist/index.d.ts CHANGED
@@ -21,3 +21,4 @@ declare const minifyBabel: {
21
21
  };
22
22
 
23
23
  export { minifyBabel as default };
24
+ export = minifyBabel
package/dist/index.js CHANGED
@@ -1,31 +1,7 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
-
25
1
  // src/index.ts
26
- var import_utils = require("@node-minify/utils");
27
- var import_babel_core = require("babel-core");
28
- var import_babel_preset_minify = __toESM(require("babel-preset-minify"));
2
+ import { utils } from "@node-minify/utils";
3
+ import { transform } from "babel-core";
4
+ import minify from "babel-preset-minify";
29
5
  var minifyBabel = ({
30
6
  settings,
31
7
  content,
@@ -36,7 +12,7 @@ var minifyBabel = ({
36
12
  presets: []
37
13
  };
38
14
  if (settings?.options?.babelrc) {
39
- babelOptions = JSON.parse(import_utils.utils.readFile(settings.options.babelrc));
15
+ babelOptions = JSON.parse(utils.readFile(settings.options.babelrc));
40
16
  }
41
17
  if (settings?.options?.presets) {
42
18
  const babelrcPresets = babelOptions.presets || [];
@@ -45,11 +21,11 @@ var minifyBabel = ({
45
21
  );
46
22
  }
47
23
  if (babelOptions.presets.indexOf("minify") === -1) {
48
- babelOptions.presets = babelOptions.presets.concat([import_babel_preset_minify.default]);
24
+ babelOptions.presets = babelOptions.presets.concat([minify]);
49
25
  }
50
- const contentMinified = (0, import_babel_core.transform)(content ?? "", babelOptions);
26
+ const contentMinified = transform(content ?? "", babelOptions);
51
27
  if (settings && !settings.content && settings.output) {
52
- settings.output && import_utils.utils.writeFile({
28
+ settings.output && utils.writeFile({
53
29
  file: settings.output,
54
30
  content: contentMinified.code,
55
31
  index
@@ -61,10 +37,12 @@ var minifyBabel = ({
61
37
  return contentMinified.code;
62
38
  };
63
39
  minifyBabel.default = minifyBabel;
64
- module.exports = minifyBabel;
40
+ var src_default = minifyBabel;
41
+ export {
42
+ src_default as default
43
+ };
65
44
  /*!
66
45
  * node-minify
67
46
  * Copyright(c) 2011-2024 Rodolphe Stoclin
68
47
  * MIT Licensed
69
48
  */
70
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-minify/babel-minify",
3
- "version": "9.0.1",
3
+ "version": "10.0.0-next.0",
4
4
  "description": "babel-minify plugin for @node-minify",
5
5
  "keywords": [
6
6
  "compressor",
@@ -9,23 +9,22 @@
9
9
  "babel-minify"
10
10
  ],
11
11
  "author": "Rodolphe Stoclin <srodolphe@gmail.com>",
12
- "homepage": "https://github.com/srod/node-minify/tree/master/packages/babel-minify#readme",
12
+ "homepage": "https://github.com/srod/node-minify/tree/main/packages/babel-minify#readme",
13
13
  "license": "MIT",
14
+ "type": "module",
14
15
  "engines": {
15
- "node": ">=18.0.0"
16
+ "node": ">=22.0.0"
16
17
  },
17
18
  "directories": {
18
19
  "lib": "dist",
19
20
  "test": "__tests__"
20
21
  },
21
- "main": "./dist/index.js",
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
- "types": "./dist/index.d.ts",
27
- "import": "./dist/index.mjs",
28
- "require": "./dist/index.js"
26
+ "import": "./dist/index.js",
27
+ "default": "./dist/index.cjs"
29
28
  }
30
29
  },
31
30
  "files": [
@@ -41,22 +40,24 @@
41
40
  "bugs": {
42
41
  "url": "https://github.com/srod/node-minify/issues"
43
42
  },
44
- "dependencies": {
45
- "babel-core": "6.26.3",
46
- "babel-preset-minify": "0.5.2",
47
- "@node-minify/utils": "9.0.1"
48
- },
49
- "devDependencies": {
50
- "@types/babel-core": "^6.25.7",
51
- "babel-preset-env": "1.7.0",
52
- "@node-minify/types": "9.0.0"
53
- },
54
43
  "scripts": {
55
- "clean": "pnpm dlx rimraf dist",
56
- "build": "pnpm clean && tsup src/index.ts --format cjs,esm --dts --clean --sourcemap",
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 .",
57
47
  "lint": "biome lint .",
48
+ "prepublishOnly": "bun run build",
58
49
  "test": "vitest run",
59
50
  "test:ci": "vitest run --coverage",
60
51
  "test:watch": "vitest"
52
+ },
53
+ "dependencies": {
54
+ "@node-minify/utils": "workspace:*",
55
+ "babel-core": "6.26.3",
56
+ "babel-preset-minify": "0.5.2"
57
+ },
58
+ "devDependencies": {
59
+ "@node-minify/types": "workspace:*",
60
+ "@types/babel-core": "^6.25.10",
61
+ "babel-preset-env": "1.7.0"
61
62
  }
62
- }
63
+ }
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\";\nimport { transform } from \"babel-core\";\nimport minify from \"babel-preset-minify\";\n\ntype BabelOptions = {\n presets: string[];\n};\n\ntype OptionsBabel = {\n babelrc?: string;\n};\n\ntype SettingsBabel = {\n options: OptionsBabel;\n};\n\ntype MinifierOptionsBabel = {\n settings: SettingsBabel;\n};\n\n/**\n * Run babel-minify.\n * @param settings Babel-minify 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 minifyBabel = ({\n settings,\n content,\n callback,\n index,\n}: MinifierOptions & MinifierOptionsBabel) => {\n let babelOptions: BabelOptions = {\n presets: [],\n };\n\n if (settings?.options?.babelrc) {\n babelOptions = JSON.parse(utils.readFile(settings.options.babelrc));\n }\n\n if (settings?.options?.presets) {\n const babelrcPresets = babelOptions.presets || [];\n babelOptions.presets = babelrcPresets.concat(\n Array.isArray(settings.options.presets)\n ? settings.options.presets\n : []\n );\n }\n\n if (babelOptions.presets.indexOf(\"minify\") === -1) {\n babelOptions.presets = babelOptions.presets.concat([minify]);\n }\n\n const contentMinified = transform(content ?? \"\", babelOptions);\n if (settings && !settings.content && settings.output) {\n 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};\n\n/**\n * Expose `minifyBabel()`.\n */\nminifyBabel.default = minifyBabel;\nexport = minifyBabel;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAUA,mBAAsB;AACtB,wBAA0B;AAC1B,iCAAmB;AA0BnB,IAAM,cAAc,CAAC;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,MAA8C;AAC1C,MAAI,eAA6B;AAAA,IAC7B,SAAS,CAAC;AAAA,EACd;AAEA,MAAI,UAAU,SAAS,SAAS;AAC5B,mBAAe,KAAK,MAAM,mBAAM,SAAS,SAAS,QAAQ,OAAO,CAAC;AAAA,EACtE;AAEA,MAAI,UAAU,SAAS,SAAS;AAC5B,UAAM,iBAAiB,aAAa,WAAW,CAAC;AAChD,iBAAa,UAAU,eAAe;AAAA,MAClC,MAAM,QAAQ,SAAS,QAAQ,OAAO,IAChC,SAAS,QAAQ,UACjB,CAAC;AAAA,IACX;AAAA,EACJ;AAEA,MAAI,aAAa,QAAQ,QAAQ,QAAQ,MAAM,IAAI;AAC/C,iBAAa,UAAU,aAAa,QAAQ,OAAO,CAAC,2BAAAA,OAAM,CAAC;AAAA,EAC/D;AAEA,QAAM,sBAAkB,6BAAU,WAAW,IAAI,YAAY;AAC7D,MAAI,YAAY,CAAC,SAAS,WAAW,SAAS,QAAQ;AAClD,aAAS,UACL,mBAAM,UAAU;AAAA,MACZ,MAAM,SAAS;AAAA,MACf,SAAS,gBAAgB;AAAA,MACzB;AAAA,IACJ,CAAC;AAAA,EACT;AACA,MAAI,UAAU;AACV,WAAO,SAAS,MAAM,gBAAgB,IAAI;AAAA,EAC9C;AACA,SAAO,gBAAgB;AAC3B;AAKA,YAAY,UAAU;AACtB,iBAAS;","names":["minify"]}
package/dist/index.mjs DELETED
@@ -1,56 +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 { transform } from "babel-core";
9
- import minify from "babel-preset-minify";
10
- var require_src = __commonJS({
11
- "src/index.ts"(exports, module) {
12
- var minifyBabel = ({
13
- settings,
14
- content,
15
- callback,
16
- index
17
- }) => {
18
- let babelOptions = {
19
- presets: []
20
- };
21
- if (settings?.options?.babelrc) {
22
- babelOptions = JSON.parse(utils.readFile(settings.options.babelrc));
23
- }
24
- if (settings?.options?.presets) {
25
- const babelrcPresets = babelOptions.presets || [];
26
- babelOptions.presets = babelrcPresets.concat(
27
- Array.isArray(settings.options.presets) ? settings.options.presets : []
28
- );
29
- }
30
- if (babelOptions.presets.indexOf("minify") === -1) {
31
- babelOptions.presets = babelOptions.presets.concat([minify]);
32
- }
33
- const contentMinified = transform(content ?? "", babelOptions);
34
- if (settings && !settings.content && settings.output) {
35
- settings.output && utils.writeFile({
36
- file: settings.output,
37
- content: contentMinified.code,
38
- index
39
- });
40
- }
41
- if (callback) {
42
- return callback(null, contentMinified.code);
43
- }
44
- return contentMinified.code;
45
- };
46
- minifyBabel.default = minifyBabel;
47
- module.exports = minifyBabel;
48
- }
49
- });
50
- export default require_src();
51
- /*!
52
- * node-minify
53
- * Copyright(c) 2011-2024 Rodolphe Stoclin
54
- * MIT Licensed
55
- */
56
- //# sourceMappingURL=index.mjs.map
@@ -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\";\nimport { transform } from \"babel-core\";\nimport minify from \"babel-preset-minify\";\n\ntype BabelOptions = {\n presets: string[];\n};\n\ntype OptionsBabel = {\n babelrc?: string;\n};\n\ntype SettingsBabel = {\n options: OptionsBabel;\n};\n\ntype MinifierOptionsBabel = {\n settings: SettingsBabel;\n};\n\n/**\n * Run babel-minify.\n * @param settings Babel-minify 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 minifyBabel = ({\n settings,\n content,\n callback,\n index,\n}: MinifierOptions & MinifierOptionsBabel) => {\n let babelOptions: BabelOptions = {\n presets: [],\n };\n\n if (settings?.options?.babelrc) {\n babelOptions = JSON.parse(utils.readFile(settings.options.babelrc));\n }\n\n if (settings?.options?.presets) {\n const babelrcPresets = babelOptions.presets || [];\n babelOptions.presets = babelrcPresets.concat(\n Array.isArray(settings.options.presets)\n ? settings.options.presets\n : []\n );\n }\n\n if (babelOptions.presets.indexOf(\"minify\") === -1) {\n babelOptions.presets = babelOptions.presets.concat([minify]);\n }\n\n const contentMinified = transform(content ?? \"\", babelOptions);\n if (settings && !settings.content && settings.output) {\n 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};\n\n/**\n * Expose `minifyBabel()`.\n */\nminifyBabel.default = minifyBabel;\nexport = minifyBabel;\n"],"mappings":";;;;;;AAUA,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,OAAO,YAAY;AAZnB;AAAA;AAsCA,QAAM,cAAc,CAAC;AAAA,MACjB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ,MAA8C;AAC1C,UAAI,eAA6B;AAAA,QAC7B,SAAS,CAAC;AAAA,MACd;AAEA,UAAI,UAAU,SAAS,SAAS;AAC5B,uBAAe,KAAK,MAAM,MAAM,SAAS,SAAS,QAAQ,OAAO,CAAC;AAAA,MACtE;AAEA,UAAI,UAAU,SAAS,SAAS;AAC5B,cAAM,iBAAiB,aAAa,WAAW,CAAC;AAChD,qBAAa,UAAU,eAAe;AAAA,UAClC,MAAM,QAAQ,SAAS,QAAQ,OAAO,IAChC,SAAS,QAAQ,UACjB,CAAC;AAAA,QACX;AAAA,MACJ;AAEA,UAAI,aAAa,QAAQ,QAAQ,QAAQ,MAAM,IAAI;AAC/C,qBAAa,UAAU,aAAa,QAAQ,OAAO,CAAC,MAAM,CAAC;AAAA,MAC/D;AAEA,YAAM,kBAAkB,UAAU,WAAW,IAAI,YAAY;AAC7D,UAAI,YAAY,CAAC,SAAS,WAAW,SAAS,QAAQ;AAClD,iBAAS,UACL,MAAM,UAAU;AAAA,UACZ,MAAM,SAAS;AAAA,UACf,SAAS,gBAAgB;AAAA,UACzB;AAAA,QACJ,CAAC;AAAA,MACT;AACA,UAAI,UAAU;AACV,eAAO,SAAS,MAAM,gBAAgB,IAAI;AAAA,MAC9C;AACA,aAAO,gBAAgB;AAAA,IAC3B;AAKA,gBAAY,UAAU;AACtB,qBAAS;AAAA;AAAA;","names":[]}