Skip to content

Commit

Permalink
Merge pull request #29 from tenetxyz/compile-to-cjs
Browse files Browse the repository at this point in the history
Compile to cjs
  • Loading branch information
dhvanipa authored Oct 31, 2023
2 parents 160fd14 + 505dd3a commit 401e034
Show file tree
Hide file tree
Showing 44 changed files with 1,858 additions and 1,645 deletions.
4 changes: 2 additions & 2 deletions e2e/packages/sync-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"@latticexyz/utils": "link:../../../packages/utils",
"@viem/anvil": "^0.0.6",
"abitype": "0.9.3",
"chalk": "^5.2.0",
"chalk": "4.1.2",
"dotenv": "^16.0.3",
"ethers": "^5.7.2",
"execa": "^7.1.1",
"execa": "^5.1.1",
"jsdom": "^22.0.0",
"typescript": "5.1.6",
"viem": "1.6.0",
Expand Down
9 changes: 0 additions & 9 deletions examples/indexer-client/pnpm-lock.yaml

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "5.46.1",
"@typescript-eslint/parser": "5.46.1",
"chalk": "^5.2.0",
"chalk": "4.1.2",
"eslint": "8.29.0",
"execa": "^7.0.0",
"execa": "^5.1.1",
"husky": ">=6",
"lint-staged": ">=10",
"prettier": "^2.8.4",
Expand Down
7 changes: 5 additions & 2 deletions packages/block-logs-stream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
"directory": "packages/block-logs-stream"
},
"license": "MIT",
"type": "module",
"exports": {
".": "./dist/index.js"
".": {
"require": "./dist/index.js",
"import": "./dist/index.js"
}
},
"main": "./dist/index.js",
"types": "src/index.ts",
"scripts": {
"build": "pnpm run build:js",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-logs-stream/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/index.ts"],
target: "esnext",
format: ["esm"],
format: ["esm", "cjs"],
dts: false,
sourcemap: true,
clean: true,
Expand Down
10 changes: 6 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
"directory": "packages/cli"
},
"license": "MIT",
"type": "module",
"exports": {
".": "./dist/index.js"
".": {
"require": "./dist/index.js",
"import": "./dist/index.js"
}
},
"types": "src/index.ts",
"bin": {
Expand Down Expand Up @@ -41,12 +43,12 @@
"@latticexyz/utils": "workspace:*",
"@latticexyz/world": "workspace:*",
"@typechain/ethers-v5": "^10.2.0",
"chalk": "^5.0.1",
"chalk": "4.1.2",
"chokidar": "^3.5.3",
"dotenv": "^16.0.3",
"ejs": "^3.1.8",
"ethers": "^5.7.2",
"execa": "^7.0.0",
"execa": "^5.1.1",
"glob": "^8.0.3",
"nice-grpc-web": "^2.0.1",
"openurl": "^1.1.1",
Expand Down
14 changes: 8 additions & 6 deletions packages/cli/scripts/generate-test-tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ try {
logError(error);
}

const srcDirectory = await getSrcDirectory();
(async () => {
const srcDirectory = await getSrcDirectory();

if (config !== undefined) {
tablegen(config, path.join(srcDirectory, config.codegenDirectory));
} else {
process.exit(1);
}
if (config !== undefined) {
tablegen(config, path.join(srcDirectory, config.codegenDirectory));
} else {
process.exit(1);
}
})();
2 changes: 1 addition & 1 deletion packages/cli/src/commands/devnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { rmSync } from "fs";
import { homedir } from "os";
import path from "path";
import type { CommandModule } from "yargs";
import { execa } from "execa";
import execa from "execa";

type Options = {
blocktime: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/index.ts", "src/mud.ts"],
target: "esnext",
format: ["esm"],
format: ["esm", "cjs"],
dts: false,
sourcemap: true,
clean: true,
Expand Down
48 changes: 36 additions & 12 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,41 @@
"directory": "packages/common"
},
"license": "MIT",
"type": "module",
"exports": {
".": "./dist/index.js",
"./chains": "./dist/chains.js",
"./codegen": "./dist/codegen.js",
"./deprecated": "./dist/deprecated.js",
"./errors": "./dist/errors.js",
"./foundry": "./dist/foundry.js",
"./type-utils": "./dist/type-utils.js",
"./utils": "./dist/utils.js"
".": {
"require": "./dist/index.js",
"import": "./dist/index.js"
},
"./chains": {
"require": "./dist/chains.js",
"import": "./dist/chains.js"
},
"./codegen": {
"require": "./dist/codegen.js",
"import": "./dist/codegen.js"
},
"./deprecated": {
"require": "./dist/deprecated.js",
"import": "./dist/deprecated.js"
},
"./errors": {
"require": "./dist/errors.js",
"import": "./dist/errors.js"
},
"./foundry": {
"require": "./dist/foundry.js",
"import": "./dist/foundry.js"
},
"./type-utils": {
"require": "./dist/type-utils.js",
"import": "./dist/type-utils.js"
},
"./utils": {
"require": "./dist/utils.js",
"import": "./dist/utils.js"
}
},
"main": "./dist/index.js",
"typesVersions": {
"*": {
"index": [
Expand Down Expand Up @@ -59,10 +83,10 @@
"@latticexyz/schema-type": "workspace:*",
"@solidity-parser/parser": "^0.16.0",
"abitype": "0.9.3",
"chalk": "^5.2.0",
"chalk": "4.1.2",
"debug": "^4.3.4",
"execa": "^7.0.0",
"p-retry": "^5.1.2",
"execa": "^5.1.1",
"p-retry": "4.6.2",
"prettier": "^2.8.4",
"prettier-plugin-solidity": "^1.1.2",
"viem": "1.6.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/foundry/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { execa, Options } from "execa";
import execa, { Options } from "execa";
import chalk from "chalk";

export interface ForgeConfig {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default defineConfig({
utils: "src/utils/index.ts",
},
target: "esnext",
format: ["esm"],
format: ["esm", "cjs"],
dts: false,
sourcemap: true,
clean: true,
Expand Down
22 changes: 16 additions & 6 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@
"directory": "packages/config"
},
"license": "MIT",
"type": "module",
"exports": {
".": "./dist/library/index.js",
"./register": "./dist/register/index.js",
"./node": "./dist/node/index.js"
".": {
"require": "./dist/library/index.js",
"import": "./dist/library/index.js"
},
"./register": {
"require": "./dist/register/index.js",
"import": "./dist/register/index.js"
},
"./node": {
"require": "./dist/node/index.js",
"import": "./dist/node/index.js"
}
},
"main": "./dist/library/index.js",
"typesVersions": {
"*": {
"index": [
Expand All @@ -38,10 +47,11 @@
"dependencies": {
"@latticexyz/common": "workspace:*",
"@latticexyz/schema-type": "workspace:*",
"chalk": "^5.2.0",
"chalk": "4.1.2",
"esbuild": "^0.17.15",
"ethers": "^5.7.2",
"find-up": "^6.3.0",
"find-up": "5.0.0",
"p-retry": "4.6.2",
"zod": "^3.21.4",
"zod-validation-error": "^1.3.0"
},
Expand Down
2 changes: 1 addition & 1 deletion 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 Down
2 changes: 1 addition & 1 deletion packages/config/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/library/index.ts", "src/register/index.ts", "src/node/index.ts"],
target: "esnext",
format: ["esm"],
format: ["esm", "cjs"],
dts: false,
sourcemap: true,
clean: true,
Expand Down
11 changes: 6 additions & 5 deletions packages/gas-report/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
"directory": "packages/gas-report"
},
"license": "MIT",
"type": "module",
"exports": {
".": "./dist/index.js"
".": {
"require": "./dist/index.js",
"import": "./dist/index.js"
}
},
"typesVersions": {
"*": {
Expand All @@ -29,10 +31,9 @@
"test": "vitest typecheck --run --passWithNoTests && vitest --run --passWithNoTests && forge test"
},
"dependencies": {
"chalk": "^5.3.0",
"chalk": "4.1.2",
"dotenv": "^16.0.3",
"execa": "^7.0.0",
"strip-ansi": "^7.1.0",
"execa": "^5.1.1",
"table": "^6.8.1",
"yargs": "^17.7.1"
},
Expand Down
9 changes: 6 additions & 3 deletions packages/gas-report/ts/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { CommandModule } from "yargs";
import { readFileSync, writeFileSync } from "fs";
import { execa } from "execa";
import execa from "execa";
import chalk from "chalk";
import { table, getBorderCharacters } from "table";
import stripAnsi from "strip-ansi";
// TODO: Fix this import for cjs
// import stripAnsi from "strip-ansi";
// const stripAnsi = require('strip-ansi');

/**
* Print the gas report to the console, save it to a file and compare it to a previous gas report if provided.
Expand Down Expand Up @@ -112,7 +114,8 @@ async function runGasReport(): Promise<GasReport> {
}

// Extract the gas reports from the logs
const lines = stdout.split("\n").map(stripAnsi);
// const lines = stdout.split("\n").map(stripAnsi);
const lines = stdout.split("\n");
const gasReportPattern = /^\s*GAS REPORT: (\d+) (.*)$/;
const testFunctionPattern = /^\[(?:PASS|FAIL).*\] (\w+)\(\)/;
const testFilePattern = /^Running \d+ tests? for (.*):(.*)$/;
Expand Down
2 changes: 1 addition & 1 deletion packages/gas-report/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from "tsup";
export default defineConfig({
entry: ["ts/index.ts", "ts/mud-gas-report.ts"],
target: "esnext",
format: ["esm"],
format: ["esm", "cjs"],
dts: false,
sourcemap: true,
clean: true,
Expand Down
7 changes: 5 additions & 2 deletions packages/protocol-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
"directory": "packages/protocol-parser"
},
"license": "MIT",
"type": "module",
"exports": {
".": "./dist/index.js"
".": {
"require": "./dist/index.js",
"import": "./dist/index.js"
}
},
"main": "./dist/index.js",
"types": "src/index.ts",
"scripts": {
"build": "pnpm run build:js",
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol-parser/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/index.ts"],
target: "esnext",
format: ["esm"],
format: ["esm", "cjs"],
dts: false,
sourcemap: true,
clean: true,
Expand Down
12 changes: 9 additions & 3 deletions packages/recs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@
"directory": "packages/recs"
},
"license": "MIT",
"type": "module",
"exports": {
".": "./dist/index.js",
"./deprecated": "./dist/deprecated/index.js"
".": {
"require": "./dist/index.js",
"import": "./dist/index.js"
},
"./deprecated": {
"require": "./dist/deprecated/index.js",
"import": "./dist/deprecated/index.js"
}
},
"main": "./dist/index.js",
"typesVersions": {
"*": {
"index": [
Expand Down
2 changes: 1 addition & 1 deletion packages/recs/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/index.ts", "src/deprecated/index.ts"],
target: "esnext",
format: ["esm"],
format: ["esm", "cjs"],
dts: false,
sourcemap: true,
clean: true,
Expand Down
Loading

0 comments on commit 401e034

Please sign in to comment.