playwright 1.57.0-beta-1764944708000 → 1.57.0-beta-1765994134000
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/transform/esmLoader.js +10 -11
- package/lib/transform/transform.js +9 -6
- package/package.json +2 -2
|
@@ -27,7 +27,9 @@ var import_compilationCache = require("./compilationCache");
|
|
|
27
27
|
var import_portTransport = require("./portTransport");
|
|
28
28
|
var import_transform = require("./transform");
|
|
29
29
|
var import_util = require("../util");
|
|
30
|
-
|
|
30
|
+
const esmPreflightExtension = ".esm.preflight";
|
|
31
|
+
async function resolve(originalSpecifier, context, defaultResolve) {
|
|
32
|
+
let specifier = originalSpecifier.replace(esmPreflightExtension, "");
|
|
31
33
|
if (context.parentURL && context.parentURL.startsWith("file://")) {
|
|
32
34
|
const filename = import_url.default.fileURLToPath(context.parentURL);
|
|
33
35
|
const resolved = (0, import_transform.resolveHook)(filename, specifier);
|
|
@@ -37,6 +39,8 @@ async function resolve(specifier, context, defaultResolve) {
|
|
|
37
39
|
const result = await defaultResolve(specifier, context, defaultResolve);
|
|
38
40
|
if (result?.url && result.url.startsWith("file://"))
|
|
39
41
|
(0, import_compilationCache.currentFileDepsCollector)()?.add(import_url.default.fileURLToPath(result.url));
|
|
42
|
+
if (originalSpecifier.endsWith(esmPreflightExtension))
|
|
43
|
+
result.url = result.url + esmPreflightExtension;
|
|
40
44
|
return result;
|
|
41
45
|
}
|
|
42
46
|
const kSupportedFormats = /* @__PURE__ */ new Map([
|
|
@@ -47,7 +51,8 @@ const kSupportedFormats = /* @__PURE__ */ new Map([
|
|
|
47
51
|
[null, null],
|
|
48
52
|
[void 0, void 0]
|
|
49
53
|
]);
|
|
50
|
-
async function load(
|
|
54
|
+
async function load(originalModuleUrl, context, defaultLoad) {
|
|
55
|
+
const moduleUrl = originalModuleUrl.replace(esmPreflightExtension, "");
|
|
51
56
|
if (!kSupportedFormats.has(context.format))
|
|
52
57
|
return defaultLoad(moduleUrl, context, defaultLoad);
|
|
53
58
|
if (!moduleUrl.startsWith("file://"))
|
|
@@ -57,23 +62,17 @@ async function load(moduleUrl, context, defaultLoad) {
|
|
|
57
62
|
return defaultLoad(moduleUrl, context, defaultLoad);
|
|
58
63
|
const code = import_fs.default.readFileSync(filename, "utf-8");
|
|
59
64
|
const transformed = (0, import_transform.transformHook)(code, filename, moduleUrl);
|
|
60
|
-
if (transformed.serializedCache)
|
|
61
|
-
|
|
62
|
-
await transport?.send("pushToCompilationCache", { cache: transformed.serializedCache });
|
|
63
|
-
else
|
|
64
|
-
transport?.post("pushToCompilationCache", { cache: transformed.serializedCache });
|
|
65
|
-
}
|
|
65
|
+
if (transformed.serializedCache)
|
|
66
|
+
transport?.post("pushToCompilationCache", { cache: transformed.serializedCache });
|
|
66
67
|
return {
|
|
67
68
|
format: kSupportedFormats.get(context.format) || ((0, import_util.fileIsModule)(filename) ? "module" : "commonjs"),
|
|
68
|
-
source: transformed.code,
|
|
69
|
+
source: originalModuleUrl.endsWith(esmPreflightExtension) ? `void 0;` : transformed.code,
|
|
69
70
|
shortCircuit: true
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
73
|
let transport;
|
|
73
|
-
let legacyWaitForSourceMaps = false;
|
|
74
74
|
function initialize(data) {
|
|
75
75
|
transport = createTransport(data?.port);
|
|
76
|
-
legacyWaitForSourceMaps = !!process.env.PLAYWRIGHT_WAIT_FOR_SOURCE_MAPS;
|
|
77
76
|
}
|
|
78
77
|
function createTransport(port) {
|
|
79
78
|
return new import_portTransport.PortTransport(port, async (method, params) => {
|
|
@@ -209,11 +209,11 @@ function calculateHash(content, filePath, isModule2, pluginsPrologue, pluginsEpi
|
|
|
209
209
|
async function requireOrImport(file) {
|
|
210
210
|
installTransformIfNeeded();
|
|
211
211
|
const isModule = (0, import_util.fileIsModule)(file);
|
|
212
|
-
const esmImport = () => eval(`import(${JSON.stringify(import_url.default.pathToFileURL(file))})`);
|
|
213
212
|
if (isModule) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
});
|
|
213
|
+
const fileName = import_url.default.pathToFileURL(file);
|
|
214
|
+
const esmImport = () => eval(`import(${JSON.stringify(fileName)})`);
|
|
215
|
+
await eval(`import(${JSON.stringify(fileName + ".esm.preflight")})`).finally(nextTask);
|
|
216
|
+
return await esmImport().finally(nextTask);
|
|
217
217
|
}
|
|
218
218
|
const result = require(file);
|
|
219
219
|
const depsCollector = (0, import_compilationCache.currentFileDepsCollector)();
|
|
@@ -257,8 +257,8 @@ function wrapFunctionWithLocation(func) {
|
|
|
257
257
|
const oldPrepareStackTrace = Error.prepareStackTrace;
|
|
258
258
|
Error.prepareStackTrace = (error, stackFrames) => {
|
|
259
259
|
const frame = import_utilsBundle.sourceMapSupport.wrapCallSite(stackFrames[1]);
|
|
260
|
-
const
|
|
261
|
-
const file2 =
|
|
260
|
+
const fileName2 = frame.getFileName();
|
|
261
|
+
const file2 = fileName2 && fileName2.startsWith("file://") ? import_url.default.fileURLToPath(fileName2) : fileName2;
|
|
262
262
|
return {
|
|
263
263
|
file: file2,
|
|
264
264
|
line: frame.getLineNumber(),
|
|
@@ -278,6 +278,9 @@ function wrapFunctionWithLocation(func) {
|
|
|
278
278
|
function isRelativeSpecifier(specifier) {
|
|
279
279
|
return specifier === "." || specifier === ".." || specifier.startsWith("./") || specifier.startsWith("../");
|
|
280
280
|
}
|
|
281
|
+
async function nextTask() {
|
|
282
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
283
|
+
}
|
|
281
284
|
// Annotate the CommonJS export names for ESM import in node:
|
|
282
285
|
0 && (module.exports = {
|
|
283
286
|
requireOrImport,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playwright",
|
|
3
|
-
"version": "1.57.0-beta-
|
|
3
|
+
"version": "1.57.0-beta-1765994134000",
|
|
4
4
|
"description": "A high-level API to automate web browsers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"license": "Apache-2.0",
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"playwright-core": "1.57.0-beta-
|
|
67
|
+
"playwright-core": "1.57.0-beta-1765994134000"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
70
|
"fsevents": "2.3.2"
|