Skip to content

Commit

Permalink
feat: restore CJS compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ruicsh committed Mar 21, 2023
1 parent 46d5aef commit 5871688
Show file tree
Hide file tree
Showing 5 changed files with 397 additions and 518 deletions.
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@
"test": "vitest --watch"
},
"devDependencies": {
"@types/node": "18.14.6",
"@typescript-eslint/eslint-plugin": "5.54.1",
"@typescript-eslint/parser": "5.54.1",
"@vitest/coverage-c8": "0.29.2",
"aws-sdk": "^2.2.0",
"esbuild": "0.17.11",
"eslint": "8.35.0",
"@types/node": "18.15.5",
"@typescript-eslint/eslint-plugin": "5.56.0",
"@typescript-eslint/parser": "5.56.0",
"@vitest/coverage-c8": "0.29.7",
"aws-sdk": "^2.1340.0",
"esbuild": "0.17.12",
"eslint": "8.36.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-airbnb-typescript": "17.0.0",
"eslint-config-prettier": "8.7.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-import": "2.27.5",
"nyc": "15.1.0",
"prettier": "2.8.4",
"tsx": "3.12.3",
"typescript": "4.9.5",
"vitest": "0.29.2",
"zx": "7.2.0"
"prettier": "2.8.6",
"tsx": "3.12.6",
"typescript": "5.0.2",
"vitest": "0.29.7",
"zx": "7.2.1"
}
}
2 changes: 1 addition & 1 deletion sh/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ async function main() {

const flags = ["--bundle", "--platform=node"];

await $`esbuild src/index.ts --outfile=dist/index.cjs ${flags}`;
await $`esbuild src/cjs/index.cjs --outfile=dist/index.cjs ${flags}`;
await $`esbuild src/index.ts --format=esm --outfile=dist/index.mjs ${flags}`;

await $`cp src/dynoexpr.d.ts dist/dynoexpr.d.ts`;
Expand Down
3 changes: 3 additions & 0 deletions src/cjs/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import dynoexpr from "../index";

module.exports = dynoexpr;
4 changes: 3 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ export function toString(data: unknown) {
return `Set(${JSON.stringify(Array.from(data))}))`;
}

return typeof data === "object" ? JSON.stringify(data) : `${data}:${typeof data}`;
return typeof data === "object"
? JSON.stringify(data)
: `${data}:${typeof data}`;
}

export function md5(data: unknown) {
Expand Down

0 comments on commit 5871688

Please sign in to comment.