@tapjs/processinfo 1.0.7 → 1.0.8
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/esm.mjs +31 -0
- package/package.json +2 -2
package/lib/esm.mjs
CHANGED
|
@@ -4,6 +4,34 @@ import { getProcessInfo } from './get-process-info.cjs'
|
|
|
4
4
|
import { getExclude } from './get-exclude.cjs'
|
|
5
5
|
import './cjs.cjs'
|
|
6
6
|
|
|
7
|
+
// on Node v20, loaders are executed in a separate isolated environment
|
|
8
|
+
// As a result, to register coverage and track files, we need to act in
|
|
9
|
+
// the globalPreload function. The load() method posts a message with the
|
|
10
|
+
// filename being loaded, because any registrations that happen in the
|
|
11
|
+
// loader thread will not have any effect.
|
|
12
|
+
// The check for the 'port' being undefined is to allow for support back to
|
|
13
|
+
// 16.12, which had a globalPreload method, but did not have a sendMessage
|
|
14
|
+
// port in that environment.
|
|
15
|
+
let PORT = null
|
|
16
|
+
export const globalPreload = context => {
|
|
17
|
+
const loader = fileURLToPath(import.meta.url)
|
|
18
|
+
const { port } = context || {}
|
|
19
|
+
PORT = port
|
|
20
|
+
return `
|
|
21
|
+
if (typeof port !== 'undefined') {
|
|
22
|
+
const { createRequire } = getBuiltin('module')
|
|
23
|
+
const {pid, ppid} = getBuiltin('process')
|
|
24
|
+
const require = createRequire(${JSON.stringify(loader)})
|
|
25
|
+
const { getProcessInfo } = require('./get-process-info.cjs')
|
|
26
|
+
const { getExclude } = require('./get-exclude.cjs')
|
|
27
|
+
require('./cjs.cjs')
|
|
28
|
+
const processInfo = getProcessInfo()
|
|
29
|
+
port.onmessage = (e) => processInfo.files.push(e.data)
|
|
30
|
+
port.unref()
|
|
31
|
+
}
|
|
32
|
+
`
|
|
33
|
+
}
|
|
34
|
+
|
|
7
35
|
const processInfo = getProcessInfo()
|
|
8
36
|
const exclude = getExclude('_TAPJS_PROCESSINFO_EXCLUDE_')
|
|
9
37
|
|
|
@@ -21,6 +49,9 @@ const myLoad = defaultFn => async (url, context) => {
|
|
|
21
49
|
const filename = fileURLToPath(url)
|
|
22
50
|
if (!exclude.test(filename)) {
|
|
23
51
|
processInfo.files.push(filename)
|
|
52
|
+
if (PORT) {
|
|
53
|
+
PORT.postMessage(filename)
|
|
54
|
+
}
|
|
24
55
|
}
|
|
25
56
|
}
|
|
26
57
|
return defaultFn(url, context, defaultFn)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapjs/processinfo",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"main": "lib/index.cjs",
|
|
5
5
|
"files": [
|
|
6
6
|
"index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"uuid": "^8.3.2"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
|
-
"node": ">=16"
|
|
43
|
+
"node": ">=16.12"
|
|
44
44
|
},
|
|
45
45
|
"license": "ISC",
|
|
46
46
|
"devDependencies": {
|