@jsenv/core 39.3.1 → 39.3.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.
@@ -11561,10 +11561,12 @@ ${reason}`,
11561
11561
  },
11562
11562
  ),
11563
11563
  );
11564
- resolveError.name = "RESOLVE_URL_ERROR";
11565
- resolveError.code = code;
11566
- resolveError.reason = reason;
11567
- resolveError.asResponse = error.asResponse;
11564
+ defineNonEnumerableProperties(resolveError, {
11565
+ name: "RESOLVE_URL_ERROR",
11566
+ code,
11567
+ reason,
11568
+ asResponse: error.asResponse,
11569
+ });
11568
11570
  return resolveError;
11569
11571
  };
11570
11572
  if (error.message === "NO_RESOLVE") {
@@ -11607,16 +11609,14 @@ ${reason}`,
11607
11609
  },
11608
11610
  ),
11609
11611
  );
11610
- fetchError.name = "FETCH_URL_CONTENT_ERROR";
11611
- fetchError.code = code;
11612
- fetchError.reason = reason;
11613
- fetchError.url = urlInfo.url;
11614
- if (code === "PARSE_ERROR") {
11615
- fetchError.trace = error.trace;
11616
- } else {
11617
- fetchError.trace = reference.trace;
11618
- }
11619
- fetchError.asResponse = error.asResponse;
11612
+ defineNonEnumerableProperties(fetchError, {
11613
+ name: "FETCH_URL_CONTENT_ERROR",
11614
+ code,
11615
+ reason,
11616
+ url: urlInfo.url,
11617
+ trace: code === "PARSE_ERROR" ? error.trace : reference.trace,
11618
+ asResponse: error.asResponse,
11619
+ });
11620
11620
  return fetchError;
11621
11621
  };
11622
11622
 
@@ -11723,13 +11723,14 @@ ${error.message}`,
11723
11723
  },
11724
11724
  ),
11725
11725
  );
11726
- transformError.cause = error;
11727
- transformError.name = "TRANSFORM_URL_CONTENT_ERROR";
11728
- transformError.code = "PARSE_ERROR";
11729
- transformError.stack = error.stack;
11730
- transformError.reason = error.message;
11731
- transformError.trace = trace;
11732
- transformError.asResponse = error.asResponse;
11726
+ defineNonEnumerableProperties(transformError, {
11727
+ name: "TRANSFORM_URL_CONTENT_ERROR",
11728
+ code: "PARSE_ERROR",
11729
+ reason: error.message,
11730
+ stack: error.stack,
11731
+ trace,
11732
+ asResponse: error.asResponse,
11733
+ });
11733
11734
  return transformError;
11734
11735
  }
11735
11736
  const createFailedToTransformError = ({
@@ -11751,14 +11752,16 @@ ${reason}`,
11751
11752
  },
11752
11753
  ),
11753
11754
  );
11754
- transformError.cause = error;
11755
- transformError.name = "TRANSFORM_URL_CONTENT_ERROR";
11756
- transformError.code = code;
11757
- transformError.reason = reason;
11758
- transformError.stack = error.stack;
11759
- transformError.url = urlInfo.url;
11760
- transformError.trace = trace;
11761
- transformError.asResponse = error.asResponse;
11755
+ defineNonEnumerableProperties(transformError, {
11756
+ cause: error,
11757
+ name: "TRANSFORM_URL_CONTENT_ERROR",
11758
+ code,
11759
+ reason,
11760
+ stack: error.stack,
11761
+ url: urlInfo.url,
11762
+ trace,
11763
+ asResponse: error.asResponse,
11764
+ });
11762
11765
  return transformError;
11763
11766
  };
11764
11767
  return createFailedToTransformError({
@@ -11784,12 +11787,12 @@ ${reference.trace.message}`,
11784
11787
  },
11785
11788
  ),
11786
11789
  );
11787
- if (error && error instanceof Error) {
11788
- finalizeError.cause = error;
11789
- }
11790
- finalizeError.name = "FINALIZE_URL_CONTENT_ERROR";
11791
- finalizeError.reason = `"finalizeUrlContent" error on "${urlInfo.type}"`;
11792
- finalizeError.asResponse = error.asResponse;
11790
+ defineNonEnumerableProperties(finalizeError, {
11791
+ ...(error && error instanceof Error ? { cause: error } : {}),
11792
+ name: "FINALIZE_URL_CONTENT_ERROR",
11793
+ reason: `"finalizeUrlContent" error on "${urlInfo.type}"`,
11794
+ asResponse: error.asResponse,
11795
+ });
11793
11796
  return finalizeError;
11794
11797
  };
11795
11798
 
@@ -11846,6 +11849,16 @@ const detailsFromValueThrown = (valueThrownByPlugin) => {
11846
11849
  };
11847
11850
  };
11848
11851
 
11852
+ const defineNonEnumerableProperties = (assertionError, properties) => {
11853
+ for (const key of Object.keys(properties)) {
11854
+ Object.defineProperty(assertionError, key, {
11855
+ configurable: true,
11856
+ writable: true,
11857
+ value: properties[key],
11858
+ });
11859
+ }
11860
+ };
11861
+
11849
11862
  const isSupportedAlgorithm = (algo) => {
11850
11863
  return SUPPORTED_ALGORITHMS.includes(algo);
11851
11864
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "39.3.1",
3
+ "version": "39.3.2",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -68,17 +68,17 @@
68
68
  "dependencies": {
69
69
  "@financial-times/polyfill-useragent-normaliser": "1.10.2",
70
70
  "@jsenv/abort": "4.3.0",
71
- "@jsenv/ast": "6.2.15",
71
+ "@jsenv/ast": "6.2.16",
72
72
  "@jsenv/filesystem": "4.10.0",
73
73
  "@jsenv/humanize": "1.2.8",
74
74
  "@jsenv/importmap": "1.2.1",
75
75
  "@jsenv/integrity": "0.0.2",
76
- "@jsenv/js-module-fallback": "1.3.36",
76
+ "@jsenv/js-module-fallback": "1.3.37",
77
77
  "@jsenv/node-esm-resolution": "1.0.2",
78
78
  "@jsenv/plugin-bundling": "2.7.7",
79
79
  "@jsenv/plugin-minification": "1.5.5",
80
- "@jsenv/plugin-supervisor": "1.5.16",
81
- "@jsenv/plugin-transpilation": "1.4.20",
80
+ "@jsenv/plugin-supervisor": "1.5.17",
81
+ "@jsenv/plugin-transpilation": "1.4.21",
82
82
  "@jsenv/runtime-compat": "1.3.1",
83
83
  "@jsenv/server": "15.2.19",
84
84
  "@jsenv/sourcemap": "1.2.23",
@@ -24,10 +24,12 @@ ${reason}`,
24
24
  },
25
25
  ),
26
26
  );
27
- resolveError.name = "RESOLVE_URL_ERROR";
28
- resolveError.code = code;
29
- resolveError.reason = reason;
30
- resolveError.asResponse = error.asResponse;
27
+ defineNonEnumerableProperties(resolveError, {
28
+ name: "RESOLVE_URL_ERROR",
29
+ code,
30
+ reason,
31
+ asResponse: error.asResponse,
32
+ });
31
33
  return resolveError;
32
34
  };
33
35
  if (error.message === "NO_RESOLVE") {
@@ -70,16 +72,14 @@ ${reason}`,
70
72
  },
71
73
  ),
72
74
  );
73
- fetchError.name = "FETCH_URL_CONTENT_ERROR";
74
- fetchError.code = code;
75
- fetchError.reason = reason;
76
- fetchError.url = urlInfo.url;
77
- if (code === "PARSE_ERROR") {
78
- fetchError.trace = error.trace;
79
- } else {
80
- fetchError.trace = reference.trace;
81
- }
82
- fetchError.asResponse = error.asResponse;
75
+ defineNonEnumerableProperties(fetchError, {
76
+ name: "FETCH_URL_CONTENT_ERROR",
77
+ code,
78
+ reason,
79
+ url: urlInfo.url,
80
+ trace: code === "PARSE_ERROR" ? error.trace : reference.trace,
81
+ asResponse: error.asResponse,
82
+ });
83
83
  return fetchError;
84
84
  };
85
85
 
@@ -186,13 +186,14 @@ ${error.message}`,
186
186
  },
187
187
  ),
188
188
  );
189
- transformError.cause = error;
190
- transformError.name = "TRANSFORM_URL_CONTENT_ERROR";
191
- transformError.code = "PARSE_ERROR";
192
- transformError.stack = error.stack;
193
- transformError.reason = error.message;
194
- transformError.trace = trace;
195
- transformError.asResponse = error.asResponse;
189
+ defineNonEnumerableProperties(transformError, {
190
+ name: "TRANSFORM_URL_CONTENT_ERROR",
191
+ code: "PARSE_ERROR",
192
+ reason: error.message,
193
+ stack: error.stack,
194
+ trace,
195
+ asResponse: error.asResponse,
196
+ });
196
197
  return transformError;
197
198
  }
198
199
  const createFailedToTransformError = ({
@@ -214,14 +215,16 @@ ${reason}`,
214
215
  },
215
216
  ),
216
217
  );
217
- transformError.cause = error;
218
- transformError.name = "TRANSFORM_URL_CONTENT_ERROR";
219
- transformError.code = code;
220
- transformError.reason = reason;
221
- transformError.stack = error.stack;
222
- transformError.url = urlInfo.url;
223
- transformError.trace = trace;
224
- transformError.asResponse = error.asResponse;
218
+ defineNonEnumerableProperties(transformError, {
219
+ cause: error,
220
+ name: "TRANSFORM_URL_CONTENT_ERROR",
221
+ code,
222
+ reason,
223
+ stack: error.stack,
224
+ url: urlInfo.url,
225
+ trace,
226
+ asResponse: error.asResponse,
227
+ });
225
228
  return transformError;
226
229
  };
227
230
  return createFailedToTransformError({
@@ -247,12 +250,12 @@ ${reference.trace.message}`,
247
250
  },
248
251
  ),
249
252
  );
250
- if (error && error instanceof Error) {
251
- finalizeError.cause = error;
252
- }
253
- finalizeError.name = "FINALIZE_URL_CONTENT_ERROR";
254
- finalizeError.reason = `"finalizeUrlContent" error on "${urlInfo.type}"`;
255
- finalizeError.asResponse = error.asResponse;
253
+ defineNonEnumerableProperties(finalizeError, {
254
+ ...(error && error instanceof Error ? { cause: error } : {}),
255
+ name: "FINALIZE_URL_CONTENT_ERROR",
256
+ reason: `"finalizeUrlContent" error on "${urlInfo.type}"`,
257
+ asResponse: error.asResponse,
258
+ });
256
259
  return finalizeError;
257
260
  };
258
261
 
@@ -308,3 +311,13 @@ const detailsFromValueThrown = (valueThrownByPlugin) => {
308
311
  error: JSON.stringify(valueThrownByPlugin),
309
312
  };
310
313
  };
314
+
315
+ const defineNonEnumerableProperties = (assertionError, properties) => {
316
+ for (const key of Object.keys(properties)) {
317
+ Object.defineProperty(assertionError, key, {
318
+ configurable: true,
319
+ writable: true,
320
+ value: properties[key],
321
+ });
322
+ }
323
+ };