@latticexyz/config 2.2.15-main-c3c209ef0aba141416824a1613ccd1fe077adee1 → 2.2.15

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.
@@ -1,2 +1,2 @@
1
- import{findUp as n}from"find-up";import o from"path";import m from"esbuild";import{rmSync as s}from"fs";import{pathToFileURL as u}from"url";import f from"os";var a=["mud.config.js","mud.config.mjs","mud.config.ts","mud.config.mts"],e="mud.config.temp.mjs";async function j(r){r=await t(r);try{return await m.build({entryPoints:[r],format:"esm",outfile:e,platform:"node",bundle:!0,packages:"external"}),r=await t(e,!0),(await import(r+`?update=${Date.now()}`)).default}finally{s(e,{force:!0})}}async function t(r,i){return r===void 0?r=await d():o.isAbsolute(r)||(r=o.join(process.cwd(),r),r=o.normalize(r)),i&&f.platform()==="win32"?u(r).href:r}async function d(){let r=await n(a);if(r===void 0)throw new Error("Did not find a `mud.config.ts` file. Are you inside a MUD project?");return r}export{j as loadConfig,t as resolveConfigPath};
1
+ import{findUp as i}from"find-up";import e from"path";import{pathToFileURL as n}from"url";import s from"os";import a from"fs/promises";import{tsImport as m}from"tsx/esm/api";import{require as f}from"tsx/cjs/api";var p=["mud.config.js","mud.config.mjs","mud.config.ts","mud.config.mts"];async function C(r){r=await u(r);let o=await i("package.json",{cwd:e.dirname(r)});if(!o)throw new Error(`Could not find package.json for config at "${r}".`);let t=JSON.parse(await a.readFile(o,"utf8"));return!t.type||t.type==="commonjs"?f(`${r}?update=${Date.now()}`,import.meta.url).default:(await m(r,import.meta.url)).default}async function u(r,o){return r===void 0?r=await d():e.isAbsolute(r)||(r=e.join(process.cwd(),r),r=e.normalize(r)),o&&s.platform()==="win32"?n(r).href:r}async function d(){let r=await i(p);if(r===void 0)throw new Error("Did not find a `mud.config.ts` file. Are you inside a MUD project?");return r}export{C as loadConfig,u as resolveConfigPath};
2
2
  //# 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 esbuild from \"esbuild\";\nimport { rmSync } from \"fs\";\nimport { pathToFileURL } from \"url\";\nimport os from \"os\";\n\n// TODO: explore using https://www.npmjs.com/package/ts-import instead\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/** @deprecated */\nconst TEMP_CONFIG = \"mud.config.temp.mjs\";\n\n/** @deprecated */\nexport async function loadConfig(configPath?: string): Promise<unknown> {\n configPath = await resolveConfigPath(configPath);\n try {\n await esbuild.build({\n entryPoints: [configPath],\n format: \"esm\",\n outfile: TEMP_CONFIG,\n // https://esbuild.github.io/getting-started/#bundling-for-node\n platform: \"node\",\n // bundle local imports (otherwise it may error, js can't import ts)\n bundle: true,\n // avoid bundling external imports (it's unnecessary and esbuild can't handle all node features)\n packages: \"external\",\n });\n configPath = await resolveConfigPath(TEMP_CONFIG, true);\n // Node.js caches dynamic imports, so without appending a cache breaking\n // param like `?update={Date.now()}` this import always returns the same config\n // if called multiple times in a single process, like the `dev-contracts` cli\n return (await import(configPath + `?update=${Date.now()}`)).default;\n } finally {\n rmSync(TEMP_CONFIG, { force: true });\n }\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,OAAS,UAAAA,MAAc,UACvB,OAAOC,MAAU,OACjB,OAAOC,MAAa,UACpB,OAAS,UAAAC,MAAc,KACvB,OAAS,iBAAAC,MAAqB,MAC9B,OAAOC,MAAQ,KAMf,IAAMC,EAAc,CAAC,gBAAiB,iBAAkB,gBAAiB,gBAAgB,EAEnFC,EAAc,sBAGpB,eAAsBC,EAAWC,EAAuC,CACtEA,EAAa,MAAMC,EAAkBD,CAAU,EAC/C,GAAI,CACF,aAAMP,EAAQ,MAAM,CAClB,YAAa,CAACO,CAAU,EACxB,OAAQ,MACR,QAASF,EAET,SAAU,OAEV,OAAQ,GAER,SAAU,UACZ,CAAC,EACDE,EAAa,MAAMC,EAAkBH,EAAa,EAAI,GAI9C,MAAM,OAAOE,EAAa,WAAW,KAAK,IAAI,MAAM,OAC9D,QAAE,CACAN,EAAOI,EAAa,CAAE,MAAO,EAAK,CAAC,CACrC,CACF,CAGA,eAAsBG,EAAkBD,EAAqBE,EAAqB,CAChF,OAAIF,IAAe,OACjBA,EAAa,MAAMG,EAAkB,EAEhCX,EAAK,WAAWQ,CAAU,IAC7BA,EAAaR,EAAK,KAAK,QAAQ,IAAI,EAAGQ,CAAU,EAChDA,EAAaR,EAAK,UAAUQ,CAAU,GAMnCE,GAAaN,EAAG,SAAS,IAAM,QAAUD,EAAcK,CAAU,EAAE,KAAOA,CACnF,CAGA,eAAeG,GAAoB,CACjC,IAAMC,EAAe,MAAMb,EAAOM,CAAW,EAC7C,GAAIO,IAAiB,OACnB,MAAM,IAAI,MAAM,oEAAoE,EAEtF,OAAOA,CACT","names":["findUp","path","esbuild","rmSync","pathToFileURL","os","configFiles","TEMP_CONFIG","loadConfig","configPath","resolveConfigPath","toFileURL","getUserConfigPath","tsConfigPath"]}
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,OAAS,UAAAA,MAAc,UACvB,OAAOC,MAAU,OACjB,OAAS,iBAAAC,MAAqB,MAC9B,OAAOC,MAAQ,KACf,OAAOC,MAAQ,cACf,OAAS,YAAAC,MAAgB,cACzB,OAAS,WAAWC,MAAiB,cAIrC,IAAMC,EAAc,CAAC,gBAAiB,iBAAkB,gBAAiB,gBAAgB,EAGzF,eAAsBC,EAAWC,EAAuC,CACtEA,EAAa,MAAMC,EAAkBD,CAAU,EAE/C,IAAME,EAAkB,MAAMX,EAAO,eAAgB,CAAE,IAAKC,EAAK,QAAQQ,CAAU,CAAE,CAAC,EACtF,GAAI,CAACE,EAAiB,MAAM,IAAI,MAAM,8CAA8CF,KAAc,EAClG,IAAMG,EAAc,KAAK,MAAM,MAAMR,EAAG,SAASO,EAAiB,MAAM,CAAC,EAEzE,MAAI,CAACC,EAAY,MAAQA,EAAY,OAAS,WAGrCN,EAAU,GAAGG,YAAqB,KAAK,IAAI,IAAK,YAAY,GAAG,EAAE,SAIlE,MAAMJ,EAASI,EAAY,YAAY,GAAG,GAAG,OACvD,CAGA,eAAsBC,EAAkBD,EAAqBI,EAAqB,CAChF,OAAIJ,IAAe,OACjBA,EAAa,MAAMK,EAAkB,EAEhCb,EAAK,WAAWQ,CAAU,IAC7BA,EAAaR,EAAK,KAAK,QAAQ,IAAI,EAAGQ,CAAU,EAChDA,EAAaR,EAAK,UAAUQ,CAAU,GAMnCI,GAAaV,EAAG,SAAS,IAAM,QAAUD,EAAcO,CAAU,EAAE,KAAOA,CACnF,CAGA,eAAeK,GAAoB,CACjC,IAAMC,EAAe,MAAMf,EAAOO,CAAW,EAC7C,GAAIQ,IAAiB,OACnB,MAAM,IAAI,MAAM,oEAAoE,EAEtF,OAAOA,CACT","names":["findUp","path","pathToFileURL","os","fs","tsImport","tsRequire","configFiles","loadConfig","configPath","resolveConfigPath","packageJsonPath","packageJson","toFileURL","getUserConfigPath","tsConfigPath"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/config",
3
- "version": "2.2.15-main-c3c209ef0aba141416824a1613ccd1fe077adee1",
3
+ "version": "2.2.15",
4
4
  "description": "Config for Store and World",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,14 +32,17 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "@ark/util": "0.2.2",
35
- "esbuild": "^0.17.15",
36
35
  "find-up": "^6.3.0",
37
- "viem": "2.21.19",
38
- "@latticexyz/common": "2.2.15-main-c3c209ef0aba141416824a1613ccd1fe077adee1",
39
- "@latticexyz/schema-type": "2.2.15-main-c3c209ef0aba141416824a1613ccd1fe077adee1"
36
+ "tsx": "^4.19.1",
37
+ "@latticexyz/common": "2.2.15",
38
+ "@latticexyz/schema-type": "2.2.15"
40
39
  },
41
40
  "devDependencies": {
42
- "tsup": "^6.7.0"
41
+ "tsup": "^6.7.0",
42
+ "viem": "2.21.19"
43
+ },
44
+ "peerDependencies": {
45
+ "viem": "2.x"
43
46
  },
44
47
  "scripts": {
45
48
  "build": "pnpm run build:js",