@parcel/optimizer-terser 2.8.4-nightly.0 → 2.9.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.
@@ -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 _terser() {
19
15
  const data = require("terser");
20
-
21
16
  _terser = 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,
@@ -104,10 +78,10 @@ var _default = new (_plugin().Optimizer)({
104
78
  map
105
79
  };
106
80
  }
107
-
108
81
  let code = await (0, _utils().blobToString)(contents);
109
82
  let originalMap = map ? await map.stringify({}) : null;
110
- let config = { ...userConfig,
83
+ let config = {
84
+ ...userConfig,
111
85
  sourceMap: bundle.env.sourceMap ? {
112
86
  filename: _path().default.relative(options.projectRoot, _path().default.join(bundle.target.distDir, bundle.name)),
113
87
  asObject: true,
@@ -117,7 +91,6 @@ var _default = new (_plugin().Optimizer)({
117
91
  module: bundle.env.outputFormat === 'esmodule'
118
92
  };
119
93
  let result;
120
-
121
94
  try {
122
95
  result = await (0, _terser().minify)(code, config);
123
96
  } catch (error) {
@@ -127,20 +100,16 @@ var _default = new (_plugin().Optimizer)({
127
100
  line,
128
101
  col
129
102
  } = error;
130
-
131
103
  if (line != null && col != null) {
132
104
  message = (0, _diagnostic().escapeMarkdown)(message);
133
105
  let diagnostics = [];
134
106
  let mapping = map === null || map === void 0 ? void 0 : map.findClosestMapping(line, col);
135
-
136
107
  if (mapping && mapping.original && mapping.source) {
137
108
  let {
138
109
  source,
139
110
  original
140
111
  } = mapping;
141
-
142
112
  let filePath = _path().default.resolve(options.projectRoot, source);
143
-
144
113
  diagnostics.push({
145
114
  message,
146
115
  origin: '@parcel/optimizer-terser',
@@ -157,7 +126,6 @@ var _default = new (_plugin().Optimizer)({
157
126
  hints: ["It's likely that Terser doesn't support this syntax yet."]
158
127
  });
159
128
  }
160
-
161
129
  if (diagnostics.length === 0 || options.logLevel === 'verbose') {
162
130
  let loc = {
163
131
  line: line,
@@ -179,7 +147,6 @@ var _default = new (_plugin().Optimizer)({
179
147
  hints: ["It's likely that Terser doesn't support this syntax yet."]
180
148
  });
181
149
  }
182
-
183
150
  throw new (_diagnostic().default)({
184
151
  diagnostic: diagnostics
185
152
  });
@@ -187,27 +154,21 @@ var _default = new (_plugin().Optimizer)({
187
154
  throw error;
188
155
  }
189
156
  }
190
-
191
157
  let sourceMap = null;
192
158
  let minifiedContents = (0, _nullthrows().default)(result.code);
193
159
  let resultMap = result.map;
194
-
195
160
  if (resultMap && typeof resultMap !== 'string') {
196
161
  sourceMap = new (_sourceMap().default)(options.projectRoot);
197
162
  sourceMap.addVLQMap(resultMap);
198
163
  let sourcemapReference = await getSourceMapReference(sourceMap);
199
-
200
164
  if (sourcemapReference) {
201
165
  minifiedContents += `\n//# sourceMappingURL=${sourcemapReference}\n`;
202
166
  }
203
167
  }
204
-
205
168
  return {
206
169
  contents: minifiedContents,
207
170
  map: sourceMap
208
171
  };
209
172
  }
210
-
211
173
  });
212
-
213
174
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/optimizer-terser",
3
- "version": "2.8.4-nightly.0+7b79c6d",
3
+ "version": "2.9.0",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,15 +17,15 @@
17
17
  "source": "src/TerserOptimizer.js",
18
18
  "engines": {
19
19
  "node": ">= 12.0.0",
20
- "parcel": "2.8.4-nightly.0+7b79c6d"
20
+ "parcel": "^2.9.0"
21
21
  },
22
22
  "dependencies": {
23
- "@parcel/diagnostic": "2.8.4-nightly.0+7b79c6d",
24
- "@parcel/plugin": "2.8.4-nightly.0+7b79c6d",
23
+ "@parcel/diagnostic": "2.9.0",
24
+ "@parcel/plugin": "2.9.0",
25
25
  "@parcel/source-map": "^2.1.1",
26
- "@parcel/utils": "2.8.4-nightly.0+7b79c6d",
26
+ "@parcel/utils": "2.9.0",
27
27
  "nullthrows": "^1.1.1",
28
28
  "terser": "^5.2.0"
29
29
  },
30
- "gitHead": "7b79c6d69ffabef89810a8db61e9abdeb70d6990"
30
+ "gitHead": "dd9435be8afed35c5ffc161cf4b586fd6c78fc1f"
31
31
  }