Skip to content

Commit

Permalink
refactor: 💡 Updated build system
Browse files Browse the repository at this point in the history
Esm module only exported
  • Loading branch information
kostysh committed Apr 3, 2023
1 parent 9bbf7f0 commit 2d3f7ee
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 45 deletions.
4 changes: 2 additions & 2 deletions examples/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"eslint-plugin-react-refresh": "^0.3.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^4.9.3",
"typescript": "^5.0.3",
"vite": "^4.1.0",
"zod": "^3.21.4",
"@windingtree/sdk": "^0.1.0-beta.3"
"@windingtree/sdk": "latest"
},
"eslintConfig": {
"extends": [
Expand Down
11 changes: 5 additions & 6 deletions examples/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import {
contractConfig,
serverAddress,
} from '../../shared/types.js';
import { isExpired } from '../../../src/utils/time.js';
import { RequestRecord } from '../../../src/client/requestsRegistry.js';
import { createClient, Client } from '../../../src/client/index.js';
import { ClientOptions, storage } from '@windingtree/sdk';
// import { isExpired } from '@windingtree/sdk/utils';
import { Client, createClient } from '../../../src/client/index.js';
import { ClientOptions, storage, utils } from '../../../src/index.js';
// import { Client, ClientOptions, RequestRecord, createClient, storage } from '@windingtree/sdk';

/** Default request expiration time */
const defaultExpire = '30s';
Expand Down Expand Up @@ -114,10 +113,10 @@ export const Requests = ({ requests, subscribed, onClear, onCancel }: RequestsPr
<td>{r.data.id}</td>
<td>{JSON.stringify(r.data.query)}</td>
<td>{subscribed && subscribed(r.data.id) ? '✅' : 'no'}</td>
<td>{isExpired(r.data.expire) || r.cancelled ? '✅' : 'no'}</td>
<td>{utils.isExpired(r.data.expire) || r.cancelled ? '✅' : 'no'}</td>
<td>{r.offers.length}</td>
<td>
{!r.cancelled && !isExpired(r.data.expire) ? (
{!r.cancelled && !utils.isExpired(r.data.expire) ? (
<button
onClick={() => {
onCancel(r.data.id);
Expand Down
3 changes: 2 additions & 1 deletion examples/client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"moduleResolution": "NodeNext",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"noErrorTruncation": true,
"jsx": "react-jsx"
},
"include": ["src"],
Expand Down
10 changes: 5 additions & 5 deletions examples/client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,7 @@
magic-string "^0.27.0"
react-refresh "^0.14.0"

"@windingtree/sdk@^0.1.0-beta.3":
"@windingtree/sdk@latest":
version "0.1.0-beta.3"
resolved "https://registry.yarnpkg.com/@windingtree/sdk/-/sdk-0.1.0-beta.3.tgz#02678fea232da12f493fa3057cba089b2612c55a"
integrity sha512-9PEjlopjizfkfWSRAT5VTY5I3eCTIipTF59p3vHd/CUjRHGnziFYUPUKSlD8rQ8fpBtrwvFC5Iivo2c6OY1FYQ==
Expand Down Expand Up @@ -4514,10 +4514,10 @@ typed-array-length@^1.0.4:
for-each "^0.3.3"
is-typed-array "^1.1.9"

typescript@^4.9.3:
version "4.9.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==
typescript@^5.0.3:
version "5.0.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.3.tgz#fe976f0c826a88d0a382007681cbb2da44afdedf"
integrity sha512-xv8mOEDnigb/tN9PSMTwSEqAnUvkoXMQlicOb0IUVDBSQCgBSaAAROUZYy2IcUy5qU6XajK5jjjO7TMWqBTKZA==

uint8-varint@^1.0.1, uint8-varint@^1.0.2, uint8-varint@^1.0.6:
version "1.0.6"
Expand Down
27 changes: 15 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,29 @@
"type": "module",
"exports": {
".": {
"types": "./lib/cjs/types/index.d.ts",
"import": "./lib/esm/index.mjs",
"require": "./lib/cjs/index.js"
"import": "./lib/index.js"
},
"./utils": {
"types": "./lib/cjs/types/utils/index.d.ts",
"import": "./lib/esm/utils/index.js",
"require": "./lib/cjs/utils/index.js"
"import": "./lib/utils/index.js"
}
},
"types": "./lib/cjs/types/index.d.ts",
"main": "./lib/cjs/index.js",
"typesVersions": {
"*": {
"*": [
"lib/types/*",
"lib/types/utils/*"
]
}
},
"types": "./lib/types/index.d.ts",
"main": "./lib/index.js",
"files": [
"lib/**/*"
"lib/**/*",
"!**/*.tsbuildinfo"
],
"scripts": {
"clean": "rm -rf ./lib",
"build": "npm run clean && npm run build:esm && npm run build:cjs",
"build:esm": "tsc -p ./tsconfig.esm.json && mv lib/esm/index.js lib/esm/index.mjs",
"build:cjs": "tsc -p ./tsconfig.cjs.json",
"build": "npm run clean && tsc -p ./tsconfig.build.json",
"test": "mocha -t 60000 --extension spec.ts",
"semantic-release": "semantic-release",
"prepack": "npm run build",
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * as constants from './constants.js';
export * as storage from './storage/index.js';
export * as utils from './utils/index.js';
export * from './server/index.js';
export * from './client/index.js';
export * from './node/index.js';
Expand Down
1 change: 1 addition & 0 deletions src/storage/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export class LocalStorage extends Storage {
if (value !== null) {
return this.deserialize<ValueType>(value);
}
return;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions test/shared.queue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ describe('Shared.Queue', () => {
if (job.state.attempts >= counter) {
return true;
}

return;
};

queue.addJobHandler(name, handler);
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.esm.json → tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./lib/esm",
"declarationDir": "./lib/esm/types"
"outDir": "./lib",
"declarationDir": "./lib/types"
},
"exclude": ["./examples", "./test"]
}
12 changes: 0 additions & 12 deletions tsconfig.cjs.json

This file was deleted.

15 changes: 10 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"compilerOptions": {
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": ["ES2022", "DOM"],
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "NodeNext",
"skipLibCheck": true,
"checkJs": true,
"allowJs": true,
Expand All @@ -11,10 +14,12 @@
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"noErrorTruncation": true,
"lib": ["ES2022", "DOM"],
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "NodeNext"
"incremental": true,
"composite": true,
"forceConsistentCasingInFileNames": true,
"useUnknownInCatchVariables": true,
"importsNotUsedAsValues": "remove",
"noImplicitReturns": true
},
"include": ["./src/**/*.ts", "./examples/**/*.ts", "./test/**/*.ts"]
}

0 comments on commit 2d3f7ee

Please sign in to comment.