@jsenv/core 24.3.1 → 24.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.
- package/{LICENSE → license} +0 -0
- package/package.json +3 -4
- package/src/execute.js +7 -10
- package/src/internal/browser_launcher/browser_runtime_report.js +75 -0
- package/src/internal/browser_launcher/executeHtmlFile.js +10 -16
- package/src/internal/compiling/startCompileServer.js +3 -0
- package/src/internal/executing/executeConcurrently.js +5 -4
- package/src/internal/executing/executePlan.js +1 -2
- package/src/internal/node_launcher/node_runtime_report.js +71 -0
- package/src/launchBrowser.js +9 -0
- package/src/launchNode.js +5 -2
package/{LICENSE → license}
RENAMED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "24.3.
|
|
3
|
+
"version": "24.3.2",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
"node": ">=14.9.0"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
14
|
-
"access": "public"
|
|
15
|
-
"registry": "https://registry.npmjs.org"
|
|
14
|
+
"access": "public"
|
|
16
15
|
},
|
|
17
16
|
"type": "module",
|
|
18
17
|
"exports": {
|
|
@@ -142,4 +141,4 @@
|
|
|
142
141
|
"redux": "4.1.2",
|
|
143
142
|
"rollup-plugin-import-assert": "1.1.1"
|
|
144
143
|
}
|
|
145
|
-
}
|
|
144
|
+
}
|
package/src/execute.js
CHANGED
|
@@ -88,11 +88,7 @@ export const execute = async ({
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
try {
|
|
91
|
-
const {
|
|
92
|
-
outDirectoryRelativeUrl,
|
|
93
|
-
origin: compileServerOrigin,
|
|
94
|
-
stop,
|
|
95
|
-
} = await startCompileServer({
|
|
91
|
+
const compileServer = await startCompileServer({
|
|
96
92
|
signal: executeOperation.signal,
|
|
97
93
|
logLevel: compileServerLogLevel,
|
|
98
94
|
|
|
@@ -117,7 +113,7 @@ export const execute = async ({
|
|
|
117
113
|
compileServerCanWriteOnFilesystem,
|
|
118
114
|
})
|
|
119
115
|
executeOperation.addEndCallback(async () => {
|
|
120
|
-
await stop("execution done")
|
|
116
|
+
await compileServer.stop("execution done")
|
|
121
117
|
})
|
|
122
118
|
|
|
123
119
|
const result = await launchAndExecute({
|
|
@@ -127,8 +123,9 @@ export const execute = async ({
|
|
|
127
123
|
runtime,
|
|
128
124
|
runtimeParams: {
|
|
129
125
|
projectDirectoryUrl,
|
|
130
|
-
compileServerOrigin,
|
|
131
|
-
|
|
126
|
+
compileServerOrigin: compileServer.origin,
|
|
127
|
+
compileServerId: compileServer.id,
|
|
128
|
+
outDirectoryRelativeUrl: compileServer.outDirectoryRelativeUrl,
|
|
132
129
|
...runtimeParams,
|
|
133
130
|
},
|
|
134
131
|
executeParams: {
|
|
@@ -155,8 +152,8 @@ export const execute = async ({
|
|
|
155
152
|
})
|
|
156
153
|
|
|
157
154
|
if (collectCompileServerInfo) {
|
|
158
|
-
result.
|
|
159
|
-
result.
|
|
155
|
+
result.compileServerOrigin = compileServer.origin
|
|
156
|
+
result.outDirectoryRelativeUrl = compileServer.outDirectoryRelativeUrl
|
|
160
157
|
}
|
|
161
158
|
|
|
162
159
|
if (result.status === "errored") {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export const getBrowserRuntimeReport = async ({
|
|
2
|
+
page,
|
|
3
|
+
coverageHandledFromOutside,
|
|
4
|
+
runtime,
|
|
5
|
+
compileServerId,
|
|
6
|
+
}) => {
|
|
7
|
+
const cache = cacheFromParams({
|
|
8
|
+
runtime,
|
|
9
|
+
compileServerId,
|
|
10
|
+
coverageHandledFromOutside,
|
|
11
|
+
})
|
|
12
|
+
const entry = cache.read()
|
|
13
|
+
if (entry) {
|
|
14
|
+
return entry
|
|
15
|
+
}
|
|
16
|
+
const browserRuntimeFeaturesReport = await page.evaluate(
|
|
17
|
+
/* istanbul ignore next */
|
|
18
|
+
async ({ coverageHandledFromOutside }) => {
|
|
19
|
+
// eslint-disable-next-line no-undef
|
|
20
|
+
await window.readyPromise
|
|
21
|
+
|
|
22
|
+
// eslint-disable-next-line no-undef
|
|
23
|
+
return window.scanBrowserRuntimeFeatures({
|
|
24
|
+
coverageHandledFromOutside,
|
|
25
|
+
failFastOnFeatureDetection: true,
|
|
26
|
+
})
|
|
27
|
+
},
|
|
28
|
+
{ coverageHandledFromOutside },
|
|
29
|
+
)
|
|
30
|
+
cache.write(browserRuntimeFeaturesReport)
|
|
31
|
+
return browserRuntimeFeaturesReport
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let currentCacheParams
|
|
35
|
+
let currentCacheValue
|
|
36
|
+
const cacheFromParams = ({
|
|
37
|
+
runtime,
|
|
38
|
+
compileServerId,
|
|
39
|
+
coverageHandledFromOutside,
|
|
40
|
+
}) => {
|
|
41
|
+
const params = {
|
|
42
|
+
compileServerId,
|
|
43
|
+
coverageHandledFromOutside,
|
|
44
|
+
}
|
|
45
|
+
const runtimeLabel = `${runtime.name}/${runtime.version}`
|
|
46
|
+
|
|
47
|
+
if (!currentCacheParams) {
|
|
48
|
+
currentCacheParams = params
|
|
49
|
+
currentCacheValue = {}
|
|
50
|
+
return {
|
|
51
|
+
read: () => null,
|
|
52
|
+
write: (value) => {
|
|
53
|
+
currentCacheValue[runtimeLabel] = value
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (JSON.stringify(currentCacheParams) !== JSON.stringify(params)) {
|
|
59
|
+
return {
|
|
60
|
+
read: () => null,
|
|
61
|
+
write: (value) => {
|
|
62
|
+
currentCacheParams = params
|
|
63
|
+
currentCacheValue = {}
|
|
64
|
+
currentCacheValue[runtimeLabel] = value
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
read: () => currentCacheValue[runtimeLabel],
|
|
71
|
+
write: (value) => {
|
|
72
|
+
currentCacheValue[runtimeLabel] = value
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -10,13 +10,16 @@ import { filterV8Coverage } from "@jsenv/core/src/internal/executing/coverage_ut
|
|
|
10
10
|
import { composeTwoFileByFileIstanbulCoverages } from "@jsenv/core/src/internal/executing/coverage_utils/istanbul_coverage_composition.js"
|
|
11
11
|
import { evalSource } from "../node_runtime/evalSource.js"
|
|
12
12
|
import { escapeRegexpSpecialCharacters } from "../escapeRegexpSpecialCharacters.js"
|
|
13
|
+
import { getBrowserRuntimeReport } from "./browser_runtime_report.js"
|
|
13
14
|
|
|
14
15
|
export const executeHtmlFile = async (
|
|
15
16
|
fileRelativeUrl,
|
|
16
17
|
{
|
|
18
|
+
runtime,
|
|
17
19
|
executeOperation,
|
|
18
20
|
projectDirectoryUrl,
|
|
19
21
|
compileServerOrigin,
|
|
22
|
+
compileServerId,
|
|
20
23
|
outDirectoryRelativeUrl,
|
|
21
24
|
page,
|
|
22
25
|
|
|
@@ -48,25 +51,16 @@ export const executeHtmlFile = async (
|
|
|
48
51
|
)
|
|
49
52
|
executeOperation.throwIfAborted()
|
|
50
53
|
await page.goto(compileProxyClientUrl)
|
|
54
|
+
executeOperation.throwIfAborted()
|
|
51
55
|
|
|
52
56
|
const coverageHandledFromOutside =
|
|
53
57
|
coveragePlaywrightAPIAvailable && !coverageForceIstanbul
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
await window.readyPromise
|
|
61
|
-
|
|
62
|
-
// eslint-disable-next-line no-undef
|
|
63
|
-
return window.scanBrowserRuntimeFeatures({
|
|
64
|
-
coverageHandledFromOutside,
|
|
65
|
-
failFastOnFeatureDetection: true,
|
|
66
|
-
})
|
|
67
|
-
},
|
|
68
|
-
{ coverageHandledFromOutside },
|
|
69
|
-
)
|
|
58
|
+
const browserRuntimeFeaturesReport = await getBrowserRuntimeReport({
|
|
59
|
+
page,
|
|
60
|
+
coverageHandledFromOutside,
|
|
61
|
+
compileServerId,
|
|
62
|
+
runtime,
|
|
63
|
+
})
|
|
70
64
|
|
|
71
65
|
try {
|
|
72
66
|
let executionResult
|
|
@@ -51,6 +51,8 @@ import { createCompiledFileService } from "./createCompiledFileService.js"
|
|
|
51
51
|
import { urlIsCompilationAsset } from "./compile-directory/compile-asset.js"
|
|
52
52
|
import { createTransformHtmlSourceFileService } from "./html_source_file_service.js"
|
|
53
53
|
|
|
54
|
+
let compileServerId = 0
|
|
55
|
+
|
|
54
56
|
export const startCompileServer = async ({
|
|
55
57
|
signal = new AbortController().signal,
|
|
56
58
|
handleSIGINT,
|
|
@@ -389,6 +391,7 @@ export const startCompileServer = async ({
|
|
|
389
391
|
})
|
|
390
392
|
|
|
391
393
|
return {
|
|
394
|
+
id: compileServerId++,
|
|
392
395
|
jsenvDirectoryRelativeUrl,
|
|
393
396
|
outDirectoryRelativeUrl,
|
|
394
397
|
...compileServer,
|
|
@@ -27,8 +27,7 @@ export const executeConcurrently = async (
|
|
|
27
27
|
launchAndExecuteLogLevel,
|
|
28
28
|
|
|
29
29
|
projectDirectoryUrl,
|
|
30
|
-
|
|
31
|
-
outDirectoryRelativeUrl,
|
|
30
|
+
compileServer,
|
|
32
31
|
|
|
33
32
|
babelPluginMap,
|
|
34
33
|
|
|
@@ -206,8 +205,10 @@ export const executeConcurrently = async (
|
|
|
206
205
|
coverageTempDirectoryUrl,
|
|
207
206
|
runtimeParams: {
|
|
208
207
|
projectDirectoryUrl,
|
|
209
|
-
compileServerOrigin,
|
|
210
|
-
|
|
208
|
+
compileServerOrigin: compileServer.origin,
|
|
209
|
+
compileServerId: compileServer.id,
|
|
210
|
+
outDirectoryRelativeUrl: compileServer.outDirectoryRelativeUrl,
|
|
211
|
+
|
|
211
212
|
collectCoverage: coverage,
|
|
212
213
|
coverageIgnorePredicate,
|
|
213
214
|
coverageForceIstanbul,
|
|
@@ -146,8 +146,7 @@ export const executePlan = async (
|
|
|
146
146
|
launchAndExecuteLogLevel,
|
|
147
147
|
|
|
148
148
|
projectDirectoryUrl,
|
|
149
|
-
|
|
150
|
-
outDirectoryRelativeUrl: compileServer.outDirectoryRelativeUrl,
|
|
149
|
+
compileServer,
|
|
151
150
|
|
|
152
151
|
// not sure we actually have to pass import params to executeConcurrently
|
|
153
152
|
importResolutionMethod,
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { scanNodeRuntimeFeatures } from "@jsenv/core/src/internal/node_feature_detection/node_feature_detection.js"
|
|
2
|
+
|
|
3
|
+
export const getNodeRuntimeReport = async ({
|
|
4
|
+
runtime,
|
|
5
|
+
compileServerId,
|
|
6
|
+
compileServerOrigin,
|
|
7
|
+
outDirectoryRelativeUrl,
|
|
8
|
+
coverageHandledFromOutside,
|
|
9
|
+
}) => {
|
|
10
|
+
const cache = cacheFromParams({
|
|
11
|
+
runtime,
|
|
12
|
+
compileServerId,
|
|
13
|
+
compileServerOrigin,
|
|
14
|
+
outDirectoryRelativeUrl,
|
|
15
|
+
coverageHandledFromOutside,
|
|
16
|
+
})
|
|
17
|
+
const entry = cache.read()
|
|
18
|
+
if (entry) {
|
|
19
|
+
return entry
|
|
20
|
+
}
|
|
21
|
+
const nodeRuntimeFeaturesReport = await scanNodeRuntimeFeatures({
|
|
22
|
+
compileServerOrigin,
|
|
23
|
+
outDirectoryRelativeUrl,
|
|
24
|
+
coverageHandledFromOutside,
|
|
25
|
+
})
|
|
26
|
+
cache.write(nodeRuntimeFeaturesReport)
|
|
27
|
+
return nodeRuntimeFeaturesReport
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let currentCacheParams
|
|
31
|
+
let currentCacheValue
|
|
32
|
+
const cacheFromParams = ({
|
|
33
|
+
compileServerId,
|
|
34
|
+
compileServerOrigin,
|
|
35
|
+
outDirectoryRelativeUrl,
|
|
36
|
+
coverageHandledFromOutside,
|
|
37
|
+
}) => {
|
|
38
|
+
const params = {
|
|
39
|
+
compileServerId,
|
|
40
|
+
compileServerOrigin,
|
|
41
|
+
outDirectoryRelativeUrl,
|
|
42
|
+
coverageHandledFromOutside,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!currentCacheParams) {
|
|
46
|
+
currentCacheParams = params
|
|
47
|
+
return {
|
|
48
|
+
read: () => null,
|
|
49
|
+
write: (value) => {
|
|
50
|
+
currentCacheValue = value
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (JSON.stringify(currentCacheParams) !== JSON.stringify(params)) {
|
|
56
|
+
return {
|
|
57
|
+
read: () => null,
|
|
58
|
+
write: (value) => {
|
|
59
|
+
currentCacheParams = params
|
|
60
|
+
currentCacheValue = value
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
read: () => currentCacheValue,
|
|
67
|
+
write: (value) => {
|
|
68
|
+
currentCacheValue = value
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/launchBrowser.js
CHANGED
|
@@ -32,6 +32,7 @@ chromiumRuntime.launch = async ({
|
|
|
32
32
|
|
|
33
33
|
projectDirectoryUrl,
|
|
34
34
|
compileServerOrigin,
|
|
35
|
+
compileServerId,
|
|
35
36
|
outDirectoryRelativeUrl,
|
|
36
37
|
|
|
37
38
|
collectPerformance,
|
|
@@ -106,10 +107,12 @@ chromiumRuntime.launch = async ({
|
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
const browserHooks = browserToRuntimeHooks(browser, {
|
|
110
|
+
runtime: chromiumRuntime,
|
|
109
111
|
browserServerLogLevel,
|
|
110
112
|
|
|
111
113
|
projectDirectoryUrl,
|
|
112
114
|
compileServerOrigin,
|
|
115
|
+
compileServerId,
|
|
113
116
|
outDirectoryRelativeUrl,
|
|
114
117
|
|
|
115
118
|
collectPerformance,
|
|
@@ -184,6 +187,7 @@ firefoxRuntime.launch = async ({
|
|
|
184
187
|
const browser = await browserPromise
|
|
185
188
|
|
|
186
189
|
const browserHooks = browserToRuntimeHooks(browser, {
|
|
190
|
+
runtime: firefoxRuntime,
|
|
187
191
|
launchBrowserOperation,
|
|
188
192
|
browserServerLogLevel,
|
|
189
193
|
|
|
@@ -262,6 +266,7 @@ webkitRuntime.launch = async ({
|
|
|
262
266
|
const browser = await browserPromise
|
|
263
267
|
|
|
264
268
|
const browserHooks = browserToRuntimeHooks(browser, {
|
|
269
|
+
runtime: webkitRuntime,
|
|
265
270
|
launchBrowserOperation,
|
|
266
271
|
browserServerLogLevel,
|
|
267
272
|
|
|
@@ -391,8 +396,10 @@ const stopBrowser = async (browser) => {
|
|
|
391
396
|
const browserToRuntimeHooks = (
|
|
392
397
|
browser,
|
|
393
398
|
{
|
|
399
|
+
runtime,
|
|
394
400
|
projectDirectoryUrl,
|
|
395
401
|
compileServerOrigin,
|
|
402
|
+
compileServerId,
|
|
396
403
|
outDirectoryRelativeUrl,
|
|
397
404
|
|
|
398
405
|
collectPerformance,
|
|
@@ -461,10 +468,12 @@ const browserToRuntimeHooks = (
|
|
|
461
468
|
stoppedCallbackList.add(stopTrackingToNotify)
|
|
462
469
|
|
|
463
470
|
const result = await executeHtmlFile(fileRelativeUrl, {
|
|
471
|
+
runtime,
|
|
464
472
|
executeOperation,
|
|
465
473
|
|
|
466
474
|
projectDirectoryUrl,
|
|
467
475
|
compileServerOrigin,
|
|
476
|
+
compileServerId,
|
|
468
477
|
outDirectoryRelativeUrl,
|
|
469
478
|
|
|
470
479
|
page,
|
package/src/launchNode.js
CHANGED
|
@@ -4,7 +4,7 @@ import { loggerToLogLevel } from "@jsenv/logger"
|
|
|
4
4
|
import { jsenvCoreDirectoryUrl } from "@jsenv/core/src/internal/jsenvCoreDirectoryUrl.js"
|
|
5
5
|
import { escapeRegexpSpecialCharacters } from "./internal/escapeRegexpSpecialCharacters.js"
|
|
6
6
|
import { createControllableNodeProcess } from "./internal/node_launcher/createControllableNodeProcess.js"
|
|
7
|
-
import {
|
|
7
|
+
import { getNodeRuntimeReport } from "./internal/node_launcher/node_runtime_report.js"
|
|
8
8
|
|
|
9
9
|
export const nodeRuntime = {
|
|
10
10
|
name: "node",
|
|
@@ -16,6 +16,7 @@ nodeRuntime.launch = async ({
|
|
|
16
16
|
logProcessCommand,
|
|
17
17
|
|
|
18
18
|
projectDirectoryUrl,
|
|
19
|
+
compileServerId,
|
|
19
20
|
compileServerOrigin,
|
|
20
21
|
outDirectoryRelativeUrl,
|
|
21
22
|
|
|
@@ -115,7 +116,9 @@ nodeRuntime.launch = async ({
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
// the computation of runtime features can be cached
|
|
118
|
-
const nodeFeatures = await
|
|
119
|
+
const nodeFeatures = await getNodeRuntimeReport({
|
|
120
|
+
runtime: nodeRuntime,
|
|
121
|
+
compileServerId,
|
|
119
122
|
compileServerOrigin,
|
|
120
123
|
outDirectoryRelativeUrl,
|
|
121
124
|
// https://nodejs.org/docs/latest-v15.x/api/cli.html#cli_node_v8_coverage_dir
|