one
Version:
One is a new React Framework that makes Vite serve both native and web.
32 lines (31 loc) • 1.07 kB
JavaScript
import { AsyncLocalStorage } from "async_hooks";
import { _registerWatchFileImpl } from "./watchFile.native.js";
var LOADER_DEPS_KEY = "__oneLoaderDepsContext",
LOADER_DEPS_STORE = {
get current() {
if (globalThis[LOADER_DEPS_KEY]) return globalThis[LOADER_DEPS_KEY];
var als = new AsyncLocalStorage();
return globalThis[LOADER_DEPS_KEY] = als, als;
}
},
debugLoaderDeps = process.env.ONE_DEBUG_LOADER_DEPS;
function watchFileImpl(path) {
var store = LOADER_DEPS_STORE.current.getStore();
store && store.deps.add(path);
}
_registerWatchFileImpl(watchFileImpl);
async function trackLoaderDependencies(fn) {
var deps = /* @__PURE__ */new Set(),
context = LOADER_DEPS_STORE.current,
result = await context.run({
deps
}, async function () {
return await fn();
});
return debugLoaderDeps && deps.size > 0 && console.info("[loader-deps] tracked dependencies:", [...deps]), {
result,
dependencies: deps
};
}
export { trackLoaderDependencies };
//# sourceMappingURL=trackLoaderDependencies.native.js.map