escover 3.8.0 → 4.0.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,17 @@
1
+ 2023.12.10, v4.0.0
2
+
3
+ feature:
4
+ - c365383 convert to node v18 loaders
5
+ - cc25857 escover: drop support of node < 18
6
+ - 7cc297d escover: madrun v10.0.0
7
+ - 3513811 escover: putout v34.0.0
8
+
9
+ 2023.11.09, v3.8.1
10
+
11
+ feature:
12
+ - c5ac532 escover: putout v33.0.0
13
+ - c3b1022 escover: eslint-plugin-putout v21.0.2
14
+
1
15
  2023.10.02, v3.8.0
2
16
 
3
17
  feature:
package/lib/cli/cli.js CHANGED
@@ -10,7 +10,7 @@ const noop = () => {};
10
10
 
11
11
  const {ESCOVER_FORMAT} = process.env;
12
12
 
13
- export const ESCOVER_NODE_OPTIONS = '--no-warnings --loader zenload';
13
+ export const ESCOVER_NODE_OPTIONS = '--no-warnings --import escover/register --import mock-import/register';
14
14
 
15
15
  export const cli = ({argv, exit, readCoverage}) => {
16
16
  const args = yargsParser(argv.slice(2), {
@@ -50,11 +50,17 @@ export const cli = ({argv, exit, readCoverage}) => {
50
50
 
51
51
  export const isSuccess = (error) => !error || error?.status === Number(process.env.ESCOVER_SUCCESS_EXIT_CODE);
52
52
 
53
+ export function createZenload() {
54
+ return {
55
+ ZENLOAD: 'escover,mock-import',
56
+ }
57
+ }
58
+
53
59
  function execute(cmd, exit) {
54
60
  const [error] = tryCatch(execSync, cmd, {
55
61
  stdio: [0, 1, 2],
56
62
  env: {
57
- ZENLOAD: 'escover,mock-import',
63
+ ...createZenload,
58
64
  ...process.env,
59
65
  NODE_OPTIONS: ESCOVER_NODE_OPTIONS,
60
66
  },
package/lib/escover.js CHANGED
@@ -23,7 +23,7 @@ const EXCLUDE = [
23
23
  ...exclude,
24
24
  ];
25
25
 
26
- export function globalPreload({port}) {
26
+ export function initialize({port}) {
27
27
  port.onmessage = ({data}) => {
28
28
  const {
29
29
  type,
@@ -46,33 +46,6 @@ export function globalPreload({port}) {
46
46
 
47
47
  writeCoverage();
48
48
  };
49
-
50
- return `(${escover})();`;
51
- }
52
-
53
- function escover() {
54
- const loader = 'escover';
55
-
56
- global.__createC4 = (url) => ({
57
- '🧨': (line, column) => {
58
- port.postMessage({
59
- type: 'set',
60
- url,
61
- line,
62
- column,
63
- loader,
64
- });
65
- },
66
- 'init': (line, column) => {
67
- port.postMessage({
68
- type: 'init',
69
- url,
70
- line,
71
- column,
72
- loader,
73
- });
74
- },
75
- });
76
49
  }
77
50
 
78
51
  export async function load(url, context, defaultLoad) {
@@ -109,6 +82,7 @@ export async function load(url, context, defaultLoad) {
109
82
  return {
110
83
  format,
111
84
  source,
85
+ shortCircuit: true,
112
86
  };
113
87
  }
114
88
 
package/lib/fresh.js ADDED
@@ -0,0 +1,30 @@
1
+ import {
2
+ fileURLToPath,
3
+ pathToFileURL,
4
+ } from 'node:url';
5
+ import assert from 'node:assert';
6
+ import {register} from 'node:module';
7
+ import {MessageChannel} from 'node:worker_threads';
8
+
9
+ // This example showcases how a message channel can be used to communicate
10
+ // between the main (application) thread and the hooks running on the hooks
11
+ // thread, by sending `port2` to the `initialize` hook.
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ // This example showcases how a message channel can be used to communicate
14
+ // between the main (application) thread and the hooks running on the hooks
15
+ // thread, by sending `port2` to the `initialize` hook.
16
+ const {port1, port2} = new MessageChannel();
17
+
18
+ port1.on('message', (msg) => {
19
+ assert.strictEqual(msg, 'increment: 2');
20
+ });
21
+
22
+ register('./escover.js', {
23
+ parentURL: pathToFileURL(__filename),
24
+ data: {
25
+ number: 1,
26
+ port: port2,
27
+ },
28
+ transferList: [port2],
29
+ });
30
+
@@ -0,0 +1,40 @@
1
+ import {pathToFileURL} from 'node:url';
2
+ import { register } from 'node:module';
3
+ import { MessageChannel } from 'node:worker_threads';
4
+
5
+ const { port1, port2 } = new MessageChannel();
6
+
7
+ initialize({
8
+ port: port1
9
+ });
10
+
11
+ register('./escover.js', import.meta.url, {
12
+ parentURL: import.meta.url,
13
+ data: { port: port2 },
14
+ transferList: [port2],
15
+ });
16
+
17
+ function initialize({port}) {
18
+ const loader = 'escover';
19
+
20
+ global.__createC4 = (url) => ({
21
+ '🧨': (line, column) => {
22
+ port.postMessage({
23
+ type: 'set',
24
+ url,
25
+ line,
26
+ column,
27
+ loader,
28
+ });
29
+ },
30
+ 'init': (line, column) => {
31
+ port.postMessage({
32
+ type: 'init',
33
+ url,
34
+ line,
35
+ column,
36
+ loader,
37
+ });
38
+ },
39
+ });
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "3.8.0",
3
+ "version": "4.0.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",
@@ -16,6 +16,8 @@
16
16
  ".": {
17
17
  "import": "./lib/escover.js"
18
18
  },
19
+ "./fresh": "./lib/fresh.js",
20
+ "./register": "./lib/register.js",
19
21
  "./plugin": "./lib/instrument/plugin-mark/index.js",
20
22
  "./instrument": "./lib/instrument/index.js"
21
23
  },
@@ -47,7 +49,7 @@
47
49
  "montag": "^1.2.1",
48
50
  "once": "^1.4.0",
49
51
  "picomatch": "^2.3.1",
50
- "putout": "^32.0.0",
52
+ "putout": "^34.0.0",
51
53
  "strip-ansi": "^7.0.1",
52
54
  "table": "^6.8.0",
53
55
  "try-catch": "^3.0.0",
@@ -55,7 +57,7 @@
55
57
  "zenload": "^2.0.0"
56
58
  },
57
59
  "engines": {
58
- "node": ">=16"
60
+ "node": ">=18"
59
61
  },
60
62
  "license": "MIT",
61
63
  "devDependencies": {
@@ -64,8 +66,8 @@
64
66
  "escover": "^3.2.0",
65
67
  "eslint": "^8.3.0",
66
68
  "eslint-plugin-n": "^16.0.0",
67
- "eslint-plugin-putout": "^20.0.0",
68
- "madrun": "^9.0.0",
69
+ "eslint-plugin-putout": "^21.0.2",
70
+ "madrun": "^10.0.0",
69
71
  "supertape": "^8.0.1"
70
72
  }
71
73
  }