@pi-r/terser 0.7.3 → 0.8.2
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/README.md +1 -1
- package/index.js +11 -10
- package/package.json +26 -26
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
2
|
+
const util_1 = require("@e-mc/document/util");
|
|
3
3
|
const MINIFY_PROPS = [
|
|
4
4
|
'compress',
|
|
5
5
|
'ecma',
|
|
@@ -22,14 +22,14 @@ const MINIFY_PROPS = [
|
|
|
22
22
|
'warnings',
|
|
23
23
|
'wrap'
|
|
24
24
|
];
|
|
25
|
-
|
|
25
|
+
async function transform(context, value, options) {
|
|
26
26
|
const { sourceMap, supplementChunks } = options;
|
|
27
27
|
const baseConfig = options.toBaseConfig();
|
|
28
28
|
let url;
|
|
29
29
|
if (baseConfig.sourceMap === false) {
|
|
30
30
|
sourceMap.reset();
|
|
31
31
|
}
|
|
32
|
-
else if (
|
|
32
|
+
else if ((0, util_1.isObject)(baseConfig.sourceMap) || sourceMap.map && (baseConfig.sourceMap = {})) {
|
|
33
33
|
const map = baseConfig.sourceMap;
|
|
34
34
|
if (sourceMap.map) {
|
|
35
35
|
map.content = sourceMap.map;
|
|
@@ -41,7 +41,7 @@ module.exports = async function transform(context, value, options) {
|
|
|
41
41
|
}
|
|
42
42
|
for (const chunk of supplementChunks) {
|
|
43
43
|
const chunkConfig = { ...baseConfig };
|
|
44
|
-
if (
|
|
44
|
+
if ((0, util_1.isObject)(chunkConfig.sourceMap)) {
|
|
45
45
|
chunkConfig.sourceMap = { content: chunk.sourceMap?.map, asObject: true };
|
|
46
46
|
}
|
|
47
47
|
const result = await context.minify(chunk.code, chunkConfig);
|
|
@@ -58,11 +58,12 @@ module.exports = async function transform(context, value, options) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
if (
|
|
64
|
-
sourceMap.nextMap('terser',
|
|
61
|
+
const { code, map } = await context.minify(value, (0, util_1.removeInternalProperties)(baseConfig, MINIFY_PROPS));
|
|
62
|
+
if (code) {
|
|
63
|
+
if (map) {
|
|
64
|
+
sourceMap.nextMap('terser', code, map, url);
|
|
65
65
|
}
|
|
66
|
-
return
|
|
66
|
+
return code;
|
|
67
67
|
}
|
|
68
|
-
}
|
|
68
|
+
}
|
|
69
|
+
module.exports = transform;
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@pi-r/terser",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"publishConfig": {
|
|
7
|
-
"access": "public"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/anpham6/pi-r.git",
|
|
12
|
-
"directory": "src/
|
|
13
|
-
},
|
|
14
|
-
"keywords": [
|
|
15
|
-
"squared",
|
|
16
|
-
"e-mc",
|
|
17
|
-
"squared-functions"
|
|
18
|
-
],
|
|
19
|
-
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@e-mc/document": "^0.
|
|
24
|
-
"terser": "^5.
|
|
25
|
-
}
|
|
26
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@pi-r/terser",
|
|
3
|
+
"version": "0.8.2",
|
|
4
|
+
"description": "Terser transform function for E-mc.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/anpham6/pi-r.git",
|
|
12
|
+
"directory": "src/document/terser"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"squared",
|
|
16
|
+
"e-mc",
|
|
17
|
+
"squared-functions"
|
|
18
|
+
],
|
|
19
|
+
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@e-mc/document": "^0.10.2",
|
|
24
|
+
"terser": "^5.33.0"
|
|
25
|
+
}
|
|
26
|
+
}
|