@jsenv/core 27.3.0 → 27.3.3
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/dist/controllable_child_process.mjs +1 -0
- package/dist/controllable_worker_thread.mjs +1 -0
- package/dist/js/execute_using_dynamic_import.js +5 -3
- package/dist/main.js +165 -133
- package/package.json +2 -2
- package/src/build/build.js +2 -2
- package/src/build/graph_utils.js +14 -11
- package/src/execute/run.js +27 -28
- package/src/execute/runtimes/browsers/from_playwright.js +90 -92
- package/src/execute/runtimes/node/execute_using_dynamic_import.js +8 -2
- package/src/execute/runtimes/node/node_child_process.js +2 -0
- package/src/execute/runtimes/node/node_worker_thread.js +13 -2
- package/src/omega/url_graph/url_graph_report.js +2 -4
- package/src/omega/url_graph.js +23 -16
- package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_server.js +1 -2
- package/src/plugins/bundling/js_module/bundle_js_module.js +0 -1
- package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +1 -2
- package/src/plugins/url_analysis/js/js_urls.js +0 -9
- package/src/test/coverage/report_to_coverage.js +16 -11
- package/src/test/execute_plan.js +3 -2
- package/src/test/execute_test_plan.js +3 -1
package/dist/main.js
CHANGED
|
@@ -9,6 +9,7 @@ import net, { createServer } from "node:net";
|
|
|
9
9
|
import { Readable, Stream, Writable } from "node:stream";
|
|
10
10
|
import { Http2ServerResponse } from "node:http2";
|
|
11
11
|
import { createReadStream, readdirSync, statSync, readFile as readFile$1, chmod, stat, lstat, readdir, promises, unlink, openSync, closeSync, rmdir, readFileSync as readFileSync$1, watch, writeFile as writeFile$1, writeFileSync as writeFileSync$1, mkdirSync, existsSync, realpathSync } from "node:fs";
|
|
12
|
+
import { lookup } from "node:dns";
|
|
12
13
|
import { performance } from "node:perf_hooks";
|
|
13
14
|
import { extname, dirname, basename } from "node:path";
|
|
14
15
|
import { pathToFileURL, fileURLToPath } from "node:url";
|
|
@@ -2653,15 +2654,32 @@ const statusIsClientError = status => status >= 400 && status < 500;
|
|
|
2653
2654
|
|
|
2654
2655
|
const statusIsServerError = status => status >= 500 && status < 600;
|
|
2655
2656
|
|
|
2656
|
-
const
|
|
2657
|
+
const applyDnsResolution = async hostname => {
|
|
2658
|
+
const dnsResolution = await new Promise((resolve, reject) => {
|
|
2659
|
+
lookup(hostname, (error, address, family) => {
|
|
2660
|
+
if (error) {
|
|
2661
|
+
reject(error);
|
|
2662
|
+
} else {
|
|
2663
|
+
resolve({
|
|
2664
|
+
address,
|
|
2665
|
+
family
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
2668
|
+
});
|
|
2669
|
+
});
|
|
2670
|
+
return dnsResolution;
|
|
2671
|
+
};
|
|
2672
|
+
|
|
2673
|
+
const getServerOrigins = async ({
|
|
2657
2674
|
protocol,
|
|
2658
2675
|
ip,
|
|
2659
2676
|
port
|
|
2660
2677
|
}) => {
|
|
2661
2678
|
const isInternalIp = ip === "127.0.0.1";
|
|
2679
|
+
const localhostDnsResolution = await applyDnsResolution("localhost");
|
|
2662
2680
|
const internalOrigin = createServerOrigin({
|
|
2663
2681
|
protocol,
|
|
2664
|
-
hostname: "localhost",
|
|
2682
|
+
hostname: localhostDnsResolution.address === "127.0.0.1" ? "localhost" : "127.0.0.1",
|
|
2665
2683
|
port
|
|
2666
2684
|
});
|
|
2667
2685
|
|
|
@@ -3536,7 +3554,7 @@ const startServer = async ({
|
|
|
3536
3554
|
};
|
|
3537
3555
|
|
|
3538
3556
|
status = "opened";
|
|
3539
|
-
const serverOrigins = getServerOrigins({
|
|
3557
|
+
const serverOrigins = await getServerOrigins({
|
|
3540
3558
|
protocol,
|
|
3541
3559
|
ip,
|
|
3542
3560
|
port
|
|
@@ -8452,22 +8470,11 @@ const parseAndTransformJsUrls = async (urlInfo, context) => {
|
|
|
8452
8470
|
} = context;
|
|
8453
8471
|
const actions = [];
|
|
8454
8472
|
const magicSource = createMagicSource(urlInfo.content);
|
|
8455
|
-
urlInfo.data.usesImport = false;
|
|
8456
|
-
urlInfo.data.usesExport = false;
|
|
8457
|
-
urlInfo.data.usesImportAssertion = false;
|
|
8458
8473
|
jsMentions.forEach(jsMention => {
|
|
8459
|
-
if (jsMention.assert) {
|
|
8460
|
-
urlInfo.data.usesImportAssertion = true;
|
|
8461
|
-
}
|
|
8462
|
-
|
|
8463
8474
|
if (jsMention.subtype === "import_static" || jsMention.subtype === "import_dynamic") {
|
|
8464
8475
|
urlInfo.data.usesImport = true;
|
|
8465
8476
|
}
|
|
8466
8477
|
|
|
8467
|
-
if (jsMention.subtype === "export") {
|
|
8468
|
-
urlInfo.data.usesExport = true;
|
|
8469
|
-
}
|
|
8470
|
-
|
|
8471
8478
|
const [reference] = referenceUtils.found({
|
|
8472
8479
|
type: jsMention.type,
|
|
8473
8480
|
subtype: jsMention.subtype,
|
|
@@ -10909,9 +10916,7 @@ const jsenvPluginNodeEsmResolution = ({
|
|
|
10909
10916
|
const onFileChange = () => {
|
|
10910
10917
|
packageScopesCache.clear();
|
|
10911
10918
|
packageJsonsCache.clear();
|
|
10912
|
-
|
|
10913
|
-
const urlInfo = urlGraph.getUrlInfo(url);
|
|
10914
|
-
|
|
10919
|
+
urlGraph.urlInfoMap.forEach(urlInfo => {
|
|
10915
10920
|
if (urlInfo.dependsOnPackageJson) {
|
|
10916
10921
|
urlGraph.considerModified(urlInfo);
|
|
10917
10922
|
}
|
|
@@ -19320,8 +19325,7 @@ const rollupPluginJsenv = ({
|
|
|
19320
19325
|
data: {
|
|
19321
19326
|
generatedBy: "rollup",
|
|
19322
19327
|
bundleRelativeUrl: rollupFileInfo.fileName,
|
|
19323
|
-
usesImport: rollupFileInfo.imports.length > 0 || rollupFileInfo.dynamicImports.length > 0
|
|
19324
|
-
usesExport: rollupFileInfo.exports.length > 0
|
|
19328
|
+
usesImport: rollupFileInfo.imports.length > 0 || rollupFileInfo.dynamicImports.length > 0
|
|
19325
19329
|
},
|
|
19326
19330
|
contentType: "text/javascript",
|
|
19327
19331
|
content: rollupFileInfo.code,
|
|
@@ -20320,8 +20324,6 @@ const jsenvPluginDevSSEServer = ({
|
|
|
20320
20324
|
};
|
|
20321
20325
|
|
|
20322
20326
|
const propagateUpdate = firstUrlInfo => {
|
|
20323
|
-
const urlInfos = urlGraph.urlInfos;
|
|
20324
|
-
|
|
20325
20327
|
const iterate = (urlInfo, trace) => {
|
|
20326
20328
|
if (urlInfo.data.hotAcceptSelf) {
|
|
20327
20329
|
return {
|
|
@@ -20341,7 +20343,7 @@ const jsenvPluginDevSSEServer = ({
|
|
|
20341
20343
|
const instructions = [];
|
|
20342
20344
|
|
|
20343
20345
|
for (const dependentUrl of dependents) {
|
|
20344
|
-
const dependentUrlInfo =
|
|
20346
|
+
const dependentUrlInfo = urlGraph.getUrlInfo(dependentUrl);
|
|
20345
20347
|
|
|
20346
20348
|
if (dependentUrlInfo.data.hotDecline) {
|
|
20347
20349
|
return {
|
|
@@ -20704,15 +20706,15 @@ const createUrlGraph = ({
|
|
|
20704
20706
|
clientFileChangeCallbackList,
|
|
20705
20707
|
clientFilesPruneCallbackList
|
|
20706
20708
|
} = {}) => {
|
|
20707
|
-
const
|
|
20709
|
+
const urlInfoMap = new Map();
|
|
20708
20710
|
|
|
20709
|
-
const getUrlInfo = url =>
|
|
20711
|
+
const getUrlInfo = url => urlInfoMap.get(url);
|
|
20710
20712
|
|
|
20711
20713
|
const deleteUrlInfo = url => {
|
|
20712
|
-
const urlInfo =
|
|
20714
|
+
const urlInfo = urlInfoMap.get(url);
|
|
20713
20715
|
|
|
20714
20716
|
if (urlInfo) {
|
|
20715
|
-
delete
|
|
20717
|
+
urlInfoMap.delete(url);
|
|
20716
20718
|
|
|
20717
20719
|
if (urlInfo.sourcemapReference) {
|
|
20718
20720
|
deleteUrlInfo(urlInfo.sourcemapReference.url);
|
|
@@ -20721,15 +20723,15 @@ const createUrlGraph = ({
|
|
|
20721
20723
|
};
|
|
20722
20724
|
|
|
20723
20725
|
const reuseOrCreateUrlInfo = url => {
|
|
20724
|
-
const existingUrlInfo =
|
|
20726
|
+
const existingUrlInfo = getUrlInfo(url);
|
|
20725
20727
|
if (existingUrlInfo) return existingUrlInfo;
|
|
20726
20728
|
const urlInfo = createUrlInfo(url);
|
|
20727
|
-
|
|
20729
|
+
urlInfoMap.set(url, urlInfo);
|
|
20728
20730
|
return urlInfo;
|
|
20729
20731
|
};
|
|
20730
20732
|
|
|
20731
20733
|
const inferReference = (specifier, parentUrl) => {
|
|
20732
|
-
const parentUrlInfo =
|
|
20734
|
+
const parentUrlInfo = getUrlInfo(parentUrl);
|
|
20733
20735
|
|
|
20734
20736
|
if (!parentUrlInfo) {
|
|
20735
20737
|
return null;
|
|
@@ -20742,7 +20744,7 @@ const createUrlGraph = ({
|
|
|
20742
20744
|
};
|
|
20743
20745
|
|
|
20744
20746
|
const findDependent = (url, predicate) => {
|
|
20745
|
-
const urlInfo =
|
|
20747
|
+
const urlInfo = getUrlInfo(url);
|
|
20746
20748
|
|
|
20747
20749
|
if (!urlInfo) {
|
|
20748
20750
|
return null;
|
|
@@ -20750,7 +20752,7 @@ const createUrlGraph = ({
|
|
|
20750
20752
|
|
|
20751
20753
|
const visitDependents = urlInfo => {
|
|
20752
20754
|
for (const dependentUrl of urlInfo.dependents) {
|
|
20753
|
-
const dependent =
|
|
20755
|
+
const dependent = getUrlInfo(dependentUrl);
|
|
20754
20756
|
|
|
20755
20757
|
if (predicate(dependent)) {
|
|
20756
20758
|
return dependent;
|
|
@@ -20800,7 +20802,7 @@ const createUrlGraph = ({
|
|
|
20800
20802
|
const removeDependencies = (urlInfo, urlsToPrune) => {
|
|
20801
20803
|
urlsToPrune.forEach(urlToPrune => {
|
|
20802
20804
|
urlInfo.dependencies.delete(urlToPrune);
|
|
20803
|
-
const dependency =
|
|
20805
|
+
const dependency = getUrlInfo(urlToPrune);
|
|
20804
20806
|
|
|
20805
20807
|
if (!dependency) {
|
|
20806
20808
|
return;
|
|
@@ -20840,7 +20842,7 @@ const createUrlGraph = ({
|
|
|
20840
20842
|
clientFileChangeCallbackList.push(({
|
|
20841
20843
|
url
|
|
20842
20844
|
}) => {
|
|
20843
|
-
const urlInfo =
|
|
20845
|
+
const urlInfo = getUrlInfo(url);
|
|
20844
20846
|
|
|
20845
20847
|
if (urlInfo) {
|
|
20846
20848
|
considerModified(urlInfo, Date.now());
|
|
@@ -20860,7 +20862,7 @@ const createUrlGraph = ({
|
|
|
20860
20862
|
urlInfo.modifiedTimestamp = modifiedTimestamp;
|
|
20861
20863
|
urlInfo.contentEtag = undefined;
|
|
20862
20864
|
urlInfo.dependents.forEach(dependentUrl => {
|
|
20863
|
-
const dependentUrlInfo =
|
|
20865
|
+
const dependentUrlInfo = getUrlInfo(dependentUrl);
|
|
20864
20866
|
const {
|
|
20865
20867
|
hotAcceptDependencies = []
|
|
20866
20868
|
} = dependentUrlInfo.data;
|
|
@@ -20890,7 +20892,7 @@ const createUrlGraph = ({
|
|
|
20890
20892
|
};
|
|
20891
20893
|
|
|
20892
20894
|
return {
|
|
20893
|
-
|
|
20895
|
+
urlInfoMap,
|
|
20894
20896
|
reuseOrCreateUrlInfo,
|
|
20895
20897
|
getUrlInfo,
|
|
20896
20898
|
deleteUrlInfo,
|
|
@@ -20899,13 +20901,20 @@ const createUrlGraph = ({
|
|
|
20899
20901
|
updateReferences,
|
|
20900
20902
|
considerModified,
|
|
20901
20903
|
getRelatedUrlInfos,
|
|
20904
|
+
toObject: () => {
|
|
20905
|
+
const data = {};
|
|
20906
|
+
urlInfoMap.forEach(urlInfo => {
|
|
20907
|
+
data[urlInfo.url] = urlInfo;
|
|
20908
|
+
});
|
|
20909
|
+
return data;
|
|
20910
|
+
},
|
|
20902
20911
|
toJSON: rootDirectoryUrl => {
|
|
20903
20912
|
const data = {};
|
|
20904
|
-
|
|
20905
|
-
const dependencyUrls = Array.from(
|
|
20913
|
+
urlInfoMap.forEach(urlInfo => {
|
|
20914
|
+
const dependencyUrls = Array.from(urlInfo.dependencies);
|
|
20906
20915
|
|
|
20907
20916
|
if (dependencyUrls.length) {
|
|
20908
|
-
const relativeUrl = urlToRelativeUrl(url, rootDirectoryUrl);
|
|
20917
|
+
const relativeUrl = urlToRelativeUrl(urlInfo.url, rootDirectoryUrl);
|
|
20909
20918
|
data[relativeUrl] = dependencyUrls.map(dependencyUrl => urlToRelativeUrl(dependencyUrl, rootDirectoryUrl));
|
|
20910
20919
|
}
|
|
20911
20920
|
});
|
|
@@ -23985,7 +23994,7 @@ const reportToCoverage = async (report, {
|
|
|
23985
23994
|
// coverDescription will generate empty coverage for files
|
|
23986
23995
|
// that were suppose to be coverage but were not.
|
|
23987
23996
|
if (executionResult.status === "completed" && executionResult.type === "node" && coverageMethodForNodeJs !== "NODE_V8_COVERAGE") {
|
|
23988
|
-
logger.warn(`
|
|
23997
|
+
logger.warn(`"${executionName}" execution of ${file} did not properly write coverage into ${executionResult.coverageFileUrl}`);
|
|
23989
23998
|
}
|
|
23990
23999
|
}
|
|
23991
24000
|
});
|
|
@@ -24066,17 +24075,22 @@ const getCoverageFromReport = async ({
|
|
|
24066
24075
|
const {
|
|
24067
24076
|
coverageFileUrl
|
|
24068
24077
|
} = executionResultForFileOnRuntime;
|
|
24078
|
+
let executionCoverage;
|
|
24069
24079
|
|
|
24070
|
-
|
|
24071
|
-
|
|
24072
|
-
|
|
24073
|
-
|
|
24074
|
-
|
|
24075
|
-
|
|
24076
|
-
|
|
24077
|
-
|
|
24080
|
+
try {
|
|
24081
|
+
executionCoverage = JSON.parse(String(readFileSync$1(new URL(coverageFileUrl))));
|
|
24082
|
+
} catch (e) {
|
|
24083
|
+
if (e.code === "ENOENT" || e.name === "SyntaxError") {
|
|
24084
|
+
onMissing({
|
|
24085
|
+
executionName,
|
|
24086
|
+
file,
|
|
24087
|
+
executionResult: executionResultForFileOnRuntime
|
|
24088
|
+
});
|
|
24089
|
+
return;
|
|
24090
|
+
}
|
|
24078
24091
|
|
|
24079
|
-
|
|
24092
|
+
throw e;
|
|
24093
|
+
}
|
|
24080
24094
|
|
|
24081
24095
|
if (isV8Coverage(executionCoverage)) {
|
|
24082
24096
|
v8Coverage = v8Coverage ? composeTwoV8Coverages(v8Coverage, executionCoverage) : executionCoverage;
|
|
@@ -24109,7 +24123,7 @@ const run = async ({
|
|
|
24109
24123
|
runtime,
|
|
24110
24124
|
runtimeParams
|
|
24111
24125
|
}) => {
|
|
24112
|
-
|
|
24126
|
+
const result = {};
|
|
24113
24127
|
const callbacks = [];
|
|
24114
24128
|
const onConsoleRef = {
|
|
24115
24129
|
current: () => {}
|
|
@@ -24127,18 +24141,14 @@ const run = async ({
|
|
|
24127
24141
|
const timeoutAbortSource = runOperation.timeout(allocatedMs);
|
|
24128
24142
|
callbacks.push(() => {
|
|
24129
24143
|
if (result.status === "errored" && Abort.isAbortError(result.error) && timeoutAbortSource.signal.aborted) {
|
|
24130
|
-
result =
|
|
24131
|
-
status: "timedout"
|
|
24132
|
-
};
|
|
24144
|
+
result.status = "timedout";
|
|
24133
24145
|
}
|
|
24134
24146
|
});
|
|
24135
24147
|
}
|
|
24136
24148
|
|
|
24137
24149
|
callbacks.push(() => {
|
|
24138
24150
|
if (result.status === "errored" && Abort.isAbortError(result.error)) {
|
|
24139
|
-
result =
|
|
24140
|
-
status: "aborted"
|
|
24141
|
-
};
|
|
24151
|
+
result.status = "aborted";
|
|
24142
24152
|
}
|
|
24143
24153
|
});
|
|
24144
24154
|
const consoleCalls = [];
|
|
@@ -24167,6 +24177,22 @@ const run = async ({
|
|
|
24167
24177
|
callbacks.push(() => {
|
|
24168
24178
|
result.consoleCalls = consoleCalls;
|
|
24169
24179
|
});
|
|
24180
|
+
} // we do not keep coverage in memory, it can grow very big
|
|
24181
|
+
// instead we store it on the filesystem
|
|
24182
|
+
// and they can be read later at "coverageFileUrl"
|
|
24183
|
+
|
|
24184
|
+
|
|
24185
|
+
let coverageFileUrl;
|
|
24186
|
+
|
|
24187
|
+
if (coverageEnabled) {
|
|
24188
|
+
coverageFileUrl = new URL(`./${runtime.name}/${cuid()}.json`, coverageTempDirectoryUrl).href;
|
|
24189
|
+
await ensureParentDirectories(coverageFileUrl);
|
|
24190
|
+
|
|
24191
|
+
if (coverageEnabled) {
|
|
24192
|
+
result.coverageFileUrl = coverageFileUrl; // written within the child_process/worker_thread or during runtime.run()
|
|
24193
|
+
// for browsers
|
|
24194
|
+
// (because it takes time to serialize and transfer the coverage object)
|
|
24195
|
+
}
|
|
24170
24196
|
}
|
|
24171
24197
|
|
|
24172
24198
|
const startMs = Date.now();
|
|
@@ -24191,7 +24217,9 @@ const run = async ({
|
|
|
24191
24217
|
signal: runOperation.signal,
|
|
24192
24218
|
logger,
|
|
24193
24219
|
...runtimeParams,
|
|
24220
|
+
collectConsole,
|
|
24194
24221
|
collectPerformance,
|
|
24222
|
+
coverageFileUrl,
|
|
24195
24223
|
keepRunning,
|
|
24196
24224
|
stopSignal,
|
|
24197
24225
|
onConsole: log => onConsoleRef.current(log)
|
|
@@ -24216,8 +24244,7 @@ const run = async ({
|
|
|
24216
24244
|
status,
|
|
24217
24245
|
namespace,
|
|
24218
24246
|
error,
|
|
24219
|
-
performance
|
|
24220
|
-
coverage
|
|
24247
|
+
performance
|
|
24221
24248
|
} = winner.data;
|
|
24222
24249
|
result.status = status;
|
|
24223
24250
|
|
|
@@ -24231,27 +24258,13 @@ const run = async ({
|
|
|
24231
24258
|
result.performance = performance;
|
|
24232
24259
|
}
|
|
24233
24260
|
|
|
24234
|
-
if (coverageEnabled) {
|
|
24235
|
-
if (coverage) {
|
|
24236
|
-
// we do not keep coverage in memory, it can grow very big
|
|
24237
|
-
// instead we store it on the filesystem
|
|
24238
|
-
// and they can be read later at "coverageFileUrl"
|
|
24239
|
-
const coverageFileUrl = new URL(`./${runtime.name}/${cuid()}.json`, coverageTempDirectoryUrl);
|
|
24240
|
-
writeFileSync(coverageFileUrl, JSON.stringify(coverage, null, " "));
|
|
24241
|
-
result.coverageFileUrl = coverageFileUrl.href;
|
|
24242
|
-
} else {// will eventually log a warning in report_to_coverage.js
|
|
24243
|
-
}
|
|
24244
|
-
}
|
|
24245
|
-
|
|
24246
24261
|
callbacks.forEach(callback => {
|
|
24247
24262
|
callback();
|
|
24248
24263
|
});
|
|
24249
24264
|
return result;
|
|
24250
24265
|
} catch (e) {
|
|
24251
|
-
result =
|
|
24252
|
-
|
|
24253
|
-
error: e
|
|
24254
|
-
};
|
|
24266
|
+
result.status = "errored";
|
|
24267
|
+
result.error = e;
|
|
24255
24268
|
callbacks.forEach(callback => {
|
|
24256
24269
|
callback();
|
|
24257
24270
|
});
|
|
@@ -24749,7 +24762,7 @@ const executePlan = async (plan, {
|
|
|
24749
24762
|
} else {
|
|
24750
24763
|
coverageMethodForNodeJs = "Profiler";
|
|
24751
24764
|
logger.warn(createDetailedMessage$1(`process.env.NODE_V8_COVERAGE is required to generate coverage for Node.js subprocesses`, {
|
|
24752
|
-
"suggestion": `
|
|
24765
|
+
"suggestion": `set process.env.NODE_V8_COVERAGE`,
|
|
24753
24766
|
"suggestion 2": `use coverageMethodForNodeJs: "Profiler". But it means coverage for child_process and worker_thread cannot be collected`
|
|
24754
24767
|
}));
|
|
24755
24768
|
}
|
|
@@ -24827,7 +24840,7 @@ const executePlan = async (plan, {
|
|
|
24827
24840
|
getCustomBabelPlugins: ({
|
|
24828
24841
|
clientRuntimeCompat
|
|
24829
24842
|
}) => {
|
|
24830
|
-
if (coverageEnabled && Object.keys(clientRuntimeCompat)[0] !== "chrome") {
|
|
24843
|
+
if (coverageEnabled && (coverageMethodForBrowsers !== "playwright_api" || Object.keys(clientRuntimeCompat)[0] !== "chrome")) {
|
|
24831
24844
|
return {
|
|
24832
24845
|
"transform-instrument": [babelPluginInstrument, {
|
|
24833
24846
|
rootDirectoryUrl,
|
|
@@ -25251,8 +25264,7 @@ const executeTestPlan = async ({
|
|
|
25251
25264
|
},
|
|
25252
25265
|
coverageIncludeMissing = true,
|
|
25253
25266
|
coverageAndExecutionAllowed = false,
|
|
25254
|
-
coverageMethodForNodeJs = "NODE_V8_COVERAGE",
|
|
25255
|
-
// "Profiler" also accepted
|
|
25267
|
+
coverageMethodForNodeJs = process.env.NODE_V8_COVERAGE ? "NODE_V8_COVERAGE" : "Profiler",
|
|
25256
25268
|
coverageMethodForBrowsers = "playwright_api",
|
|
25257
25269
|
// "istanbul" also accepted
|
|
25258
25270
|
coverageV8ConflictWarning = true,
|
|
@@ -25490,6 +25502,7 @@ const createRuntimeFromPlaywright = ({
|
|
|
25490
25502
|
coverageEnabled = false,
|
|
25491
25503
|
coverageConfig,
|
|
25492
25504
|
coverageMethodForBrowsers,
|
|
25505
|
+
coverageFileUrl,
|
|
25493
25506
|
stopAfterAllSignal,
|
|
25494
25507
|
stopSignal,
|
|
25495
25508
|
keepRunning,
|
|
@@ -25572,13 +25585,14 @@ const createRuntimeFromPlaywright = ({
|
|
|
25572
25585
|
}
|
|
25573
25586
|
};
|
|
25574
25587
|
|
|
25575
|
-
|
|
25588
|
+
const result = {};
|
|
25589
|
+
const callbacks = [];
|
|
25576
25590
|
|
|
25577
25591
|
if (coverageEnabled) {
|
|
25578
25592
|
if (coveragePlaywrightAPIAvailable && coverageMethodForBrowsers === "playwright_api") {
|
|
25579
25593
|
await page.coverage.startJSCoverage({// reportAnonymousScripts: true,
|
|
25580
25594
|
});
|
|
25581
|
-
|
|
25595
|
+
callbacks.push(async () => {
|
|
25582
25596
|
const v8CoveragesWithWebUrls = await page.coverage.stopJSCoverage(); // we convert urls starting with http:// to file:// because we later
|
|
25583
25597
|
// convert the url to filesystem path in istanbulCoverageFromV8Coverage function
|
|
25584
25598
|
|
|
@@ -25599,23 +25613,20 @@ const createRuntimeFromPlaywright = ({
|
|
|
25599
25613
|
rootDirectoryUrl,
|
|
25600
25614
|
coverageConfig
|
|
25601
25615
|
});
|
|
25602
|
-
|
|
25603
|
-
coverage
|
|
25604
|
-
};
|
|
25616
|
+
writeFileSync$1(new URL(coverageFileUrl), JSON.stringify(coverage, null, " "));
|
|
25605
25617
|
});
|
|
25606
25618
|
} else {
|
|
25607
|
-
|
|
25619
|
+
callbacks.push(() => {
|
|
25608
25620
|
const scriptExecutionResults = result.namespace;
|
|
25609
25621
|
|
|
25610
25622
|
if (scriptExecutionResults) {
|
|
25611
|
-
|
|
25623
|
+
const coverage = generateCoverageForPage(scriptExecutionResults) || {};
|
|
25624
|
+
writeFileSync$1(new URL(coverageFileUrl), JSON.stringify(coverage, null, " "));
|
|
25612
25625
|
}
|
|
25613
|
-
|
|
25614
|
-
return result;
|
|
25615
25626
|
});
|
|
25616
25627
|
}
|
|
25617
25628
|
} else {
|
|
25618
|
-
|
|
25629
|
+
callbacks.push(() => {
|
|
25619
25630
|
const scriptExecutionResults = result.namespace;
|
|
25620
25631
|
|
|
25621
25632
|
if (scriptExecutionResults) {
|
|
@@ -25623,13 +25634,11 @@ const createRuntimeFromPlaywright = ({
|
|
|
25623
25634
|
delete scriptExecutionResults[fileRelativeUrl].coverage;
|
|
25624
25635
|
});
|
|
25625
25636
|
}
|
|
25626
|
-
|
|
25627
|
-
return result;
|
|
25628
25637
|
});
|
|
25629
25638
|
}
|
|
25630
25639
|
|
|
25631
25640
|
if (collectPerformance) {
|
|
25632
|
-
|
|
25641
|
+
callbacks.push(async () => {
|
|
25633
25642
|
const performance = await page.evaluate(
|
|
25634
25643
|
/* eslint-disable no-undef */
|
|
25635
25644
|
|
|
@@ -25658,7 +25667,6 @@ const createRuntimeFromPlaywright = ({
|
|
|
25658
25667
|
/* eslint-enable no-undef */
|
|
25659
25668
|
);
|
|
25660
25669
|
result.performance = performance;
|
|
25661
|
-
return result;
|
|
25662
25670
|
});
|
|
25663
25671
|
}
|
|
25664
25672
|
|
|
@@ -25752,7 +25760,7 @@ const createRuntimeFromPlaywright = ({
|
|
|
25752
25760
|
await page.goto(fileClientUrl, {
|
|
25753
25761
|
timeout: 0
|
|
25754
25762
|
});
|
|
25755
|
-
const
|
|
25763
|
+
const returnValue = await page.evaluate(
|
|
25756
25764
|
/* eslint-disable no-undef */
|
|
25757
25765
|
|
|
25758
25766
|
/* istanbul ignore next */
|
|
@@ -25768,12 +25776,12 @@ const createRuntimeFromPlaywright = ({
|
|
|
25768
25776
|
const {
|
|
25769
25777
|
status,
|
|
25770
25778
|
scriptExecutionResults
|
|
25771
|
-
} =
|
|
25779
|
+
} = returnValue;
|
|
25772
25780
|
|
|
25773
25781
|
if (status === "errored") {
|
|
25774
25782
|
const {
|
|
25775
25783
|
exceptionSource
|
|
25776
|
-
} =
|
|
25784
|
+
} = returnValue;
|
|
25777
25785
|
const error = evalException(exceptionSource, {
|
|
25778
25786
|
rootDirectoryUrl,
|
|
25779
25787
|
server,
|
|
@@ -25824,16 +25832,32 @@ const createRuntimeFromPlaywright = ({
|
|
|
25824
25832
|
return winner.data;
|
|
25825
25833
|
};
|
|
25826
25834
|
|
|
25827
|
-
let result;
|
|
25828
|
-
|
|
25829
25835
|
try {
|
|
25830
|
-
|
|
25831
|
-
|
|
25836
|
+
const {
|
|
25837
|
+
status,
|
|
25838
|
+
error,
|
|
25839
|
+
namespace,
|
|
25840
|
+
performance
|
|
25841
|
+
} = await getResult();
|
|
25842
|
+
result.status = status;
|
|
25843
|
+
|
|
25844
|
+
if (status === "errored") {
|
|
25845
|
+
result.error = error;
|
|
25846
|
+
} else {
|
|
25847
|
+
result.namespace = namespace;
|
|
25848
|
+
}
|
|
25849
|
+
|
|
25850
|
+
if (collectPerformance) {
|
|
25851
|
+
result.performance = performance;
|
|
25852
|
+
}
|
|
25853
|
+
|
|
25854
|
+
await callbacks.reduce(async (previous, callback) => {
|
|
25855
|
+
await previous;
|
|
25856
|
+
await callback();
|
|
25857
|
+
}, Promise.resolve());
|
|
25832
25858
|
} catch (e) {
|
|
25833
|
-
result =
|
|
25834
|
-
|
|
25835
|
-
error: e
|
|
25836
|
-
};
|
|
25859
|
+
result.status = "errored";
|
|
25860
|
+
result.error = e;
|
|
25837
25861
|
}
|
|
25838
25862
|
|
|
25839
25863
|
if (keepRunning) {
|
|
@@ -25951,13 +25975,6 @@ const isTargetClosedError = error => {
|
|
|
25951
25975
|
return false;
|
|
25952
25976
|
};
|
|
25953
25977
|
|
|
25954
|
-
const composeTransformer = (previousTransformer, transformer) => {
|
|
25955
|
-
return async value => {
|
|
25956
|
-
const transformedValue = await previousTransformer(value);
|
|
25957
|
-
return transformer(transformedValue);
|
|
25958
|
-
};
|
|
25959
|
-
};
|
|
25960
|
-
|
|
25961
25978
|
const extractTextFromConsoleMessage = consoleMessage => {
|
|
25962
25979
|
return consoleMessage.text(); // ensure we use a string so that istanbul won't try
|
|
25963
25980
|
// to put any coverage statement inside it
|
|
@@ -26367,6 +26384,7 @@ nodeChildProcess.run = async ({
|
|
|
26367
26384
|
coverageEnabled = false,
|
|
26368
26385
|
coverageConfig,
|
|
26369
26386
|
coverageMethodForNodeJs,
|
|
26387
|
+
coverageFileUrl,
|
|
26370
26388
|
collectPerformance,
|
|
26371
26389
|
env,
|
|
26372
26390
|
debugPort,
|
|
@@ -26530,6 +26548,7 @@ nodeChildProcess.run = async ({
|
|
|
26530
26548
|
coverageEnabled,
|
|
26531
26549
|
coverageConfig,
|
|
26532
26550
|
coverageMethodForNodeJs,
|
|
26551
|
+
coverageFileUrl,
|
|
26533
26552
|
exitAfterAction: true
|
|
26534
26553
|
}
|
|
26535
26554
|
}
|
|
@@ -26710,10 +26729,12 @@ nodeWorkerThread.run = async ({
|
|
|
26710
26729
|
keepRunning,
|
|
26711
26730
|
stopSignal,
|
|
26712
26731
|
onConsole,
|
|
26732
|
+
collectConsole = false,
|
|
26733
|
+
collectPerformance,
|
|
26734
|
+
coverageEnabled = false,
|
|
26713
26735
|
coverageConfig,
|
|
26714
26736
|
coverageMethodForNodeJs,
|
|
26715
|
-
|
|
26716
|
-
collectPerformance,
|
|
26737
|
+
coverageFileUrl,
|
|
26717
26738
|
env,
|
|
26718
26739
|
debugPort,
|
|
26719
26740
|
debugMode,
|
|
@@ -26777,6 +26798,16 @@ nodeWorkerThread.run = async ({
|
|
|
26777
26798
|
onceWorkerThreadMessage(workerThread, "ready", resolve);
|
|
26778
26799
|
});
|
|
26779
26800
|
const stop = memoize(async () => {
|
|
26801
|
+
// read all stdout before terminating
|
|
26802
|
+
// (no need for stderr because it's sync)
|
|
26803
|
+
if (collectConsole) {
|
|
26804
|
+
while (workerThread.stdout.read() !== null) {}
|
|
26805
|
+
|
|
26806
|
+
await new Promise(resolve => {
|
|
26807
|
+
setTimeout(resolve, 50);
|
|
26808
|
+
});
|
|
26809
|
+
}
|
|
26810
|
+
|
|
26780
26811
|
await workerThread.terminate();
|
|
26781
26812
|
});
|
|
26782
26813
|
const winnerPromise = new Promise(resolve => {
|
|
@@ -26816,6 +26847,7 @@ nodeWorkerThread.run = async ({
|
|
|
26816
26847
|
coverageEnabled,
|
|
26817
26848
|
coverageConfig,
|
|
26818
26849
|
coverageMethodForNodeJs,
|
|
26850
|
+
coverageFileUrl,
|
|
26819
26851
|
exitAfterAction: true
|
|
26820
26852
|
}
|
|
26821
26853
|
}
|
|
@@ -27073,9 +27105,6 @@ ${createRepartitionMessage(graphReport)}
|
|
|
27073
27105
|
};
|
|
27074
27106
|
|
|
27075
27107
|
const createUrlGraphReport = urlGraph => {
|
|
27076
|
-
const {
|
|
27077
|
-
urlInfos
|
|
27078
|
-
} = urlGraph;
|
|
27079
27108
|
const countGroups = {
|
|
27080
27109
|
sourcemaps: 0,
|
|
27081
27110
|
html: 0,
|
|
@@ -27094,15 +27123,14 @@ const createUrlGraphReport = urlGraph => {
|
|
|
27094
27123
|
other: 0,
|
|
27095
27124
|
total: 0
|
|
27096
27125
|
};
|
|
27097
|
-
|
|
27098
|
-
if (url.startsWith("data:")) {
|
|
27126
|
+
urlGraph.urlInfoMap.forEach(urlInfo => {
|
|
27127
|
+
if (urlInfo.url.startsWith("data:")) {
|
|
27099
27128
|
return;
|
|
27100
|
-
}
|
|
27101
|
-
|
|
27102
|
-
const urlInfo = urlInfos[url]; // ignore:
|
|
27129
|
+
} // ignore:
|
|
27103
27130
|
// - inline files: they are already taken into account in the file where they appear
|
|
27104
27131
|
// - ignored files: we don't know their content
|
|
27105
27132
|
|
|
27133
|
+
|
|
27106
27134
|
if (urlInfo.isInline || !urlInfo.shouldHandle) {
|
|
27107
27135
|
return;
|
|
27108
27136
|
} // file loaded via import assertion are already inside the graph
|
|
@@ -27280,20 +27308,18 @@ const createRepartitionMessage = ({
|
|
|
27280
27308
|
|
|
27281
27309
|
const GRAPH = {
|
|
27282
27310
|
map: (graph, callback) => {
|
|
27283
|
-
|
|
27284
|
-
|
|
27311
|
+
const array = [];
|
|
27312
|
+
graph.urlInfoMap.forEach(urlInfo => {
|
|
27313
|
+
array.push(callback(urlInfo));
|
|
27285
27314
|
});
|
|
27315
|
+
return array;
|
|
27286
27316
|
},
|
|
27287
27317
|
forEach: (graph, callback) => {
|
|
27288
|
-
|
|
27289
|
-
callback(graph.urlInfos[url], url);
|
|
27290
|
-
});
|
|
27318
|
+
graph.urlInfoMap.forEach(callback);
|
|
27291
27319
|
},
|
|
27292
27320
|
filter: (graph, callback) => {
|
|
27293
27321
|
const urlInfos = [];
|
|
27294
|
-
|
|
27295
|
-
const urlInfo = graph.urlInfos[url];
|
|
27296
|
-
|
|
27322
|
+
graph.urlInfoMap.forEach(urlInfo => {
|
|
27297
27323
|
if (callback(urlInfo)) {
|
|
27298
27324
|
urlInfos.push(urlInfo);
|
|
27299
27325
|
}
|
|
@@ -27301,10 +27327,16 @@ const GRAPH = {
|
|
|
27301
27327
|
return urlInfos;
|
|
27302
27328
|
},
|
|
27303
27329
|
find: (graph, callback) => {
|
|
27304
|
-
|
|
27305
|
-
|
|
27306
|
-
|
|
27307
|
-
|
|
27330
|
+
let found = null;
|
|
27331
|
+
|
|
27332
|
+
for (const urlInfo of graph.urlInfoMap.values()) {
|
|
27333
|
+
if (callback(urlInfo)) {
|
|
27334
|
+
found = urlInfo;
|
|
27335
|
+
break;
|
|
27336
|
+
}
|
|
27337
|
+
}
|
|
27338
|
+
|
|
27339
|
+
return found;
|
|
27308
27340
|
}
|
|
27309
27341
|
};
|
|
27310
27342
|
|
|
@@ -28450,7 +28482,7 @@ build ${entryPointKeys.length} entry points`);
|
|
|
28450
28482
|
|
|
28451
28483
|
buildTask.done();
|
|
28452
28484
|
logger.debug(`graph urls pre-versioning:
|
|
28453
|
-
${
|
|
28485
|
+
${Array.from(finalGraph.urlInfoMap.keys()).join("\n")}`);
|
|
28454
28486
|
|
|
28455
28487
|
if (versioning) {
|
|
28456
28488
|
await applyUrlVersioning({
|
|
@@ -28706,7 +28738,7 @@ const applyUrlVersioning = async ({
|
|
|
28706
28738
|
});
|
|
28707
28739
|
|
|
28708
28740
|
try {
|
|
28709
|
-
const urlsSorted = sortByDependencies(finalGraph.
|
|
28741
|
+
const urlsSorted = sortByDependencies(finalGraph.toObject());
|
|
28710
28742
|
urlsSorted.forEach(url => {
|
|
28711
28743
|
if (url.startsWith("data:")) {
|
|
28712
28744
|
return;
|