@node-minify/babel-minify 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,18 @@
1
+ import { MinifierOptions } from '@node-minify/types';
2
+
3
+ /*!
4
+ * node-minify
5
+ * Copyright(c) 2011-2022 Rodolphe Stoclin
6
+ * MIT Licensed
7
+ */
8
+
9
+ /**
10
+ * Run babel-minify.
11
+ *
12
+ * @param {Object} settings
13
+ * @param {String} content
14
+ * @param {Function} callback
15
+ */
16
+ declare const minifyBabel: ({ settings, content, callback, index }: MinifierOptions) => any;
17
+
18
+ export { minifyBabel as default };
package/dist/index.js ADDED
@@ -0,0 +1,65 @@
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_babel_core = require("babel-core");
32
+ var import_babel_preset_minify = __toESM(require("babel-preset-minify"));
33
+ var import_utils = require("@node-minify/utils");
34
+ var minifyBabel = ({ settings, content, callback, index }) => {
35
+ let babelOptions = {
36
+ presets: []
37
+ };
38
+ if (settings && settings.options && settings.options.babelrc) {
39
+ babelOptions = JSON.parse(import_utils.utils.readFile(settings.options.babelrc));
40
+ }
41
+ if (settings && settings.options && settings.options.presets) {
42
+ const babelrcPresets = babelOptions.presets || [];
43
+ babelOptions.presets = babelrcPresets.concat(settings.options.presets);
44
+ }
45
+ if (babelOptions.presets.indexOf("minify") === -1) {
46
+ babelOptions.presets = babelOptions.presets.concat([import_babel_preset_minify.default]);
47
+ }
48
+ const contentMinified = (0, import_babel_core.transform)(content || "", babelOptions);
49
+ if (settings && !settings.content) {
50
+ import_utils.utils.writeFile({ file: settings.output, content: contentMinified.code, index });
51
+ }
52
+ if (callback) {
53
+ return callback(null, contentMinified.code);
54
+ }
55
+ return contentMinified.code;
56
+ };
57
+ var src_default = minifyBabel;
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {});
60
+ /*!
61
+ * node-minify
62
+ * Copyright(c) 2011-2022 Rodolphe Stoclin
63
+ * MIT Licensed
64
+ */
65
+ //# 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 { transform } from 'babel-core';\nimport minify from 'babel-preset-minify';\nimport { utils } from '@node-minify/utils';\nimport { MinifierOptions } from '@node-minify/types';\n\n// interface Options {\n// sourceMap?: boolean;\n// _sourceMap?: { url: string } | boolean;\n// babelrc?: {};\n// presets?: [];\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\ninterface BabelOptions {\n presets: string[];\n}\n\n/**\n * Run babel-minify.\n *\n * @param {Object} settings\n * @param {String} content\n * @param {Function} callback\n */\nconst minifyBabel = ({ settings, content, callback, index }: MinifierOptions) => {\n let babelOptions: BabelOptions = {\n presets: []\n };\n\n if (settings && settings.options && settings.options.babelrc) {\n babelOptions = JSON.parse(utils.readFile(settings.options.babelrc));\n }\n\n if (settings && settings.options && settings.options.presets) {\n const babelrcPresets = babelOptions.presets || [];\n babelOptions.presets = babelrcPresets.concat(settings.options.presets);\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) {\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 `minifyBabel()`.\n */\nexport default minifyBabel;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,wBAA0B;AAC1B,iCAAmB;AACnB,mBAAsB;AAkCtB,IAAM,cAAc,CAAC,EAAE,UAAU,SAAS,UAAU,MAAM,MAAuB;AAC/E,MAAI,eAA6B;AAAA,IAC/B,SAAS,CAAC;AAAA,EACZ;AAEA,MAAI,YAAY,SAAS,WAAW,SAAS,QAAQ,SAAS;AAC5D,mBAAe,KAAK,MAAM,mBAAM,SAAS,SAAS,QAAQ,OAAO,CAAC;AAAA,EACpE;AAEA,MAAI,YAAY,SAAS,WAAW,SAAS,QAAQ,SAAS;AAC5D,UAAM,iBAAiB,aAAa,WAAW,CAAC;AAChD,iBAAa,UAAU,eAAe,OAAO,SAAS,QAAQ,OAAO;AAAA,EACvE;AAEA,MAAI,aAAa,QAAQ,QAAQ,QAAQ,MAAM,IAAI;AACjD,iBAAa,UAAU,aAAa,QAAQ,OAAO,CAAC,2BAAAA,OAAM,CAAC;AAAA,EAC7D;AAEA,QAAM,sBAAkB,6BAAU,WAAW,IAAI,YAAY;AAC7D,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":["minify"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,37 @@
1
+ // src/index.ts
2
+ import { transform } from "babel-core";
3
+ import minify from "babel-preset-minify";
4
+ import { utils } from "@node-minify/utils";
5
+ var minifyBabel = ({ settings, content, callback, index }) => {
6
+ let babelOptions = {
7
+ presets: []
8
+ };
9
+ if (settings && settings.options && settings.options.babelrc) {
10
+ babelOptions = JSON.parse(utils.readFile(settings.options.babelrc));
11
+ }
12
+ if (settings && settings.options && settings.options.presets) {
13
+ const babelrcPresets = babelOptions.presets || [];
14
+ babelOptions.presets = babelrcPresets.concat(settings.options.presets);
15
+ }
16
+ if (babelOptions.presets.indexOf("minify") === -1) {
17
+ babelOptions.presets = babelOptions.presets.concat([minify]);
18
+ }
19
+ const contentMinified = transform(content || "", babelOptions);
20
+ if (settings && !settings.content) {
21
+ utils.writeFile({ file: settings.output, content: contentMinified.code, index });
22
+ }
23
+ if (callback) {
24
+ return callback(null, contentMinified.code);
25
+ }
26
+ return contentMinified.code;
27
+ };
28
+ var src_default = minifyBabel;
29
+ export {
30
+ src_default as default
31
+ };
32
+ /*!
33
+ * node-minify
34
+ * Copyright(c) 2011-2022 Rodolphe Stoclin
35
+ * MIT Licensed
36
+ */
37
+ //# 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 { transform } from 'babel-core';\nimport minify from 'babel-preset-minify';\nimport { utils } from '@node-minify/utils';\nimport { MinifierOptions } from '@node-minify/types';\n\n// interface Options {\n// sourceMap?: boolean;\n// _sourceMap?: { url: string } | boolean;\n// babelrc?: {};\n// presets?: [];\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\ninterface BabelOptions {\n presets: string[];\n}\n\n/**\n * Run babel-minify.\n *\n * @param {Object} settings\n * @param {String} content\n * @param {Function} callback\n */\nconst minifyBabel = ({ settings, content, callback, index }: MinifierOptions) => {\n let babelOptions: BabelOptions = {\n presets: []\n };\n\n if (settings && settings.options && settings.options.babelrc) {\n babelOptions = JSON.parse(utils.readFile(settings.options.babelrc));\n }\n\n if (settings && settings.options && settings.options.presets) {\n const babelrcPresets = babelOptions.presets || [];\n babelOptions.presets = babelrcPresets.concat(settings.options.presets);\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) {\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 `minifyBabel()`.\n */\nexport default minifyBabel;\n"],"mappings":";AASA,SAAS,iBAAiB;AAC1B,OAAO,YAAY;AACnB,SAAS,aAAa;AAkCtB,IAAM,cAAc,CAAC,EAAE,UAAU,SAAS,UAAU,MAAM,MAAuB;AAC/E,MAAI,eAA6B;AAAA,IAC/B,SAAS,CAAC;AAAA,EACZ;AAEA,MAAI,YAAY,SAAS,WAAW,SAAS,QAAQ,SAAS;AAC5D,mBAAe,KAAK,MAAM,MAAM,SAAS,SAAS,QAAQ,OAAO,CAAC;AAAA,EACpE;AAEA,MAAI,YAAY,SAAS,WAAW,SAAS,QAAQ,SAAS;AAC5D,UAAM,iBAAiB,aAAa,WAAW,CAAC;AAChD,iBAAa,UAAU,eAAe,OAAO,SAAS,QAAQ,OAAO;AAAA,EACvE;AAEA,MAAI,aAAa,QAAQ,QAAQ,QAAQ,MAAM,IAAI;AACjD,iBAAa,UAAU,aAAa,QAAQ,OAAO,CAAC,MAAM,CAAC;AAAA,EAC7D;AAEA,QAAM,kBAAkB,UAAU,WAAW,IAAI,YAAY;AAC7D,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/babel-minify",
3
- "version": "7.1.0",
3
+ "version": "8.0.1-beta.0",
4
4
  "description": "babel-minify 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/babel-minify#readme",
13
13
  "license": "MIT",
14
- "main": "lib/babel-minify.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,10 +39,20 @@
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",
48
+ "@node-minify/utils": "8.0.1-beta.0",
37
49
  "babel-core": "6.26.3",
38
50
  "babel-preset-minify": "0.5.2"
39
51
  },
40
- "gitHead": "94cef2d5d653c3bddc3e603b4e25c135b0b6f4b3"
52
+ "devDependencies": {
53
+ "@node-minify/types": "8.0.1-beta.0",
54
+ "@types/babel-core": "^6.25.7",
55
+ "babel-preset-env": "1.7.0"
56
+ },
57
+ "gitHead": "35a8a41ec86a11cbec05d8a7db9113475ece2cef"
41
58
  }
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- var _babelCore = require("babel-core");
4
- var _babelPresetMinify = _interopRequireDefault(require("babel-preset-minify"));
5
- var _utils = require("@node-minify/utils");
6
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7
- /*!
8
- * node-minify
9
- * Copyright(c) 2011-2022 Rodolphe Stoclin
10
- * MIT Licensed
11
- */
12
-
13
- /**
14
- * Module dependencies.
15
- */
16
-
17
- /**
18
- * Run babel-minify.
19
- *
20
- * @param {Object} settings
21
- * @param {String} content
22
- * @param {Function} callback
23
- */
24
- const minifyBabel = ({
25
- settings,
26
- content,
27
- callback,
28
- index
29
- }) => {
30
- let babelOptions = {
31
- presets: []
32
- };
33
- if (settings.options.babelrc) {
34
- babelOptions = JSON.parse(_utils.utils.readFile(settings.options.babelrc));
35
- }
36
- if (settings.options.presets) {
37
- const babelrcPresets = babelOptions.presets || [];
38
- babelOptions.presets = babelrcPresets.concat(settings.options.presets);
39
- }
40
- if (babelOptions.presets.indexOf('minify') === -1) {
41
- babelOptions.presets = babelOptions.presets.concat([_babelPresetMinify.default]);
42
- }
43
- const contentMinified = (0, _babelCore.transform)(content, babelOptions);
44
- if (!settings.content) {
45
- _utils.utils.writeFile({
46
- file: settings.output,
47
- content: contentMinified.code,
48
- index
49
- });
50
- }
51
- if (callback) {
52
- return callback(null, contentMinified.code);
53
- }
54
- return contentMinified.code;
55
- };
56
-
57
- /**
58
- * Expose `minifyBabel()`.
59
- */
60
- module.exports = minifyBabel;