UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

62 lines 2.05 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var trackLoaderDependencies_exports = {}; __export(trackLoaderDependencies_exports, { trackLoaderDependencies: () => trackLoaderDependencies }); module.exports = __toCommonJS(trackLoaderDependencies_exports); var import_node_async_hooks = require("node:async_hooks"); var import_watchFile = require("./watchFile.cjs"); const LOADER_DEPS_KEY = "__oneLoaderDepsContext"; const LOADER_DEPS_STORE = { get current() { if (globalThis[LOADER_DEPS_KEY]) return globalThis[LOADER_DEPS_KEY]; const als = new import_node_async_hooks.AsyncLocalStorage(); globalThis[LOADER_DEPS_KEY] = als; return als; } }; const debugLoaderDeps = process.env.ONE_DEBUG_LOADER_DEPS; function watchFileImpl(path) { const store = LOADER_DEPS_STORE.current.getStore(); if (store) { store.deps.add(path); } } (0, import_watchFile._registerWatchFileImpl)(watchFileImpl); async function trackLoaderDependencies(fn) { const deps = /* @__PURE__ */new Set(); const context = LOADER_DEPS_STORE.current; const result = await context.run({ deps }, async () => { return await fn(); }); if (debugLoaderDeps && deps.size > 0) { console.info("[loader-deps] tracked dependencies:", [...deps]); } return { result, dependencies: deps }; }