Skip to content

Commit

Permalink
CJS and MJS at the same time (#28)
Browse files Browse the repository at this point in the history
* nodenext output

* just js problems, mjs vs cjs builds done

* version
  • Loading branch information
erhant authored Feb 2, 2024
1 parent 2094cfb commit ff7851a
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 17 deletions.
1 change: 1 addition & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
transform: {
"^.+\\.(ts|js)$": "ts-jest",
},
resolver: "jest-ts-webcompat-resolver",
testTimeout: 100_000,
// do this to always show a summary of failed tests, even if there is only one
// reporters: [["default", { summaryThreshold: 1 }]],
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
{
"name": "warp-contracts-redis",
"version": "0.4.0",
"version": "0.4.1",
"description": "Redis implementation for Warp Contracts",
"types": "./lib/types/index.d.ts",
"main": "./lib/cjs/index.js",
"module": "./lib/mjs/index.js",
"type": "module",
"license": "MIT",
"author": "FirstBatch Team <[email protected]>",
"homepage": "https://github.com/firstbatchxyz/warp-contracts-redis#readme",
"contributors": [
"Faruk Can Özkan <[email protected]>",
"Erhan Tezcan <[email protected]>"
],
"exports": {
".": "./lib/cjs/index.js"
},
"sideEffects": false,
"engines": {
"node": ">=16.5"
Expand All @@ -30,9 +29,10 @@
"cache"
],
"scripts": {
"build:cjs": "tsc -b tsconfig.json",
"build:mjs": "tsc -b tsconfig.mjs.json",
"build:cjs": "tsc -b tsconfig.cjs.json",
"build:types": "tsc -b tsconfig.types.json",
"build": "pnpm run clean && pnpm build:cjs && pnpm build:types",
"build": "pnpm run clean && pnpm build:cjs && pnpm build:mjs && pnpm build:types",
"format": "prettier --write 'src/**/*.ts'",
"clean": "rimraf ./lib",
"lint": "eslint . --ext .ts",
Expand All @@ -54,8 +54,8 @@
"safe-stable-stringify": "^2.4.3"
},
"peerDependencies": {
"warp-contracts": "^1.4.2",
"ioredis": "^5.3.2"
"ioredis": "^5.3.2",
"warp-contracts": "^1.4.2"
},
"devDependencies": {
"@types/jest": "^28.1.6",
Expand All @@ -66,6 +66,7 @@
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.1",
"jest": "^29.5.0",
"jest-ts-webcompat-resolver": "^1.0.0",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.0",
Expand Down
11 changes: 11 additions & 0 deletions 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 src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { RedisCache } from "./redisCache";
export type { RedisOptions } from "./types/redisCache";
export { RedisCache } from "./redisCache.js";
export type { RedisOptions } from "./types/redisCache.js";
14 changes: 10 additions & 4 deletions src/redisCache.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import type { SortKeyCache, PruneStats, BatchDBOp, CacheOptions } from "warp-contracts";
import type { SortKeyCacheRangeOptions } from "warp-contracts/lib/types/cache/SortKeyCacheRangeOptions";
import type { ChainableCommander } from "ioredis";
import { CacheKey, genesisSortKey, LoggerFactory, SortKeyCacheResult, lastPossibleSortKey } from "warp-contracts";
import { Redis } from "ioredis";
import stringify from "safe-stable-stringify";
import { luaScripts } from "./luaScripts";
import type { RedisOptions } from "./types/redisCache";
import { stringify } from "safe-stable-stringify";
import { luaScripts } from "./luaScripts.js";
import type { RedisOptions } from "./types/redisCache.js";

interface SortKeyCacheRangeOptions {
gte?: string;
lt?: string;
reverse?: boolean | undefined;
limit?: number | undefined;
}

/**
* A deleted value placeholder is to differentiate a `null` result
Expand Down
21 changes: 21 additions & 0 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "http://json.schemastore.org/tsconfig",
"compileOnSave": false,
"compilerOptions": {
"target": "es2019",
"types": ["jest", "node"],
"module": "CommonJS",
"moduleResolution": "Node",
"sourceMap": true,
"skipLibCheck": true,
"isolatedModules": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"outDir": "./lib/cjs",
"baseUrl": "./src",
"allowJs": true
},
"include": ["src"],
"exclude": ["node_modules", "test"]
}
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"compileOnSave": false,
"compilerOptions": {
"target": "es2019",
"module": "commonjs",
"types": ["jest", "node"],
"moduleResolution": "node",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"sourceMap": true,
"skipLibCheck": true,
"outDir": "./lib/cjs",
"isolatedModules": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"outDir": "./lib/mjs",
"baseUrl": "./src",
"allowJs": true
},
Expand Down
21 changes: 21 additions & 0 deletions tsconfig.mjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "http://json.schemastore.org/tsconfig",
"compileOnSave": false,
"compilerOptions": {
"target": "es2019",
"types": ["jest", "node"],
"moduleResolution": "NodeNext",
"module": "NodeNext",
"sourceMap": true,
"skipLibCheck": true,
"isolatedModules": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"outDir": "./lib/mjs",
"baseUrl": "./src",
"allowJs": true
},
"include": ["src"],
"exclude": ["node_modules", "test"]
}

0 comments on commit ff7851a

Please sign in to comment.