ScuttleBot

scuttlebot / tests / e2e / node_modules / playwright / lib / common / esmLoaderHost.js
Source Blame History 104 lines
f7eb47b… lmata 1 "use strict";
f7eb47b… lmata 2 var __create = Object.create;
f7eb47b… lmata 3 var __defProp = Object.defineProperty;
f7eb47b… lmata 4 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
f7eb47b… lmata 5 var __getOwnPropNames = Object.getOwnPropertyNames;
f7eb47b… lmata 6 var __getProtoOf = Object.getPrototypeOf;
f7eb47b… lmata 7 var __hasOwnProp = Object.prototype.hasOwnProperty;
f7eb47b… lmata 8 var __export = (target, all) => {
f7eb47b… lmata 9 for (var name in all)
f7eb47b… lmata 10 __defProp(target, name, { get: all[name], enumerable: true });
f7eb47b… lmata 11 };
f7eb47b… lmata 12 var __copyProps = (to, from, except, desc) => {
f7eb47b… lmata 13 if (from && typeof from === "object" || typeof from === "function") {
f7eb47b… lmata 14 for (let key of __getOwnPropNames(from))
f7eb47b… lmata 15 if (!__hasOwnProp.call(to, key) && key !== except)
f7eb47b… lmata 16 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
f7eb47b… lmata 17 }
f7eb47b… lmata 18 return to;
f7eb47b… lmata 19 };
f7eb47b… lmata 20 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
f7eb47b… lmata 21 // If the importer is in node compatibility mode or this is not an ESM
f7eb47b… lmata 22 // file that has been converted to a CommonJS file using a Babel-
f7eb47b… lmata 23 // compatible transform (i.e. "__esModule" has not been set), then set
f7eb47b… lmata 24 // "default" to the CommonJS "module.exports" for node compatibility.
f7eb47b… lmata 25 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
f7eb47b… lmata 26 mod
f7eb47b… lmata 27 ));
f7eb47b… lmata 28 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
f7eb47b… lmata 29 var esmLoaderHost_exports = {};
f7eb47b… lmata 30 __export(esmLoaderHost_exports, {
f7eb47b… lmata 31 configureESMLoader: () => configureESMLoader,
f7eb47b… lmata 32 configureESMLoaderTransformConfig: () => configureESMLoaderTransformConfig,
f7eb47b… lmata 33 incorporateCompilationCache: () => incorporateCompilationCache,
f7eb47b… lmata 34 registerESMLoader: () => registerESMLoader,
f7eb47b… lmata 35 startCollectingFileDeps: () => startCollectingFileDeps,
f7eb47b… lmata 36 stopCollectingFileDeps: () => stopCollectingFileDeps
f7eb47b… lmata 37 });
f7eb47b… lmata 38 module.exports = __toCommonJS(esmLoaderHost_exports);
f7eb47b… lmata 39 var import_url = __toESM(require("url"));
f7eb47b… lmata 40 var import_compilationCache = require("../transform/compilationCache");
f7eb47b… lmata 41 var import_portTransport = require("../transform/portTransport");
f7eb47b… lmata 42 var import_transform = require("../transform/transform");
f7eb47b… lmata 43 let loaderChannel;
f7eb47b… lmata 44 function registerESMLoader() {
f7eb47b… lmata 45 if (process.env.PW_DISABLE_TS_ESM)
f7eb47b… lmata 46 return true;
f7eb47b… lmata 47 if ("Bun" in globalThis)
f7eb47b… lmata 48 return true;
f7eb47b… lmata 49 if (loaderChannel)
f7eb47b… lmata 50 return true;
f7eb47b… lmata 51 const register = require("node:module").register;
f7eb47b… lmata 52 if (!register)
f7eb47b… lmata 53 return false;
f7eb47b… lmata 54 const { port1, port2 } = new MessageChannel();
f7eb47b… lmata 55 register(import_url.default.pathToFileURL(require.resolve("../transform/esmLoader")), {
f7eb47b… lmata 56 data: { port: port2 },
f7eb47b… lmata 57 transferList: [port2]
f7eb47b… lmata 58 });
f7eb47b… lmata 59 loaderChannel = createPortTransport(port1);
f7eb47b… lmata 60 return true;
f7eb47b… lmata 61 }
f7eb47b… lmata 62 function createPortTransport(port) {
f7eb47b… lmata 63 return new import_portTransport.PortTransport(port, async (method, params) => {
f7eb47b… lmata 64 if (method === "pushToCompilationCache")
f7eb47b… lmata 65 (0, import_compilationCache.addToCompilationCache)(params.cache);
f7eb47b… lmata 66 });
f7eb47b… lmata 67 }
f7eb47b… lmata 68 async function startCollectingFileDeps() {
f7eb47b… lmata 69 if (!loaderChannel)
f7eb47b… lmata 70 return;
f7eb47b… lmata 71 await loaderChannel.send("startCollectingFileDeps", {});
f7eb47b… lmata 72 }
f7eb47b… lmata 73 async function stopCollectingFileDeps(file) {
f7eb47b… lmata 74 if (!loaderChannel)
f7eb47b… lmata 75 return;
f7eb47b… lmata 76 await loaderChannel.send("stopCollectingFileDeps", { file });
f7eb47b… lmata 77 }
f7eb47b… lmata 78 async function incorporateCompilationCache() {
f7eb47b… lmata 79 if (!loaderChannel)
f7eb47b… lmata 80 return;
f7eb47b… lmata 81 const result = await loaderChannel.send("getCompilationCache", {});
f7eb47b… lmata 82 (0, import_compilationCache.addToCompilationCache)(result.cache);
f7eb47b… lmata 83 }
f7eb47b… lmata 84 async function configureESMLoader() {
f7eb47b… lmata 85 if (!loaderChannel)
f7eb47b… lmata 86 return;
f7eb47b… lmata 87 await loaderChannel.send("setSingleTSConfig", { tsconfig: (0, import_transform.singleTSConfig)() });
f7eb47b… lmata 88 await loaderChannel.send("addToCompilationCache", { cache: (0, import_compilationCache.serializeCompilationCache)() });
f7eb47b… lmata 89 }
f7eb47b… lmata 90 async function configureESMLoaderTransformConfig() {
f7eb47b… lmata 91 if (!loaderChannel)
f7eb47b… lmata 92 return;
f7eb47b… lmata 93 await loaderChannel.send("setSingleTSConfig", { tsconfig: (0, import_transform.singleTSConfig)() });
f7eb47b… lmata 94 await loaderChannel.send("setTransformConfig", { config: (0, import_transform.transformConfig)() });
f7eb47b… lmata 95 }
f7eb47b… lmata 96 // Annotate the CommonJS export names for ESM import in node:
f7eb47b… lmata 97 0 && (module.exports = {
f7eb47b… lmata 98 configureESMLoader,
f7eb47b… lmata 99 configureESMLoaderTransformConfig,
f7eb47b… lmata 100 incorporateCompilationCache,
f7eb47b… lmata 101 registerESMLoader,
f7eb47b… lmata 102 startCollectingFileDeps,
f7eb47b… lmata 103 stopCollectingFileDeps
f7eb47b… lmata 104 });

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button