@node-minify/babel-minify 7.0.0 → 8.0.0-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,64 @@
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
+ */
package/dist/index.mjs ADDED
@@ -0,0 +1,36 @@
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
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-minify/babel-minify",
3
- "version": "7.0.0",
3
+ "version": "8.0.0-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",
45
+ "prepublishOnly": "npm run build"
46
+ },
35
47
  "dependencies": {
36
- "@node-minify/utils": "^7.0.0",
48
+ "@node-minify/utils": "8.0.0-beta.0",
37
49
  "babel-core": "6.26.3",
38
50
  "babel-preset-minify": "0.5.2"
39
51
  },
40
- "gitHead": "8b5bda6f1ac9fe7180006f2a19ec3253e8fff4ec"
52
+ "devDependencies": {
53
+ "@node-minify/types": "8.0.0-beta.0",
54
+ "@types/babel-core": "^6.25.7",
55
+ "babel-preset-env": "1.7.0"
56
+ },
57
+ "gitHead": "0507c6190577e1939997a8231b07952ba167a780"
41
58
  }
@@ -1,72 +0,0 @@
1
- "use strict";
2
-
3
- var _babelCore = require("babel-core");
4
-
5
- var _babelPresetMinify = _interopRequireDefault(require("babel-preset-minify"));
6
-
7
- var _utils = require("@node-minify/utils");
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
- /*!
12
- * node-minify
13
- * Copyright(c) 2011-2022 Rodolphe Stoclin
14
- * MIT Licensed
15
- */
16
-
17
- /**
18
- * Module dependencies.
19
- */
20
-
21
- /**
22
- * Run babel-minify.
23
- *
24
- * @param {Object} settings
25
- * @param {String} content
26
- * @param {Function} callback
27
- */
28
- const minifyBabel = ({
29
- settings,
30
- content,
31
- callback,
32
- index
33
- }) => {
34
- let babelOptions = {
35
- presets: []
36
- };
37
-
38
- if (settings.options.babelrc) {
39
- babelOptions = JSON.parse(_utils.utils.readFile(settings.options.babelrc));
40
- }
41
-
42
- if (settings.options.presets) {
43
- const babelrcPresets = babelOptions.presets || [];
44
- babelOptions.presets = babelrcPresets.concat(settings.options.presets);
45
- }
46
-
47
- if (babelOptions.presets.indexOf('minify') === -1) {
48
- babelOptions.presets = babelOptions.presets.concat([_babelPresetMinify.default]);
49
- }
50
-
51
- const contentMinified = (0, _babelCore.transform)(content, babelOptions);
52
-
53
- if (!settings.content) {
54
- _utils.utils.writeFile({
55
- file: settings.output,
56
- content: contentMinified.code,
57
- index
58
- });
59
- }
60
-
61
- if (callback) {
62
- return callback(null, contentMinified.code);
63
- }
64
-
65
- return contentMinified.code;
66
- };
67
- /**
68
- * Expose `minifyBabel()`.
69
- */
70
-
71
-
72
- module.exports = minifyBabel;