@parcel/optimizer-swc 2.8.4-nightly.2921 → 2.8.4-nightly.2937
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/lib/SwcOptimizer.js +0 -42
- package/package.json +6 -6
package/lib/SwcOptimizer.js
CHANGED
|
@@ -4,83 +4,58 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
function _nullthrows() {
|
|
9
8
|
const data = _interopRequireDefault(require("nullthrows"));
|
|
10
|
-
|
|
11
9
|
_nullthrows = function () {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _core() {
|
|
19
15
|
const data = require("@swc/core");
|
|
20
|
-
|
|
21
16
|
_core = function () {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
function _plugin() {
|
|
29
22
|
const data = require("@parcel/plugin");
|
|
30
|
-
|
|
31
23
|
_plugin = function () {
|
|
32
24
|
return data;
|
|
33
25
|
};
|
|
34
|
-
|
|
35
26
|
return data;
|
|
36
27
|
}
|
|
37
|
-
|
|
38
28
|
function _utils() {
|
|
39
29
|
const data = require("@parcel/utils");
|
|
40
|
-
|
|
41
30
|
_utils = function () {
|
|
42
31
|
return data;
|
|
43
32
|
};
|
|
44
|
-
|
|
45
33
|
return data;
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
function _sourceMap() {
|
|
49
36
|
const data = _interopRequireDefault(require("@parcel/source-map"));
|
|
50
|
-
|
|
51
37
|
_sourceMap = function () {
|
|
52
38
|
return data;
|
|
53
39
|
};
|
|
54
|
-
|
|
55
40
|
return data;
|
|
56
41
|
}
|
|
57
|
-
|
|
58
42
|
function _diagnostic() {
|
|
59
43
|
const data = _interopRequireWildcard(require("@parcel/diagnostic"));
|
|
60
|
-
|
|
61
44
|
_diagnostic = function () {
|
|
62
45
|
return data;
|
|
63
46
|
};
|
|
64
|
-
|
|
65
47
|
return data;
|
|
66
48
|
}
|
|
67
|
-
|
|
68
49
|
function _path() {
|
|
69
50
|
const data = _interopRequireDefault(require("path"));
|
|
70
|
-
|
|
71
51
|
_path = function () {
|
|
72
52
|
return data;
|
|
73
53
|
};
|
|
74
|
-
|
|
75
54
|
return data;
|
|
76
55
|
}
|
|
77
|
-
|
|
78
56
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
79
|
-
|
|
80
57
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
81
|
-
|
|
82
58
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
83
|
-
|
|
84
59
|
var _default = new (_plugin().Optimizer)({
|
|
85
60
|
async loadConfig({
|
|
86
61
|
config,
|
|
@@ -89,7 +64,6 @@ var _default = new (_plugin().Optimizer)({
|
|
|
89
64
|
let userConfig = await config.getConfigFrom(_path().default.join(options.projectRoot, 'index'), ['.terserrc', '.terserrc.js', '.terserrc.cjs', '.terserrc.mjs']);
|
|
90
65
|
return userConfig === null || userConfig === void 0 ? void 0 : userConfig.contents;
|
|
91
66
|
},
|
|
92
|
-
|
|
93
67
|
async optimize({
|
|
94
68
|
contents,
|
|
95
69
|
map: originalMap,
|
|
@@ -104,10 +78,8 @@ var _default = new (_plugin().Optimizer)({
|
|
|
104
78
|
map: originalMap
|
|
105
79
|
};
|
|
106
80
|
}
|
|
107
|
-
|
|
108
81
|
let code = await (0, _utils().blobToString)(contents);
|
|
109
82
|
let result;
|
|
110
|
-
|
|
111
83
|
try {
|
|
112
84
|
result = await (0, _core().transform)(code, {
|
|
113
85
|
jsc: {
|
|
@@ -129,20 +101,16 @@ var _default = new (_plugin().Optimizer)({
|
|
|
129
101
|
// SWC doesn't give us nice error objects, so we need to parse the message.
|
|
130
102
|
let message = (0, _diagnostic().escapeMarkdown)(((0, _utils().stripAnsi)(err.message).split('\n').find(line => line.trim().length > 0) || '').trim().replace(/^(×|x)\s+/, ''));
|
|
131
103
|
let location = err.message.match(/(?:╭─|,-)\[(\d+):(\d+)\]/);
|
|
132
|
-
|
|
133
104
|
if (location) {
|
|
134
105
|
let line = Number(location[1]);
|
|
135
106
|
let col = Number(location[1]);
|
|
136
107
|
let mapping = originalMap === null || originalMap === void 0 ? void 0 : originalMap.findClosestMapping(line, col);
|
|
137
|
-
|
|
138
108
|
if (mapping && mapping.original && mapping.source) {
|
|
139
109
|
let {
|
|
140
110
|
source,
|
|
141
111
|
original
|
|
142
112
|
} = mapping;
|
|
143
|
-
|
|
144
113
|
let filePath = _path().default.resolve(options.projectRoot, source);
|
|
145
|
-
|
|
146
114
|
throw new (_diagnostic().default)({
|
|
147
115
|
diagnostic: {
|
|
148
116
|
message,
|
|
@@ -158,7 +126,6 @@ var _default = new (_plugin().Optimizer)({
|
|
|
158
126
|
}
|
|
159
127
|
});
|
|
160
128
|
}
|
|
161
|
-
|
|
162
129
|
let loc = {
|
|
163
130
|
line: line,
|
|
164
131
|
column: col
|
|
@@ -179,35 +146,26 @@ var _default = new (_plugin().Optimizer)({
|
|
|
179
146
|
}
|
|
180
147
|
});
|
|
181
148
|
}
|
|
182
|
-
|
|
183
149
|
throw err;
|
|
184
150
|
}
|
|
185
|
-
|
|
186
151
|
let sourceMap = null;
|
|
187
152
|
let minifiedContents = (0, _nullthrows().default)(result.code);
|
|
188
153
|
let resultMap = result.map;
|
|
189
|
-
|
|
190
154
|
if (resultMap) {
|
|
191
155
|
sourceMap = new (_sourceMap().default)(options.projectRoot);
|
|
192
156
|
sourceMap.addVLQMap(JSON.parse(resultMap));
|
|
193
|
-
|
|
194
157
|
if (originalMap) {
|
|
195
158
|
sourceMap.extends(originalMap);
|
|
196
159
|
}
|
|
197
|
-
|
|
198
160
|
let sourcemapReference = await getSourceMapReference(sourceMap);
|
|
199
|
-
|
|
200
161
|
if (sourcemapReference) {
|
|
201
162
|
minifiedContents += `\n//# sourceMappingURL=${sourcemapReference}\n`;
|
|
202
163
|
}
|
|
203
164
|
}
|
|
204
|
-
|
|
205
165
|
return {
|
|
206
166
|
contents: minifiedContents,
|
|
207
167
|
map: sourceMap
|
|
208
168
|
};
|
|
209
169
|
}
|
|
210
|
-
|
|
211
170
|
});
|
|
212
|
-
|
|
213
171
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/optimizer-swc",
|
|
3
|
-
"version": "2.8.4-nightly.
|
|
3
|
+
"version": "2.8.4-nightly.2937+3ad435157",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"source": "src/SwcOptimizer.js",
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">= 12.0.0",
|
|
20
|
-
"parcel": "2.0.0-nightly.
|
|
20
|
+
"parcel": "2.0.0-nightly.1312+3ad435157"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@parcel/diagnostic": "2.0.0-nightly.
|
|
24
|
-
"@parcel/plugin": "2.0.0-nightly.
|
|
23
|
+
"@parcel/diagnostic": "2.0.0-nightly.1314+3ad435157",
|
|
24
|
+
"@parcel/plugin": "2.0.0-nightly.1314+3ad435157",
|
|
25
25
|
"@parcel/source-map": "^2.1.1",
|
|
26
|
-
"@parcel/utils": "2.0.0-nightly.
|
|
26
|
+
"@parcel/utils": "2.0.0-nightly.1314+3ad435157",
|
|
27
27
|
"@swc/core": "^1.3.36",
|
|
28
28
|
"nullthrows": "^1.1.1"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "3ad435157d443da806c215d68ccf292b4e95ae0c"
|
|
31
31
|
}
|