@rollup/plugin-terser 0.2.1 → 0.3.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/cjs/index.js +13 -1
- package/dist/es/index.js +13 -1
- package/package.json +1 -1
- package/src/module.ts +11 -1
- package/src/type.ts +1 -0
- package/src/worker.ts +8 -0
package/dist/cjs/index.js
CHANGED
|
@@ -36,6 +36,12 @@ async function runWorker() {
|
|
|
36
36
|
code: result.code || worker_threads.workerData.code,
|
|
37
37
|
nameCache: options.nameCache
|
|
38
38
|
};
|
|
39
|
+
if (typeof result.map === 'string') {
|
|
40
|
+
output.sourceMap = JSON.parse(result.map);
|
|
41
|
+
}
|
|
42
|
+
if (smob.isObject(result.map)) {
|
|
43
|
+
output.sourceMap = result.map;
|
|
44
|
+
}
|
|
39
45
|
worker_threads.parentPort.postMessage(output);
|
|
40
46
|
}
|
|
41
47
|
catch (e) {
|
|
@@ -140,7 +146,7 @@ function terser(input = {}) {
|
|
|
140
146
|
defaultOptions.toplevel = true;
|
|
141
147
|
}
|
|
142
148
|
try {
|
|
143
|
-
const { code: result, nameCache } = await workerPool.addAsync({
|
|
149
|
+
const { code: result, nameCache, sourceMap } = await workerPool.addAsync({
|
|
144
150
|
code,
|
|
145
151
|
options: smob.merge({}, options || {}, defaultOptions)
|
|
146
152
|
});
|
|
@@ -167,6 +173,12 @@ function terser(input = {}) {
|
|
|
167
173
|
// eslint-disable-next-line no-param-reassign
|
|
168
174
|
options.nameCache.props = props;
|
|
169
175
|
}
|
|
176
|
+
if ((!!defaultOptions.sourceMap || !!options.sourceMap) && smob.isObject(sourceMap)) {
|
|
177
|
+
return {
|
|
178
|
+
code: result,
|
|
179
|
+
map: sourceMap
|
|
180
|
+
};
|
|
181
|
+
}
|
|
170
182
|
return result;
|
|
171
183
|
}
|
|
172
184
|
catch (e) {
|
package/dist/es/index.js
CHANGED
|
@@ -32,6 +32,12 @@ async function runWorker() {
|
|
|
32
32
|
code: result.code || workerData.code,
|
|
33
33
|
nameCache: options.nameCache
|
|
34
34
|
};
|
|
35
|
+
if (typeof result.map === 'string') {
|
|
36
|
+
output.sourceMap = JSON.parse(result.map);
|
|
37
|
+
}
|
|
38
|
+
if (isObject(result.map)) {
|
|
39
|
+
output.sourceMap = result.map;
|
|
40
|
+
}
|
|
35
41
|
parentPort.postMessage(output);
|
|
36
42
|
}
|
|
37
43
|
catch (e) {
|
|
@@ -136,7 +142,7 @@ function terser(input = {}) {
|
|
|
136
142
|
defaultOptions.toplevel = true;
|
|
137
143
|
}
|
|
138
144
|
try {
|
|
139
|
-
const { code: result, nameCache } = await workerPool.addAsync({
|
|
145
|
+
const { code: result, nameCache, sourceMap } = await workerPool.addAsync({
|
|
140
146
|
code,
|
|
141
147
|
options: merge({}, options || {}, defaultOptions)
|
|
142
148
|
});
|
|
@@ -163,6 +169,12 @@ function terser(input = {}) {
|
|
|
163
169
|
// eslint-disable-next-line no-param-reassign
|
|
164
170
|
options.nameCache.props = props;
|
|
165
171
|
}
|
|
172
|
+
if ((!!defaultOptions.sourceMap || !!options.sourceMap) && isObject(sourceMap)) {
|
|
173
|
+
return {
|
|
174
|
+
code: result,
|
|
175
|
+
map: sourceMap
|
|
176
|
+
};
|
|
177
|
+
}
|
|
166
178
|
return result;
|
|
167
179
|
}
|
|
168
180
|
catch (e) {
|
package/package.json
CHANGED
package/src/module.ts
CHANGED
|
@@ -31,7 +31,11 @@ export default function terser(input: Options = {}) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
try {
|
|
34
|
-
const {
|
|
34
|
+
const {
|
|
35
|
+
code: result,
|
|
36
|
+
nameCache,
|
|
37
|
+
sourceMap
|
|
38
|
+
} = await workerPool.addAsync({
|
|
35
39
|
code,
|
|
36
40
|
options: merge({}, options || {}, defaultOptions)
|
|
37
41
|
});
|
|
@@ -67,6 +71,12 @@ export default function terser(input: Options = {}) {
|
|
|
67
71
|
options.nameCache.props = props;
|
|
68
72
|
}
|
|
69
73
|
|
|
74
|
+
if ((!!defaultOptions.sourceMap || !!options.sourceMap) && isObject(sourceMap)) {
|
|
75
|
+
return {
|
|
76
|
+
code: result,
|
|
77
|
+
map: sourceMap
|
|
78
|
+
};
|
|
79
|
+
}
|
|
70
80
|
return result;
|
|
71
81
|
} catch (e) {
|
|
72
82
|
return Promise.reject(e);
|
package/src/type.ts
CHANGED
package/src/worker.ts
CHANGED
|
@@ -40,6 +40,14 @@ export async function runWorker() {
|
|
|
40
40
|
nameCache: options.nameCache
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
if (typeof result.map === 'string') {
|
|
44
|
+
output.sourceMap = JSON.parse(result.map);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (isObject(result.map)) {
|
|
48
|
+
output.sourceMap = result.map;
|
|
49
|
+
}
|
|
50
|
+
|
|
43
51
|
parentPort.postMessage(output);
|
|
44
52
|
} catch (e) {
|
|
45
53
|
process.exit(1);
|