@node-minify/babel-minify 10.0.0-next.0 → 10.0.1
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/LICENSE +1 -1
- package/README.md +9 -8
- package/dist/index.d.ts +157 -19
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -46
- package/dist/index.js.map +1 -0
- package/package.json +14 -12
- package/dist/index.cjs +0 -86
- package/dist/index.d.cts +0 -24
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
<br>
|
|
7
7
|
<a href="https://npmjs.org/package/@node-minify/babel-minify"><img src="https://img.shields.io/npm/v/@node-minify/babel-minify.svg"></a>
|
|
8
8
|
<a href="https://npmjs.org/package/@node-minify/babel-minify"><img src="https://img.shields.io/npm/dm/@node-minify/babel-minify.svg"></a>
|
|
9
|
-
<a href="https://github.com/srod/node-minify/actions"><img alt="Build Status" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fsrod%2Fnode-minify%2Fbadge%3Fref%
|
|
10
|
-
<a href="https://codecov.io/gh/srod/node-minify"><img src="https://codecov.io/gh/srod/node-minify/branch/
|
|
9
|
+
<a href="https://github.com/srod/node-minify/actions"><img alt="Build Status" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fsrod%2Fnode-minify%2Fbadge%3Fref%3Dmain&style=flat" /></a>
|
|
10
|
+
<a href="https://codecov.io/gh/srod/node-minify"><img src="https://codecov.io/gh/srod/node-minify/branch/main/graph/badge.svg"></a>
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
13
|
# babel-minify
|
|
14
14
|
|
|
15
|
+
> **⚠️ Deprecation Notice**: This package uses Babel 6 which is no longer maintained. Consider using [`@node-minify/terser`](https://github.com/srod/node-minify/tree/main/packages/terser) instead for actively maintained JavaScript minification.
|
|
16
|
+
|
|
15
17
|
`babel-minify` is a plugin for [`node-minify`](https://github.com/srod/node-minify)
|
|
16
18
|
|
|
17
19
|
It allow you to compress JavaScript files.
|
|
@@ -25,14 +27,13 @@ npm install @node-minify/core @node-minify/babel-minify
|
|
|
25
27
|
## Usage
|
|
26
28
|
|
|
27
29
|
```js
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
import { minify } from '@node-minify/core';
|
|
31
|
+
import { babelMinify } from '@node-minify/babel-minify';
|
|
30
32
|
|
|
31
|
-
minify({
|
|
33
|
+
await minify({
|
|
32
34
|
compressor: babelMinify,
|
|
33
35
|
input: 'foo.js',
|
|
34
|
-
output: 'bar.js'
|
|
35
|
-
callback: function (err, min) {}
|
|
36
|
+
output: 'bar.js'
|
|
36
37
|
});
|
|
37
38
|
```
|
|
38
39
|
|
|
@@ -42,4 +43,4 @@ Visit https://node-minify.2clics.net/compressors/babel-minify.html for full docu
|
|
|
42
43
|
|
|
43
44
|
## License
|
|
44
45
|
|
|
45
|
-
[MIT](https://github.com/srod/node-minify/blob/
|
|
46
|
+
[MIT](https://github.com/srod/node-minify/blob/main/LICENSE)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,162 @@
|
|
|
1
|
-
|
|
1
|
+
//#region ../types/src/types.d.ts
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
6
|
-
* MIT Licensed
|
|
3
|
+
/**
|
|
4
|
+
* Result returned by a compressor function.
|
|
7
5
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
type SettingsBabel = {
|
|
13
|
-
options: OptionsBabel;
|
|
14
|
-
};
|
|
15
|
-
type MinifierOptionsBabel = {
|
|
16
|
-
settings: SettingsBabel;
|
|
6
|
+
type CompressorResult = {
|
|
7
|
+
code: string;
|
|
8
|
+
map?: string;
|
|
17
9
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Base options that all compressors can accept.
|
|
12
|
+
* Specific compressors may extend this with their own options.
|
|
13
|
+
*/
|
|
14
|
+
type CompressorOptions = Record<string, unknown>;
|
|
15
|
+
/**
|
|
16
|
+
* A compressor function that minifies content.
|
|
17
|
+
* @param args - The minifier options including settings and content
|
|
18
|
+
* @returns A promise resolving to the compression result
|
|
19
|
+
*/
|
|
20
|
+
type Compressor<TOptions extends CompressorOptions = CompressorOptions> = (args: MinifierOptions<TOptions>) => Promise<CompressorResult>;
|
|
21
|
+
/**
|
|
22
|
+
* File type for compressors that support multiple types (e.g., YUI).
|
|
23
|
+
*/
|
|
24
|
+
type FileType = "js" | "css";
|
|
25
|
+
/**
|
|
26
|
+
* User-facing settings for the minify function.
|
|
27
|
+
* This is what users pass when calling minify().
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { minify } from '@node-minify/core';
|
|
32
|
+
* import { terser } from '@node-minify/terser';
|
|
33
|
+
*
|
|
34
|
+
* await minify({
|
|
35
|
+
* compressor: terser,
|
|
36
|
+
* input: 'src/*.js',
|
|
37
|
+
* output: 'dist/bundle.min.js',
|
|
38
|
+
* options: { mangle: true }
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
type Settings<TOptions extends CompressorOptions = CompressorOptions> = {
|
|
43
|
+
/**
|
|
44
|
+
* The compressor function to use for minification.
|
|
45
|
+
*/
|
|
46
|
+
compressor: Compressor<TOptions>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Optional label for the compressor (used in logging).
|
|
50
|
+
*/
|
|
51
|
+
compressorLabel?: string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Content to minify (for in-memory minification).
|
|
55
|
+
* If provided, input/output are not required.
|
|
56
|
+
*/
|
|
57
|
+
content?: string;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Input file path(s) or glob pattern.
|
|
61
|
+
* Can be a single file, array of files, or wildcard pattern.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* - 'src/app.js'
|
|
65
|
+
* - ['src/a.js', 'src/b.js']
|
|
66
|
+
* - 'src/**\/*.js'
|
|
67
|
+
*/
|
|
68
|
+
input?: string | string[];
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Output file path.
|
|
72
|
+
* Use $1 as placeholder for input filename in multi-file scenarios.
|
|
73
|
+
* Can be a single file, array of files, or pattern with $1.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* - 'dist/bundle.min.js'
|
|
77
|
+
* - ['file1.min.js', 'file2.min.js']
|
|
78
|
+
* - '$1.min.js' (creates app.min.js from app.js)
|
|
79
|
+
*/
|
|
80
|
+
output?: string | string[];
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Compressor-specific options.
|
|
84
|
+
* See individual compressor documentation for available options.
|
|
85
|
+
*/
|
|
86
|
+
options?: TOptions;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* CLI option string (used by CLI only).
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
option?: string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Buffer size for file operations (in bytes).
|
|
96
|
+
* @default 1024000 (1MB)
|
|
97
|
+
*/
|
|
98
|
+
buffer?: number;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* File type for compressors that support multiple types.
|
|
102
|
+
* Required for YUI compressor.
|
|
103
|
+
*/
|
|
104
|
+
type?: FileType;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Suppress console output.
|
|
108
|
+
* @default false
|
|
109
|
+
*/
|
|
110
|
+
silence?: boolean;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Public folder to prepend to input paths.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* With publicFolder: 'public/js/' and input: 'app.js',
|
|
117
|
+
* the actual path becomes 'public/js/app.js'
|
|
118
|
+
*/
|
|
119
|
+
publicFolder?: string;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Replace files in place instead of creating new output files.
|
|
123
|
+
* @default false
|
|
124
|
+
*/
|
|
125
|
+
replaceInPlace?: boolean;
|
|
21
126
|
};
|
|
127
|
+
/**
|
|
128
|
+
* Options passed to compressor functions internally.
|
|
129
|
+
* This is what compressors receive, not what users pass.
|
|
130
|
+
*/
|
|
131
|
+
type MinifierOptions<TOptions extends CompressorOptions = CompressorOptions> = {
|
|
132
|
+
/**
|
|
133
|
+
* The full settings object.
|
|
134
|
+
*/
|
|
135
|
+
settings: Settings<TOptions>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The content to minify.
|
|
139
|
+
*/
|
|
140
|
+
content?: string;
|
|
22
141
|
|
|
23
|
-
|
|
24
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Index of current file when processing multiple files.
|
|
144
|
+
*/
|
|
145
|
+
index?: number;
|
|
146
|
+
};
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/index.d.ts
|
|
149
|
+
/**
|
|
150
|
+
* Run babel-minify.
|
|
151
|
+
* @deprecated babel-minify uses Babel 6 which is no longer maintained. Use @node-minify/terser instead.
|
|
152
|
+
* @param settings - Babel-minify options
|
|
153
|
+
* @param content - Content to minify
|
|
154
|
+
* @returns Minified content
|
|
155
|
+
*/
|
|
156
|
+
declare function babelMinify({
|
|
157
|
+
settings,
|
|
158
|
+
content
|
|
159
|
+
}: MinifierOptions): Promise<CompressorResult>;
|
|
160
|
+
//#endregion
|
|
161
|
+
export { babelMinify };
|
|
162
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["CompressorReturnType","CompressorResult","CompressorOptions","Record","Compressor","TOptions","MinifierOptions","Promise","FileType","Settings","Result","MinifyOptions"],"sources":["../../types/src/types.d.ts","../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2025 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * The return type of a compressor function.\n * @deprecated Use `CompressorResult` instead. Will be removed in v11.\n */\nexport type CompressorReturnType = string;\n\n/**\n * Result returned by a compressor function.\n */\nexport type CompressorResult = {\n code: string;\n map?: string;\n};\n\n/**\n * Base options that all compressors can accept.\n * Specific compressors may extend this with their own options.\n */\nexport type CompressorOptions = Record<string, unknown>;\n\n/**\n * A compressor function that minifies content.\n * @param args - The minifier options including settings and content\n * @returns A promise resolving to the compression result\n */\nexport type Compressor<TOptions extends CompressorOptions = CompressorOptions> =\n (args: MinifierOptions<TOptions>) => Promise<CompressorResult>;\n\n/**\n * File type for compressors that support multiple types (e.g., YUI).\n */\nexport type FileType = \"js\" | \"css\";\n\n/**\n * User-facing settings for the minify function.\n * This is what users pass when calling minify().\n *\n * @example\n * ```ts\n * import { minify } from '@node-minify/core';\n * import { terser } from '@node-minify/terser';\n *\n * await minify({\n * compressor: terser,\n * input: 'src/*.js',\n * output: 'dist/bundle.min.js',\n * options: { mangle: true }\n * });\n * ```\n */\nexport type Settings<TOptions extends CompressorOptions = CompressorOptions> = {\n /**\n * The compressor function to use for minification.\n */\n compressor: Compressor<TOptions>;\n\n /**\n * Optional label for the compressor (used in logging).\n */\n compressorLabel?: string;\n\n /**\n * Content to minify (for in-memory minification).\n * If provided, input/output are not required.\n */\n content?: string;\n\n /**\n * Input file path(s) or glob pattern.\n * Can be a single file, array of files, or wildcard pattern.\n *\n * @example\n * - 'src/app.js'\n * - ['src/a.js', 'src/b.js']\n * - 'src/**\\/*.js'\n */\n input?: string | string[];\n\n /**\n * Output file path.\n * Use $1 as placeholder for input filename in multi-file scenarios.\n * Can be a single file, array of files, or pattern with $1.\n *\n * @example\n * - 'dist/bundle.min.js'\n * - ['file1.min.js', 'file2.min.js']\n * - '$1.min.js' (creates app.min.js from app.js)\n */\n output?: string | string[];\n\n /**\n * Compressor-specific options.\n * See individual compressor documentation for available options.\n */\n options?: TOptions;\n\n /**\n * CLI option string (used by CLI only).\n * @internal\n */\n option?: string;\n\n /**\n * Buffer size for file operations (in bytes).\n * @default 1024000 (1MB)\n */\n buffer?: number;\n\n /**\n * File type for compressors that support multiple types.\n * Required for YUI compressor.\n */\n type?: FileType;\n\n /**\n * Suppress console output.\n * @default false\n */\n silence?: boolean;\n\n /**\n * Public folder to prepend to input paths.\n *\n * @example\n * With publicFolder: 'public/js/' and input: 'app.js',\n * the actual path becomes 'public/js/app.js'\n */\n publicFolder?: string;\n\n /**\n * Replace files in place instead of creating new output files.\n * @default false\n */\n replaceInPlace?: boolean;\n};\n\n/**\n * Options passed to compressor functions internally.\n * This is what compressors receive, not what users pass.\n */\nexport type MinifierOptions<\n TOptions extends CompressorOptions = CompressorOptions,\n> = {\n /**\n * The full settings object.\n */\n settings: Settings<TOptions>;\n\n /**\n * The content to minify.\n */\n content?: string;\n\n /**\n * Index of current file when processing multiple files.\n */\n index?: number;\n};\n\n/**\n * Result returned after compression (used by CLI).\n */\nexport type Result = {\n /**\n * Label of the compressor used.\n */\n compressorLabel: string;\n\n /**\n * Size of minified content (formatted string, e.g., \"1.5 KB\").\n */\n size: string;\n\n /**\n * Gzipped size of minified content (formatted string).\n */\n sizeGzip: string;\n};\n\n/**\n * Type alias for user convenience.\n * @deprecated Use `Settings` instead. Will be removed in v11.\n */\nexport type MinifyOptions<\n TOptions extends CompressorOptions = CompressorOptions,\n> = Settings<TOptions>;\n"],"mappings":";;AAwDA;;;AAI2BK,KA7CfJ,gBAAAA,GA6CeI;EAAXD,IAAAA,EAAAA,MAAAA;EAwCFC,GAAAA,CAAAA,EAAAA,MAAAA;CAkBHG;AA4BX;;;;AAMcC,KAhIFP,iBAAAA,GAAoBC,MAgIlBM,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;;;;AClId;;AAEI,KDOQL,UCPR,CAAA,iBDOoCF,iBCPpC,GDOwDA,iBCPxD,CAAA,GACD,CAAA,IAAA,EDOQI,eCPR,CDOwBD,QCPxB,CAAA,EAAA,GDOsCE,OCPtC,CDO8CN,gBCP9C,CAAA;;;;KDYSO,QAAAA;;;;;;;;;;;;;;;;;;KAmBAC,0BAA0BP,oBAAoBA;;;;cAI1CE,WAAWC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAwCbA;;;;;;;;;;;;;;;;;;SAkBHG;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BCF,iCACSJ,oBAAoBA;;;;YAK3BO,SAASJ;;;;;;;;;;;;;;;;;;;AAnHvB;AAmBA;AAAsCH,iBClChB,WAAA,CDkCgBA;EAAAA,QAAAA;EAAAA;AAAAA,CAAAA,EC/BnC,eD+BmCA,CAAAA,EC/BjB,OD+BiBA,CC/BT,gBD+BSA,CAAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,48 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
import { utils } from "@node-minify/utils";
|
|
1
|
+
import { readFile, warnDeprecation } from "@node-minify/utils";
|
|
3
2
|
import { transform } from "babel-core";
|
|
4
3
|
import minify from "babel-preset-minify";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
if (callback) {
|
|
35
|
-
return callback(null, contentMinified.code);
|
|
36
|
-
}
|
|
37
|
-
return contentMinified.code;
|
|
38
|
-
};
|
|
39
|
-
minifyBabel.default = minifyBabel;
|
|
40
|
-
var src_default = minifyBabel;
|
|
41
|
-
export {
|
|
42
|
-
src_default as default
|
|
43
|
-
};
|
|
44
|
-
/*!
|
|
45
|
-
* node-minify
|
|
46
|
-
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
47
|
-
* MIT Licensed
|
|
48
|
-
*/
|
|
4
|
+
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
/**
|
|
7
|
+
* Run babel-minify.
|
|
8
|
+
* @deprecated babel-minify uses Babel 6 which is no longer maintained. Use @node-minify/terser instead.
|
|
9
|
+
* @param settings - Babel-minify options
|
|
10
|
+
* @param content - Content to minify
|
|
11
|
+
* @returns Minified content
|
|
12
|
+
*/
|
|
13
|
+
async function babelMinify({ settings, content }) {
|
|
14
|
+
warnDeprecation("babel-minify", "babel-minify uses Babel 6 which is no longer maintained. Please migrate to @node-minify/terser for continued support and modern JavaScript features.");
|
|
15
|
+
let babelOptions = { presets: [] };
|
|
16
|
+
const babelrc = settings?.options?.babelrc;
|
|
17
|
+
const presets = settings?.options?.presets;
|
|
18
|
+
if (babelrc) babelOptions = JSON.parse(readFile(babelrc));
|
|
19
|
+
if (presets && Array.isArray(presets)) {
|
|
20
|
+
const babelrcPresets = babelOptions.presets || [];
|
|
21
|
+
babelOptions.presets = presets.concat(babelrcPresets);
|
|
22
|
+
}
|
|
23
|
+
if (!babelOptions.presets.includes("minify")) babelOptions.presets = babelOptions.presets.concat([minify]);
|
|
24
|
+
const result = transform(content ?? "", babelOptions);
|
|
25
|
+
if (typeof result.code !== "string") throw new Error("Babel minification failed: empty result");
|
|
26
|
+
return { code: result.code };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { babelMinify };
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["babelOptions: BabelOptions"],"sources":["../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2025 Rodolphe Stoclin\n * MIT Licensed\n */\n\nimport type { CompressorResult, MinifierOptions } from \"@node-minify/types\";\nimport { readFile, warnDeprecation } from \"@node-minify/utils\";\nimport { transform } from \"babel-core\";\nimport minify from \"babel-preset-minify\";\n\ntype BabelOptions = {\n presets: (string | typeof minify)[];\n};\n\n/**\n * Run babel-minify.\n * @deprecated babel-minify uses Babel 6 which is no longer maintained. Use @node-minify/terser instead.\n * @param settings - Babel-minify options\n * @param content - Content to minify\n * @returns Minified content\n */\nexport async function babelMinify({\n settings,\n content,\n}: MinifierOptions): Promise<CompressorResult> {\n warnDeprecation(\n \"babel-minify\",\n \"babel-minify uses Babel 6 which is no longer maintained. \" +\n \"Please migrate to @node-minify/terser for continued support and modern JavaScript features.\"\n );\n\n let babelOptions: BabelOptions = { presets: [] };\n const babelrc = settings?.options?.babelrc as string | undefined;\n const presets = settings?.options?.presets as string[] | undefined;\n\n if (babelrc) {\n babelOptions = JSON.parse(readFile(babelrc));\n }\n\n if (presets && Array.isArray(presets)) {\n const babelrcPresets = babelOptions.presets || [];\n babelOptions.presets = presets.concat(babelrcPresets);\n }\n\n if (!babelOptions.presets.includes(\"minify\")) {\n babelOptions.presets = babelOptions.presets.concat([minify]);\n }\n\n const result = transform(content ?? \"\", babelOptions);\n\n if (typeof result.code !== \"string\") {\n throw new Error(\"Babel minification failed: empty result\");\n }\n\n return { code: result.code };\n}\n"],"mappings":";;;;;;;;;;;;AAsBA,eAAsB,YAAY,EAC9B,UACA,WAC2C;AAC3C,iBACI,gBACA,uJAEH;CAED,IAAIA,eAA6B,EAAE,SAAS,EAAE,EAAE;CAChD,MAAM,UAAU,UAAU,SAAS;CACnC,MAAM,UAAU,UAAU,SAAS;AAEnC,KAAI,QACA,gBAAe,KAAK,MAAM,SAAS,QAAQ,CAAC;AAGhD,KAAI,WAAW,MAAM,QAAQ,QAAQ,EAAE;EACnC,MAAM,iBAAiB,aAAa,WAAW,EAAE;AACjD,eAAa,UAAU,QAAQ,OAAO,eAAe;;AAGzD,KAAI,CAAC,aAAa,QAAQ,SAAS,SAAS,CACxC,cAAa,UAAU,aAAa,QAAQ,OAAO,CAAC,OAAO,CAAC;CAGhE,MAAM,SAAS,UAAU,WAAW,IAAI,aAAa;AAErD,KAAI,OAAO,OAAO,SAAS,SACvB,OAAM,IAAI,MAAM,0CAA0C;AAG9D,QAAO,EAAE,MAAM,OAAO,MAAM"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-minify/babel-minify",
|
|
3
|
-
"version": "10.0.
|
|
4
|
-
"
|
|
3
|
+
"version": "10.0.1",
|
|
4
|
+
"deprecated": "babel-minify uses Babel 6 which is no longer maintained. Please use @node-minify/terser instead.",
|
|
5
|
+
"description": "babel-minify plugin for @node-minify (DEPRECATED - use @node-minify/terser)",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"compressor",
|
|
7
8
|
"minify",
|
|
@@ -13,20 +14,19 @@
|
|
|
13
14
|
"license": "MIT",
|
|
14
15
|
"type": "module",
|
|
15
16
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
17
|
+
"node": ">=20.0.0"
|
|
17
18
|
},
|
|
18
19
|
"directories": {
|
|
19
20
|
"lib": "dist",
|
|
20
21
|
"test": "__tests__"
|
|
21
22
|
},
|
|
22
|
-
"
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"main": "./dist/index.js",
|
|
23
25
|
"exports": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"import": "./dist/index.js",
|
|
27
|
-
"default": "./dist/index.cjs"
|
|
28
|
-
}
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
29
28
|
},
|
|
29
|
+
"sideEffects": false,
|
|
30
30
|
"files": [
|
|
31
31
|
"dist/**/*"
|
|
32
32
|
],
|
|
@@ -41,14 +41,16 @@
|
|
|
41
41
|
"url": "https://github.com/srod/node-minify/issues"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
|
-
"build": "
|
|
45
|
-
"check-exports": "attw --pack .",
|
|
44
|
+
"build": "tsdown src/index.ts",
|
|
45
|
+
"check-exports": "attw --pack . --profile esm-only",
|
|
46
46
|
"format:check": "biome check .",
|
|
47
47
|
"lint": "biome lint .",
|
|
48
48
|
"prepublishOnly": "bun run build",
|
|
49
49
|
"test": "vitest run",
|
|
50
50
|
"test:ci": "vitest run --coverage",
|
|
51
|
-
"test:watch": "vitest"
|
|
51
|
+
"test:watch": "vitest",
|
|
52
|
+
"typecheck": "tsc --noEmit",
|
|
53
|
+
"dev": "tsdown src/index.ts --watch"
|
|
52
54
|
},
|
|
53
55
|
"dependencies": {
|
|
54
56
|
"@node-minify/utils": "workspace:*",
|
package/dist/index.cjs
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/index.d.cts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { MinifierOptions } from '@node-minify/types';
|
|
2
|
-
|
|
3
|
-
/*!
|
|
4
|
-
* node-minify
|
|
5
|
-
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
6
|
-
* MIT Licensed
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
type OptionsBabel = {
|
|
10
|
-
babelrc?: string;
|
|
11
|
-
};
|
|
12
|
-
type SettingsBabel = {
|
|
13
|
-
options: OptionsBabel;
|
|
14
|
-
};
|
|
15
|
-
type MinifierOptionsBabel = {
|
|
16
|
-
settings: SettingsBabel;
|
|
17
|
-
};
|
|
18
|
-
declare const minifyBabel: {
|
|
19
|
-
({ settings, content, callback, index, }: MinifierOptions & MinifierOptionsBabel): string | void;
|
|
20
|
-
default: any;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export { minifyBabel as default };
|
|
24
|
-
export = minifyBabel
|