|
1
|
"use strict"; |
|
2
|
var __create = Object.create; |
|
3
|
var __defProp = Object.defineProperty; |
|
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
|
5
|
var __getOwnPropNames = Object.getOwnPropertyNames; |
|
6
|
var __getProtoOf = Object.getPrototypeOf; |
|
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty; |
|
8
|
var __export = (target, all) => { |
|
9
|
for (var name in all) |
|
10
|
__defProp(target, name, { get: all[name], enumerable: true }); |
|
11
|
}; |
|
12
|
var __copyProps = (to, from, except, desc) => { |
|
13
|
if (from && typeof from === "object" || typeof from === "function") { |
|
14
|
for (let key of __getOwnPropNames(from)) |
|
15
|
if (!__hasOwnProp.call(to, key) && key !== except) |
|
16
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
|
17
|
} |
|
18
|
return to; |
|
19
|
}; |
|
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( |
|
21
|
// If the importer is in node compatibility mode or this is not an ESM |
|
22
|
// file that has been converted to a CommonJS file using a Babel- |
|
23
|
// compatible transform (i.e. "__esModule" has not been set), then set |
|
24
|
// "default" to the CommonJS "module.exports" for node compatibility. |
|
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, |
|
26
|
mod |
|
27
|
)); |
|
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
|
29
|
var loaderHost_exports = {}; |
|
30
|
__export(loaderHost_exports, { |
|
31
|
InProcessLoaderHost: () => InProcessLoaderHost, |
|
32
|
OutOfProcessLoaderHost: () => OutOfProcessLoaderHost |
|
33
|
}); |
|
34
|
module.exports = __toCommonJS(loaderHost_exports); |
|
35
|
var import_processHost = require("./processHost"); |
|
36
|
var import_esmLoaderHost = require("../common/esmLoaderHost"); |
|
37
|
var import_ipc = require("../common/ipc"); |
|
38
|
var import_poolBuilder = require("../common/poolBuilder"); |
|
39
|
var import_test = require("../common/test"); |
|
40
|
var import_testLoader = require("../common/testLoader"); |
|
41
|
var import_compilationCache = require("../transform/compilationCache"); |
|
42
|
class InProcessLoaderHost { |
|
43
|
constructor(config) { |
|
44
|
this._config = config; |
|
45
|
this._poolBuilder = import_poolBuilder.PoolBuilder.createForLoader(); |
|
46
|
} |
|
47
|
async start(errors) { |
|
48
|
return true; |
|
49
|
} |
|
50
|
async loadTestFile(file, testErrors) { |
|
51
|
const result = await (0, import_testLoader.loadTestFile)(file, this._config, testErrors); |
|
52
|
this._poolBuilder.buildPools(result, testErrors); |
|
53
|
return result; |
|
54
|
} |
|
55
|
async stop() { |
|
56
|
await (0, import_esmLoaderHost.incorporateCompilationCache)(); |
|
57
|
} |
|
58
|
} |
|
59
|
class OutOfProcessLoaderHost { |
|
60
|
constructor(config) { |
|
61
|
this._config = config; |
|
62
|
this._processHost = new import_processHost.ProcessHost(require.resolve("../loader/loaderMain.js"), "loader", {}); |
|
63
|
} |
|
64
|
async start(errors) { |
|
65
|
const startError = await this._processHost.startRunner((0, import_ipc.serializeConfig)(this._config, false)); |
|
66
|
if (startError) { |
|
67
|
errors.push({ |
|
68
|
message: `Test loader process failed to start with code "${startError.code}" and signal "${startError.signal}"` |
|
69
|
}); |
|
70
|
return false; |
|
71
|
} |
|
72
|
return true; |
|
73
|
} |
|
74
|
async loadTestFile(file, testErrors) { |
|
75
|
const result = await this._processHost.sendMessage({ method: "loadTestFile", params: { file } }); |
|
76
|
testErrors.push(...result.testErrors); |
|
77
|
return import_test.Suite._deepParse(result.fileSuite); |
|
78
|
} |
|
79
|
async stop() { |
|
80
|
const result = await this._processHost.sendMessage({ method: "getCompilationCacheFromLoader" }); |
|
81
|
(0, import_compilationCache.addToCompilationCache)(result); |
|
82
|
await this._processHost.stop(); |
|
83
|
} |
|
84
|
} |
|
85
|
// Annotate the CommonJS export names for ESM import in node: |
|
86
|
0 && (module.exports = { |
|
87
|
InProcessLoaderHost, |
|
88
|
OutOfProcessLoaderHost |
|
89
|
}); |
|
90
|
|