Skip to content

Commit

Permalink
fix find
Browse files Browse the repository at this point in the history
  • Loading branch information
dhvanipa committed Oct 31, 2023
1 parent 8996d63 commit d5e7998
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 45 deletions.
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"chalk": "4.1.2",
"esbuild": "^0.17.15",
"ethers": "^5.7.2",
"find-up": "^6.3.0",
"find-up": "5.0.0",
"zod": "^3.21.4",
"zod-validation-error": "^1.3.0"
},
Expand Down
4 changes: 0 additions & 4 deletions packages/config/src/library/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,17 @@ export type MUDConfigExtender = (config: MUDCoreConfig) => Record<string, unknow
export function mudCoreConfig(config: MUDCoreUserConfig): MUDCoreConfig {
// config types can change with plugins, `any` helps avoid errors when typechecking dependencies
// eslint-disable-next-line @typescript-eslint/no-explicit-any
console.log("config");
console.log(config);
let configAsAny = config as any;
const context = MUDCoreContext.getContext();
console.log(context);
for (const extender of context.configExtenders) {
configAsAny = extender(configAsAny);
}
console.log("here done bro");
return configAsAny;
}

/** Utility for plugin developers to extend the core config */
export function extendMUDCoreConfig(extender: MUDConfigExtender) {
console.log("extending bro");
const context = MUDCoreContext.getContext();
context.configExtenders.push(extender);
}
7 changes: 2 additions & 5 deletions packages/config/src/node/loadConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { findUp } from "find-up";
import findUp from "find-up";
import path from "path";
import { NotInsideProjectError } from "../library/errors";
import esbuild from "esbuild";
Expand All @@ -13,7 +13,6 @@ const TEMP_CONFIG = "mud.config.temp.mjs";
export async function loadConfig(configPath?: string): Promise<unknown> {
configPath = await resolveConfigPath(configPath);
try {
console.log("preee");
await esbuild.build({
entryPoints: [configPath],
format: "esm",
Expand All @@ -25,15 +24,13 @@ export async function loadConfig(configPath?: string): Promise<unknown> {
// avoid bundling external imports (it's unnecessary and esbuild can't handle all node features)
packages: "external",
});
console.log("here");
configPath = await resolveConfigPath(TEMP_CONFIG, true);
// Node.js caches dynamic imports, so without appending a cache breaking
// param like `?update={Date.now()}` this import always returns the same config
// if called multiple times in a single process, like the `dev-contracts` cli
console.log("all the way here");
return (await import(configPath + `?update=${Date.now()}`)).default;
} finally {
// rmSync(TEMP_CONFIG, { force: true });
rmSync(TEMP_CONFIG, { force: true });
}
}

Expand Down
39 changes: 4 additions & 35 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d5e7998

Please sign in to comment.