escover 3.1.1 → 3.2.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/ChangeLog CHANGED
@@ -1,3 +1,13 @@
1
+ 2023.05.05, v3.2.0
2
+
3
+ feature:
4
+ - e483c58 escover: add suport of node v20 (https://nodejs.org/dist/latest-v20.x/docs/api/esm.html#globalpreload)
5
+
6
+ 2023.05.05, v3.1.2
7
+
8
+ feature:
9
+ - 520372c escover: improve support of OptionalChaining
10
+
1
11
  2023.05.05, v3.1.1
2
12
 
3
13
  fix:
package/lib/escover.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import process from 'process';
2
+ import montag from 'montag';
2
3
  import {instrument} from './instrument/index.js';
3
4
  import {exit} from './exit.js';
4
5
  import {createFileEntry} from './c4.js';
@@ -23,6 +24,13 @@ const EXCLUDE = [
23
24
  ...exclude,
24
25
  ];
25
26
 
27
+ export function globalPreload({port}) {
28
+ port.onmessage = createFileEntry;
29
+ return montag`
30
+ global.__createC4 = port.postMessage.bind(port);
31
+ `;
32
+ }
33
+
26
34
  export async function load(url, context, defaultLoad) {
27
35
  const {
28
36
  format,
@@ -40,7 +40,23 @@ export const report = () => 'Mark line';
40
40
 
41
41
  const isLoc = (path) => path.node.loc;
42
42
 
43
- const findLoc = (path) => path.find(isLoc).node.loc;
43
+ const findLoc = (path) => {
44
+ const current = path.find(isLoc);
45
+ const {loc} = current.node;
46
+
47
+ if (current.__escover_loc_column) {
48
+ return {
49
+ start: {
50
+ ...loc.start,
51
+ column: ++current.__escover_loc_column,
52
+ },
53
+ };
54
+ }
55
+
56
+ current.__escover_loc_column = 1;
57
+
58
+ return loc;
59
+ };
44
60
 
45
61
  export const fix = (path, {options}) => {
46
62
  const {node} = path;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "3.1.1",
3
+ "version": "3.2.0",
4
4
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
5
  "description": "Coverage for EcmaScript Modules",
6
6
  "main": "lib/escover.js",