diff --git a/package-lock.json b/package-lock.json index 61cf4ab..4331c51 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@clober/v2-sdk", - "version": "0.0.2", + "version": "0.0.2-b", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@clober/v2-sdk", - "version": "0.0.2", + "version": "0.0.2-b", "license": "MIT", "dependencies": { "bignumber.js": "^9.1.2", diff --git a/package.json b/package.json index b56e04e..331f729 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@clober/v2-sdk", - "version": "0.0.2-a", + "version": "0.0.3", "description": "🛠 An SDK for building applications on top of Clober V2", "files": [ "dist" @@ -25,9 +25,10 @@ "docs": "typedoc --out docs src/index.ts --sort kind", "test": "vitest --root test --config vitest.config.ts --max-concurrency=0", "clean": "rm -rf dist", - "build": "npm run clean && npm run build:cjs && npm run build:esm+types", - "build:cjs": "tsc --project tsconfig.build.json --module commonjs --verbatimModuleSyntax false --outDir ./dist/cjs && echo > ./dist/cjs/package.json '{\"type\":\"commonjs\"}'", - "build:esm+types": "tsc --project tsconfig.build.json --module es2020 --outDir ./dist/esm --declaration --declarationMap --declarationDir ./dist/types && echo > ./dist/esm/package.json '{\"type\":\"module\"}'" + "build": "npm run clean && npm run build:cjs && npm run build:esm && npm run build:types", + "build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir ./dist/cjs --removeComments && printf '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json", + "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir ./dist/esm && printf '{\"type\": \"module\",\"sideEffects\":false}' > ./dist/esm/package.json", + "build:types": "tsc --project tsconfig.build.json --module esnext --outDir ./dist/types --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap" }, "keywords": [], "author": "Clober", diff --git a/tsconfig.base.json b/tsconfig.base.json index 7b619d5..18fe2a8 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,37 +1,44 @@ { + // This tsconfig file contains the shared config for the build (tsconfig.build.json) and type checking (tsconfig.json) config. "include": [], "compilerOptions": { // Incremental builds + // NOTE: Enabling incremental builds speeds up `tsc`. Keep in mind though that it does not reliably bust the cache when the `tsconfig.json` file changes. "incremental": true, // Type checking "strict": true, - "skipLibCheck": true, - "useDefineForClassFields": true, + "useDefineForClassFields": true, // Not enabled by default in `strict` mode unless we bump `target` to ES2022. + "noFallthroughCasesInSwitch": true, // Not enabled by default in `strict` mode. + "noImplicitReturns": true, // Not enabled by default in `strict` mode. + "useUnknownInCatchVariables": true, // TODO: This would normally be enabled in `strict` mode but would require some adjustments to the codebase. + "noImplicitOverride": true, // Not enabled by default in `strict` mode. + "noUnusedLocals": true, // Not enabled by default in `strict` mode. + "noUnusedParameters": true, // Not enabled by default in `strict` mode. "exactOptionalPropertyTypes": true, - "noFallthroughCasesInSwitch": true, - "noImplicitOverride": true, - "noImplicitReturns": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noUncheckedIndexedAccess": true, - - // Modules - "module": "ES2022", - "moduleResolution": "node", + // TODO: Uncomment and fix types. + // "noUncheckedIndexedAccess": true, // JavaScript support "allowJs": false, "checkJs": false, // Interop constraints + "esModuleInterop": false, + "allowSyntheticDefaultImports": false, "forceConsistentCasingInFileNames": true, + "importHelpers": true, // This is only used for build validation. Since we do not have `tslib` installed, this will fail if we accidentally make use of anything that'd require injection of helpers. // Language and environment - "lib": ["ESNext"], - "target": "ESNext", + "moduleResolution": "NodeNext", + "module": "NodeNext", + "target": "ES2021", // Setting this to `ES2021` enables native support for `Node v16+`: https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping. + "lib": [ + "ES2022", // By using ES2022 we get access to the `.cause` property on `Error` instances. + "DOM" // We are adding `DOM` here to get the `fetch`, etc. types. This should be removed once these types are available via DefinitelyTyped. + ], - // Sourcemaps - "sourceMap": true + // Skip type checking for node modules + "skipLibCheck": true, } -} +} \ No newline at end of file diff --git a/tsconfig.build.json b/tsconfig.build.json index 4314d03..1d9e489 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,9 +1,11 @@ { + // This file is used to compile the for cjs and esm (see package.json build scripts). It should exclude all test files. "extends": "./tsconfig.base.json", "include": ["src/**/*.ts"], "exclude": ["src/**/*.test.ts"], "compilerOptions": { - "types": ["node"], - "lib": ["DOM"] + "moduleResolution": "node", + "sourceMap": true, + "rootDir": "./src" } -} +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 4314d03..acd6603 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,8 +2,5 @@ "extends": "./tsconfig.base.json", "include": ["src/**/*.ts"], "exclude": ["src/**/*.test.ts"], - "compilerOptions": { - "types": ["node"], - "lib": ["DOM"] - } + "references": [{ "path": "./scripts/tsconfig.json" }] }