UNPKG

one

Version:

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

38 lines (37 loc) 1.09 kB
import { AsyncLocalStorage } from "async_hooks"; import { _registerWatchFileImpl } from "./watchFile.native.js"; var LOADER_DEPS_KEY = "__oneLoaderDepsContext"; var LOADER_DEPS_STORE = { get current() { if (globalThis[LOADER_DEPS_KEY]) return globalThis[LOADER_DEPS_KEY]; var als = new AsyncLocalStorage(); globalThis[LOADER_DEPS_KEY] = als; return als; } }; var debugLoaderDeps = process.env.ONE_DEBUG_LOADER_DEPS; function watchFileImpl(path) { var store = LOADER_DEPS_STORE.current.getStore(); if (store) { store.deps.add(path); } } _registerWatchFileImpl(watchFileImpl); async function trackLoaderDependencies(fn) { var deps = /* @__PURE__ */new Set(); var context = LOADER_DEPS_STORE.current; var result = await context.run({ deps }, async function () { return await fn(); }); if (debugLoaderDeps && deps.size > 0) { console.info("[loader-deps] tracked dependencies:", [...deps]); } return { result, dependencies: deps }; } export { trackLoaderDependencies }; //# sourceMappingURL=trackLoaderDependencies.native.js.map