UNPKG

every-plugin

Version:
42 lines (40 loc) 1.58 kB
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs'); const require_runtime_services_normalize = require('../../runtime/services/normalize.cjs'); let node_fs = require("node:fs"); node_fs = require_runtime.__toESM(node_fs, 1); let node_path = require("node:path"); node_path = require_runtime.__toESM(node_path, 1); //#region src/build/rspack/utils.ts function getPluginInfo(context) { const pkgPath = node_path.default.join(context, "package.json"); const pkg = JSON.parse(node_fs.default.readFileSync(pkgPath, "utf-8")); return { name: pkg.name, version: pkg.version, normalizedName: require_runtime_services_normalize.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 = node_path.default.resolve(devConfigPath); if (loadedModules.has(fullPath)) { delete require.cache[fullPath]; const dirPath = node_path.default.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 exports.getPluginInfo = getPluginInfo; exports.loadDevConfig = loadDevConfig; //# sourceMappingURL=utils.cjs.map