@latticexyz/config 2.2.18-f0433092876e2ac9b5b12cd0ecae9c120a2d0368 → 2.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/deprecated/node.js
CHANGED
|
@@ -1,2 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
// src/deprecated/node/loadConfig.ts
|
|
2
|
+
import { findUp } from "find-up";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { pathToFileURL } from "url";
|
|
5
|
+
import os from "os";
|
|
6
|
+
import fs from "fs/promises";
|
|
7
|
+
import { tsImport } from "tsx/esm/api";
|
|
8
|
+
import { require as tsRequire } from "tsx/cjs/api";
|
|
9
|
+
var configFiles = ["mud.config.js", "mud.config.mjs", "mud.config.ts", "mud.config.mts"];
|
|
10
|
+
async function loadConfig(configPath) {
|
|
11
|
+
configPath = await resolveConfigPath(configPath);
|
|
12
|
+
const packageJsonPath = await findUp("package.json", { cwd: path.dirname(configPath) });
|
|
13
|
+
if (!packageJsonPath) throw new Error(`Could not find package.json for config at "${configPath}".`);
|
|
14
|
+
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
|
|
15
|
+
if (!packageJson.type || packageJson.type === "commonjs") {
|
|
16
|
+
return tsRequire(`${configPath}?update=${Date.now()}`, import.meta.url).default;
|
|
17
|
+
}
|
|
18
|
+
return (await tsImport(configPath, import.meta.url)).default;
|
|
19
|
+
}
|
|
20
|
+
async function resolveConfigPath(configPath, toFileURL) {
|
|
21
|
+
if (configPath === void 0) {
|
|
22
|
+
configPath = await getUserConfigPath();
|
|
23
|
+
} else {
|
|
24
|
+
if (!path.isAbsolute(configPath)) {
|
|
25
|
+
configPath = path.join(process.cwd(), configPath);
|
|
26
|
+
configPath = path.normalize(configPath);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return toFileURL && os.platform() === "win32" ? pathToFileURL(configPath).href : configPath;
|
|
30
|
+
}
|
|
31
|
+
async function getUserConfigPath() {
|
|
32
|
+
const tsConfigPath = await findUp(configFiles);
|
|
33
|
+
if (tsConfigPath === void 0) {
|
|
34
|
+
throw new Error("Did not find a `mud.config.ts` file. Are you inside a MUD project?");
|
|
35
|
+
}
|
|
36
|
+
return tsConfigPath;
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
loadConfig,
|
|
40
|
+
resolveConfigPath
|
|
41
|
+
};
|
|
2
42
|
//# sourceMappingURL=node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/deprecated/node/loadConfig.ts"],"sourcesContent":["import { findUp } from \"find-up\";\nimport path from \"path\";\nimport { pathToFileURL } from \"url\";\nimport os from \"os\";\nimport fs from \"fs/promises\";\nimport { tsImport } from \"tsx/esm/api\";\nimport { require as tsRequire } from \"tsx/cjs/api\";\n\n// In order of preference files are checked\n/** @deprecated */\nconst configFiles = [\"mud.config.js\", \"mud.config.mjs\", \"mud.config.ts\", \"mud.config.mts\"];\n\n/** @deprecated */\nexport async function loadConfig(configPath?: string): Promise<unknown> {\n configPath = await resolveConfigPath(configPath);\n // load nearest package.json to figure out if we need to import with ESM or CJS\n const packageJsonPath = await findUp(\"package.json\", { cwd: path.dirname(configPath) });\n if (!packageJsonPath) throw new Error(`Could not find package.json for config at \"${configPath}\".`);\n const packageJson = JSON.parse(await fs.readFile(packageJsonPath, \"utf8\"));\n // use require if cjs\n if (!packageJson.type || packageJson.type === \"commonjs\") {\n // tsRequire has an internal cache, so we need to append data to reload the config\n // this helps with things like the mud dev runner that reevalutes the config on changes\n return tsRequire(`${configPath}?update=${Date.now()}`, import.meta.url).default;\n }\n // otherwise default to esm\n // this is not cached, so we don't need to append anything to the config path\n return (await tsImport(configPath, import.meta.url)).default;\n}\n\n/** @deprecated */\nexport async function resolveConfigPath(configPath?: string, toFileURL?: boolean) {\n if (configPath === undefined) {\n configPath = await getUserConfigPath();\n } else {\n if (!path.isAbsolute(configPath)) {\n configPath = path.join(process.cwd(), configPath);\n configPath = path.normalize(configPath);\n }\n }\n\n // Add `file:///` for Windows support\n // (see https://github.com/nodejs/node/issues/31710)\n return toFileURL && os.platform() === \"win32\" ? pathToFileURL(configPath).href : configPath;\n}\n\n/** @deprecated */\nasync function getUserConfigPath() {\n const tsConfigPath = await findUp(configFiles);\n if (tsConfigPath === undefined) {\n throw new Error(\"Did not find a `mud.config.ts` file. Are you inside a MUD project?\");\n }\n return tsConfigPath;\n}\n"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/deprecated/node/loadConfig.ts"],"sourcesContent":["import { findUp } from \"find-up\";\nimport path from \"path\";\nimport { pathToFileURL } from \"url\";\nimport os from \"os\";\nimport fs from \"fs/promises\";\nimport { tsImport } from \"tsx/esm/api\";\nimport { require as tsRequire } from \"tsx/cjs/api\";\n\n// In order of preference files are checked\n/** @deprecated */\nconst configFiles = [\"mud.config.js\", \"mud.config.mjs\", \"mud.config.ts\", \"mud.config.mts\"];\n\n/** @deprecated */\nexport async function loadConfig(configPath?: string): Promise<unknown> {\n configPath = await resolveConfigPath(configPath);\n // load nearest package.json to figure out if we need to import with ESM or CJS\n const packageJsonPath = await findUp(\"package.json\", { cwd: path.dirname(configPath) });\n if (!packageJsonPath) throw new Error(`Could not find package.json for config at \"${configPath}\".`);\n const packageJson = JSON.parse(await fs.readFile(packageJsonPath, \"utf8\"));\n // use require if cjs\n if (!packageJson.type || packageJson.type === \"commonjs\") {\n // tsRequire has an internal cache, so we need to append data to reload the config\n // this helps with things like the mud dev runner that reevalutes the config on changes\n return tsRequire(`${configPath}?update=${Date.now()}`, import.meta.url).default;\n }\n // otherwise default to esm\n // this is not cached, so we don't need to append anything to the config path\n return (await tsImport(configPath, import.meta.url)).default;\n}\n\n/** @deprecated */\nexport async function resolveConfigPath(configPath?: string, toFileURL?: boolean) {\n if (configPath === undefined) {\n configPath = await getUserConfigPath();\n } else {\n if (!path.isAbsolute(configPath)) {\n configPath = path.join(process.cwd(), configPath);\n configPath = path.normalize(configPath);\n }\n }\n\n // Add `file:///` for Windows support\n // (see https://github.com/nodejs/node/issues/31710)\n return toFileURL && os.platform() === \"win32\" ? pathToFileURL(configPath).href : configPath;\n}\n\n/** @deprecated */\nasync function getUserConfigPath() {\n const tsConfigPath = await findUp(configFiles);\n if (tsConfigPath === undefined) {\n throw new Error(\"Did not find a `mud.config.ts` file. Are you inside a MUD project?\");\n }\n return tsConfigPath;\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAC9B,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,SAAS,gBAAgB;AACzB,SAAS,WAAW,iBAAiB;AAIrC,IAAM,cAAc,CAAC,iBAAiB,kBAAkB,iBAAiB,gBAAgB;AAGzF,eAAsB,WAAW,YAAuC;AACtE,eAAa,MAAM,kBAAkB,UAAU;AAE/C,QAAM,kBAAkB,MAAM,OAAO,gBAAgB,EAAE,KAAK,KAAK,QAAQ,UAAU,EAAE,CAAC;AACtF,MAAI,CAAC,gBAAiB,OAAM,IAAI,MAAM,8CAA8C,UAAU,IAAI;AAClG,QAAM,cAAc,KAAK,MAAM,MAAM,GAAG,SAAS,iBAAiB,MAAM,CAAC;AAEzE,MAAI,CAAC,YAAY,QAAQ,YAAY,SAAS,YAAY;AAGxD,WAAO,UAAU,GAAG,UAAU,WAAW,KAAK,IAAI,CAAC,IAAI,YAAY,GAAG,EAAE;AAAA,EAC1E;AAGA,UAAQ,MAAM,SAAS,YAAY,YAAY,GAAG,GAAG;AACvD;AAGA,eAAsB,kBAAkB,YAAqB,WAAqB;AAChF,MAAI,eAAe,QAAW;AAC5B,iBAAa,MAAM,kBAAkB;AAAA,EACvC,OAAO;AACL,QAAI,CAAC,KAAK,WAAW,UAAU,GAAG;AAChC,mBAAa,KAAK,KAAK,QAAQ,IAAI,GAAG,UAAU;AAChD,mBAAa,KAAK,UAAU,UAAU;AAAA,IACxC;AAAA,EACF;AAIA,SAAO,aAAa,GAAG,SAAS,MAAM,UAAU,cAAc,UAAU,EAAE,OAAO;AACnF;AAGA,eAAe,oBAAoB;AACjC,QAAM,eAAe,MAAM,OAAO,WAAW;AAC7C,MAAI,iBAAiB,QAAW;AAC9B,UAAM,IAAI,MAAM,oEAAoE;AAAA,EACtF;AACA,SAAO;AACT;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latticexyz/config",
|
|
3
|
-
"version": "2.2.18
|
|
3
|
+
"version": "2.2.18",
|
|
4
4
|
"description": "Config for Store and World",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"@ark/util": "0.2.2",
|
|
35
35
|
"find-up": "^6.3.0",
|
|
36
36
|
"tsx": "^4.19.1",
|
|
37
|
-
"@latticexyz/common": "2.2.18
|
|
38
|
-
"@latticexyz/schema-type": "2.2.18
|
|
37
|
+
"@latticexyz/common": "2.2.18",
|
|
38
|
+
"@latticexyz/schema-type": "2.2.18"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"viem": "2.21.19"
|