UNPKG

every-plugin

Version:
39 lines (37 loc) 1.33 kB
import { __require } from "../../_virtual/_rolldown/runtime.mjs"; import { getNormalizedRemoteName } from "../../runtime/services/normalize.mjs"; import fs from "node:fs"; import path from "node:path"; //#region src/build/rspack/utils.ts function getPluginInfo(context) { const pkgPath = path.join(context, "package.json"); const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8")); return { name: pkg.name, version: pkg.version, normalizedName: getNormalizedRemoteName(pkg.name), dependencies: pkg.dependencies || {}, peerDependencies: pkg.peerDependencies || {} }; } const loadedModules = /* @__PURE__ */ new Set(); function loadDevConfig(devConfigPath) { if (process.env.DEPLOY === "true") return null; try { const fullPath = path.resolve(devConfigPath); if (loadedModules.has(fullPath)) { delete __require.cache[fullPath]; const dirPath = path.dirname(fullPath); for (const key of Object.keys(__require.cache)) if (key.startsWith(dirPath) && key !== fullPath) delete __require.cache[key]; } const module = __require(fullPath).default; loadedModules.add(fullPath); return module; } catch (error) { console.warn(`Could not load dev config from ${devConfigPath}:`, error.message); return null; } } //#endregion export { getPluginInfo, loadDevConfig }; //# sourceMappingURL=utils.mjs.map