diff --git a/.eslintrc.js b/.eslintrc.js index 515f3de43..ed000b621 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -20,7 +20,7 @@ module.exports = { parserOptions: { ecmaVersion: 2018, sourceType: 'module', - project: './tsconfig.json', + project: './tsconfig.base.json', }, plugins: [ '@typescript-eslint', diff --git a/.github/workflows/devpackpublish.yml b/.github/workflows/devpackpublish.yml index a84bf6c8e..0e5f80e94 100644 --- a/.github/workflows/devpackpublish.yml +++ b/.github/workflows/devpackpublish.yml @@ -36,7 +36,7 @@ jobs: PACKAGE_VERSION: ${{ steps.package_version.outputs.package_version }} run: yarn set:version $PACKAGE_VERSION --allow-same-version - name: Build packages - run: yarn run build + run: yarn run build:release - name: Bundle library run: yarn run bundle - name: Publish to npm diff --git a/.github/workflows/npmpublish-rc.yml b/.github/workflows/npmpublish-rc.yml index ece3e6a33..f395ccacb 100644 --- a/.github/workflows/npmpublish-rc.yml +++ b/.github/workflows/npmpublish-rc.yml @@ -11,7 +11,7 @@ jobs: with: node-version: 14 - run: yarn install --immutable - - run: yarn build + - run: yarn build:release - run: yarn test:ci publish-npm: diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml index 7957abf81..a92bef659 100644 --- a/.github/workflows/npmpublish.yml +++ b/.github/workflows/npmpublish.yml @@ -11,7 +11,7 @@ jobs: with: node-version: 14 - run: yarn install --immutable - - run: yarn build + - run: yarn build:release - run: yarn test:ci publish-npm: diff --git a/.github/workflows/tests-polkadot-deps.yml b/.github/workflows/tests-polkadot-deps.yml index fe4494ed0..c42e1b672 100644 --- a/.github/workflows/tests-polkadot-deps.yml +++ b/.github/workflows/tests-polkadot-deps.yml @@ -53,7 +53,7 @@ jobs: yarn.lock - name: yarn build - run: yarn build + run: yarn build:release - name: zip build run: zip -r build.zip . - name: upload build diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d0edfbeac..41f7b8e4c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,7 +45,7 @@ jobs: - name: yarn install run: yarn install --immutable - name: yarn build - run: yarn build + run: yarn build:release - name: zip build run: zip -r build.zip . - name: upload build diff --git a/.gitignore b/.gitignore index ab315dc52..45434b674 100644 --- a/.gitignore +++ b/.gitignore @@ -29,13 +29,12 @@ lib .env.test.local .env.production.local settings.json +tsconfig.tsbuildinfo # doc **/docs/api +/docs/api # misc /.idea .vscode - -# doc -/docs/api diff --git a/Dockerfile b/Dockerfile index 30cb813e1..8abb722d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,6 @@ WORKDIR /app COPY . ./ RUN yarn install -RUN yarn build +RUN yarn build:release RUN yarn lint RUN yarn test diff --git a/babel.config.json b/babel.config.json index c99be6aa9..13280383c 100644 --- a/babel.config.json +++ b/babel.config.json @@ -1,10 +1,10 @@ { - "presets": [ - [ - "@babel/preset-env", - { - "modules": "commonjs" - } - ] + "presets": [ + [ + "@babel/preset-env", + { + "modules": "commonjs" + } ] -} \ No newline at end of file + ] +} diff --git a/docs/contribution-guide.md b/docs/contribution-guide.md index 23b9b702f..e359cc016 100644 --- a/docs/contribution-guide.md +++ b/docs/contribution-guide.md @@ -23,7 +23,7 @@ We're using [typedoc][typedoc] to generate the API doc from the docBlocks. ### Documenting modules -Direct child folders of `src` such as `attestation` should be marked as `@modules`, so that they're listed in the [online API Doc][apidoc] main menu. +Direct child folders of `src` such as `attestation` should be marked as `@module`, so that they're listed in the [online API Doc][apidoc] main menu. Some of these modules are purely technical utilities, such as `crypto`. Others map to KILT concepts, such as `attestation`. @@ -72,6 +72,16 @@ If you have a doubt: ⚠️ Make sure you don't commit these generated files. +## Building and testing + +For development purposes you can build the SDK from typescript sources by running `yarn build` in the root folder of the repository. +After switching branches of if you experience issues during building or testing it is recommended to run `yarn clean` before building to delete all build artifacts and thus force a fresh build. + +Before packaging the SDK e.g. for release on npm, you must run `yarn build:release`, which not only forces a clean build but also produces ES6 modules code in addition to CJS output. +Building ESM code is skipped in `yarn build` to speed up the build/rebuild process. + +When running jest in `--watch` mode, you should have `yarn build:watch` running in a separate terminal window to make sure file changes are immediately picked up an trigger a rebuild. + ## Tests Test coverage does not seem to be fail in all cases, except for testWatch. diff --git a/jest.config.js b/jest.config.js index 17ce455e6..da41a0edd 100644 --- a/jest.config.js +++ b/jest.config.js @@ -6,7 +6,9 @@ module.exports = { // Parachain block time is 12s testTimeout: 15000, setupFilesAfterEnv: ['../jest-setup/setup.js'], - transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)'], + transformIgnorePatterns: [ + '/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)', + ], coverageThreshold: { global: { branches: 70, @@ -16,8 +18,8 @@ module.exports = { }, }, transform: { - "\\.js$": "babel-jest", - "\\.ts$": "ts-jest" + '\\.js$': 'babel-jest', + '\\.ts$': 'ts-jest', }, collectCoverageFrom: [ '**/*/src/**/*.ts', @@ -40,11 +42,12 @@ module.exports = { '!did/src/Did.utils.ts', '!utils/src/jsonabc.ts', ], - resolver: "ts-jest-resolver", + resolver: 'ts-jest-resolver', rootDir: 'packages', coverageDirectory: 'coverage', - moduleDirectories: [ - "node_modules", - "packages/*/src" - ] + globals: { + 'ts-jest': { + tsconfig: 'tsconfig.base.json', + }, + }, } diff --git a/package.json b/package.json index 948a6e835..c6942d830 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "repository": "https://github.com/kiltprotocol/sdk-js", + "name": "root-workspace", "private": true, "workspaces": [ "packages/*", @@ -7,11 +8,13 @@ ], "license": "BSD-4-Clause", "scripts": { - "check": "tsc -p tsconfig.json --noEmit", - "build": "yarn workspaces foreach -p -t --exclude '{root-workspace}' run build", + "check": "tsc -b tsconfig.json", + "build:release": "yarn clean && yarn workspaces foreach -pt --exclude 'root-workspace' run build", + "build": "yarn workspaces foreach -pt --exclude 'root-workspace' run build:cjs", + "build:watch": "yarn build:dev && tsc -b tsconfig.json --watch", "build:docs": "typedoc --theme default --out docs/api --tsconfig tsconfig.docs.json && touch docs/.nojekyll", "bundle": "yarn workspace @kiltprotocol/sdk-js run bundle", - "clean": "rimraf tests/dist && yarn workspaces foreach -p --exclude '{root-workspace}' run clean", + "clean": "rimraf tests/dist && yarn workspaces foreach -p --exclude 'root-workspace' run clean", "clean:docs": "rimraf docs/api", "prepublish": "yarn workspaces foreach -p --no-private exec cp -f ../../LICENSE .", "publish": "yarn workspaces foreach -pt --no-private npm publish", diff --git a/packages/asset-did/package.json b/packages/asset-did/package.json index e57e0dc34..fc0b9b9e8 100644 --- a/packages/asset-did/package.json +++ b/packages/asset-did/package.json @@ -12,14 +12,15 @@ } }, "files": [ - "lib/**/*" + "lib/**/*.js", + "lib/**/*.d.ts", + "lib/**/*.json" ], "scripts": { "clean": "rimraf ./lib", - "build": "yarn clean && yarn build:ts", - "build:ts": "yarn build:cjs && yarn build:esm", - "build:cjs": "tsc --declaration -p tsconfig.build.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", - "build:esm": "tsc --declaration -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc -b && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", + "build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" }, "repository": "github:kiltprotocol/sdk-js", "engines": { @@ -32,5 +33,9 @@ "dependencies": { "@kiltprotocol/types": "workspace:*", "@kiltprotocol/utils": "workspace:*" + }, + "devDependencies": { + "rimraf": "^3.0.2", + "typescript": "^4.8.3" } } diff --git a/packages/asset-did/tsconfig.build.json b/packages/asset-did/tsconfig.build.json deleted file mode 100644 index ab24dae00..000000000 --- a/packages/asset-did/tsconfig.build.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tsconfig.build.json", - - "compilerOptions": { - "module": "CommonJS", - "outDir": "./lib/cjs" - }, - - "include": [ - "src/**/*.ts", "src/**/*.js" - ], - - "exclude": [ - "coverage", - "**/*.spec.ts", - ] -} diff --git a/packages/asset-did/tsconfig.esm.json b/packages/asset-did/tsconfig.esm.json index e1f3b73b6..59d05a455 100644 --- a/packages/asset-did/tsconfig.esm.json +++ b/packages/asset-did/tsconfig.esm.json @@ -1,7 +1,9 @@ { - "extends": "./tsconfig.build.json", + "extends": "./tsconfig.json", "compilerOptions": { "module": "ES6", - "outDir": "./lib/esm" + "outDir": "./lib/esm", + "declaration": false, + "composite": false } } diff --git a/packages/asset-did/tsconfig.json b/packages/asset-did/tsconfig.json new file mode 100644 index 000000000..baf037048 --- /dev/null +++ b/packages/asset-did/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./lib/cjs", + "rootDir": "./src" + }, + "include": ["src/**/*.ts", "src/**/*.js"], + "exclude": ["coverage", "**/*.spec.ts"], + // indicates package dependencies; must be in sync with @kiltprotocol imports in package.json + "references": [ + { + "path": "../types" + }, + { + "path": "../utils" + } + ] +} diff --git a/packages/augment-api/package.json b/packages/augment-api/package.json index ce83c66d3..a3007a004 100644 --- a/packages/augment-api/package.json +++ b/packages/augment-api/package.json @@ -13,16 +13,17 @@ } }, "files": [ - "lib/**/*" + "lib/**/*.js", + "lib/**/*.d.ts", + "lib/**/*.json" ], "scripts": { "clean": "rimraf ./lib", - "build": "yarn clean && yarn build:ts", + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc -b tsconfig.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", + "build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json", "build:types": "yarn generate:defs && yarn generate:meta && yarn build:fixes", "build:fixes": "node scripts/fixTypes.mjs", - "build:ts": "yarn build:cjs && yarn build:esm", - "build:cjs": "tsc --declaration -p tsconfig.build.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", - "build:esm": "tsc --declaration -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json", "generate:defs": "ts-node --skip-project ../../node_modules/.bin/polkadot-types-from-defs --package @kiltprotocol/augment-api --input ./src/interfaces --endpoint ./metadata/spiritnet.json", "generate:meta": "ts-node --skip-project ../../node_modules/.bin/polkadot-types-from-chain --package @kiltprotocol/augment-api --endpoint ./metadata/spiritnet.json --output ./src/interfaces --strict", "update-metadata": "node ./scripts/fetchMetadata.js -o './metadata/spiritnet.json' -e 'wss://spiritnet.kilt.io/'" diff --git a/packages/augment-api/tsconfig.build.json b/packages/augment-api/tsconfig.build.json deleted file mode 100644 index 46233a664..000000000 --- a/packages/augment-api/tsconfig.build.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "extends": "../../tsconfig.build.json", - "compilerOptions": { - "module": "CommonJS", - "outDir": "./lib/cjs", - "skipLibCheck": true, - "noUnusedLocals": false, - "paths": { - "@kiltprotocol/augment-api/*": [ - "./src/*" - ], - "@polkadot/api/augment": [ - "./src/interfaces/augment-api.ts" - ], - "@polkadot/types/augment": [ - "./src/interfaces/augment-types.ts" - ] - } - }, - "include": [ - "src/**/*.ts", - "src/**/*.js" - ], - "exclude": [ - "coverage", - "**/*.spec.ts", - "src/**/definitions.ts", - ], -} \ No newline at end of file diff --git a/packages/augment-api/tsconfig.esm.json b/packages/augment-api/tsconfig.esm.json index e1f3b73b6..59d05a455 100644 --- a/packages/augment-api/tsconfig.esm.json +++ b/packages/augment-api/tsconfig.esm.json @@ -1,7 +1,9 @@ { - "extends": "./tsconfig.build.json", + "extends": "./tsconfig.json", "compilerOptions": { "module": "ES6", - "outDir": "./lib/esm" + "outDir": "./lib/esm", + "declaration": false, + "composite": false } } diff --git a/packages/augment-api/tsconfig.json b/packages/augment-api/tsconfig.json new file mode 100644 index 000000000..2f6ab48aa --- /dev/null +++ b/packages/augment-api/tsconfig.json @@ -0,0 +1,22 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./lib/cjs", + "rootDir": "./src", + "skipLibCheck": true, + "noUnusedLocals": false, + "paths": { + "@kiltprotocol/augment-api/*": ["./src/*"], + "@polkadot/api/augment": ["./src/interfaces/augment-api.ts"], + "@polkadot/types/augment": ["./src/interfaces/augment-types.ts"] + } + }, + "include": ["src/**/*.ts", "src/**/*.js"], + "exclude": ["coverage", "**/*.spec.ts", "src/**/definitions.ts"], + // indicates package dependencies; must be in sync with @kiltprotocol imports in package.json + "references": [ + { + "path": "../type-definitions" + } + ] +} diff --git a/packages/chain-helpers/package.json b/packages/chain-helpers/package.json index 9defe62a1..b5b2ae8b6 100644 --- a/packages/chain-helpers/package.json +++ b/packages/chain-helpers/package.json @@ -12,14 +12,15 @@ } }, "files": [ - "lib/**/*" + "lib/**/*.js", + "lib/**/*.d.ts", + "lib/**/*.json" ], "scripts": { "clean": "rimraf ./lib", - "build": "yarn clean && yarn build:ts", - "build:ts": "yarn build:cjs && yarn build:esm", - "build:cjs": "tsc --declaration -p tsconfig.build.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", - "build:esm": "tsc --declaration -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc -b tsconfig.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", + "build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" }, "repository": "github:kiltprotocol/sdk-js", "engines": { diff --git a/packages/chain-helpers/tsconfig.build.json b/packages/chain-helpers/tsconfig.build.json deleted file mode 100644 index acadb671e..000000000 --- a/packages/chain-helpers/tsconfig.build.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "../../tsconfig.build.json", - - "compilerOptions": { - "module": "CommonJS", - "outDir": "./lib/cjs" - }, - - "include": [ - "src/**/*.ts", "src/**/*.js" - ], - "exclude": [ - "node_modules", - "**/*.spec.ts" - ] -} diff --git a/packages/chain-helpers/tsconfig.esm.json b/packages/chain-helpers/tsconfig.esm.json index e1f3b73b6..59d05a455 100644 --- a/packages/chain-helpers/tsconfig.esm.json +++ b/packages/chain-helpers/tsconfig.esm.json @@ -1,7 +1,9 @@ { - "extends": "./tsconfig.build.json", + "extends": "./tsconfig.json", "compilerOptions": { "module": "ES6", - "outDir": "./lib/esm" + "outDir": "./lib/esm", + "declaration": false, + "composite": false } } diff --git a/packages/chain-helpers/tsconfig.json b/packages/chain-helpers/tsconfig.json new file mode 100644 index 000000000..1e187889b --- /dev/null +++ b/packages/chain-helpers/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./lib/cjs", + "rootDir": "./src" + }, + "include": ["src/**/*.ts", "src/**/*.js"], + "exclude": ["coverage", "**/*.spec.ts"], + // indicates package dependencies; must be in sync with @kiltprotocol imports in package.json + "references": [ + { "path": "../config" }, + { "path": "../types" }, + { "path": "../utils" } + ] +} diff --git a/packages/config/package.json b/packages/config/package.json index 66ee8071c..f1db6953f 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -12,14 +12,15 @@ } }, "files": [ - "lib/**/*" + "lib/**/*.js", + "lib/**/*.d.ts", + "lib/**/*.json" ], "scripts": { "clean": "rimraf ./lib", - "build": "yarn clean && yarn build:ts", - "build:ts": "yarn build:cjs && yarn build:esm", - "build:cjs": "tsc --declaration -p tsconfig.build.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", - "build:esm": "tsc --declaration -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc -b tsconfig.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", + "build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" }, "repository": "github:kiltprotocol/sdk-js", "engines": { diff --git a/packages/config/tsconfig.build.json b/packages/config/tsconfig.build.json deleted file mode 100644 index 8af083c78..000000000 --- a/packages/config/tsconfig.build.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tsconfig.build.json", - - "compilerOptions": { - "module": "CommonJS", - "outDir": "./lib/cjs" - }, - - "include": [ - "src/**/*.ts", "src/**/*.js" - ], - - "exclude": [ - "node_modules", - "**/*.spec.ts", - ] -} diff --git a/packages/config/tsconfig.esm.json b/packages/config/tsconfig.esm.json index e1f3b73b6..59d05a455 100644 --- a/packages/config/tsconfig.esm.json +++ b/packages/config/tsconfig.esm.json @@ -1,7 +1,9 @@ { - "extends": "./tsconfig.build.json", + "extends": "./tsconfig.json", "compilerOptions": { "module": "ES6", - "outDir": "./lib/esm" + "outDir": "./lib/esm", + "declaration": false, + "composite": false } } diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json new file mode 100644 index 000000000..ab5460124 --- /dev/null +++ b/packages/config/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./lib/cjs", + "rootDir": "./src" + }, + "include": ["src/**/*.ts", "src/**/*.js"], + "exclude": ["coverage", "**/*.spec.ts"], + // indicates package dependencies; must be in sync with @kiltprotocol imports in package.json + "references": [{ "path": "../types" }, { "path": "../utils" }] +} diff --git a/packages/core/package.json b/packages/core/package.json index 467428978..6eea8f282 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -12,14 +12,15 @@ } }, "files": [ - "lib/**/*" + "lib/**/*.js", + "lib/**/*.d.ts", + "lib/**/*.json" ], "scripts": { "clean": "rimraf ./lib", - "build": "yarn clean && yarn build:ts", - "build:ts": "yarn build:cjs && yarn build:esm", - "build:cjs": "tsc --declaration -p tsconfig.build.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", - "build:esm": "tsc --declaration -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc -b tsconfig.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", + "build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" }, "repository": "github:kiltprotocol/sdk-js", "engines": { diff --git a/packages/core/tsconfig.build.json b/packages/core/tsconfig.build.json deleted file mode 100644 index 8a71ad3e7..000000000 --- a/packages/core/tsconfig.build.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "extends": "../../tsconfig.build.json", - - "compilerOptions": { - "module": "CommonJS", - "outDir": "./lib/cjs" - }, - - "include": [ - "src/**/*.ts", "src/**/*.js" - ], - - "exclude": [ - "node_modules", - "coverage", - "build", - "scripts", - "acceptance-tests", - "webpack", - "jest", - "src/setupTests.ts", - "jest.config.js", - "docs", - "**/*.spec.ts", - "src/__integrationtests__", - "**/test" - ] -} diff --git a/packages/core/tsconfig.esm.json b/packages/core/tsconfig.esm.json index e1f3b73b6..59d05a455 100644 --- a/packages/core/tsconfig.esm.json +++ b/packages/core/tsconfig.esm.json @@ -1,7 +1,9 @@ { - "extends": "./tsconfig.build.json", + "extends": "./tsconfig.json", "compilerOptions": { "module": "ES6", - "outDir": "./lib/esm" + "outDir": "./lib/esm", + "declaration": false, + "composite": false } } diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json new file mode 100644 index 000000000..a396032bc --- /dev/null +++ b/packages/core/tsconfig.json @@ -0,0 +1,34 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./lib/cjs", + "rootDir": "./src" + }, + "include": ["src/**/*.ts", "src/**/*.js"], + "exclude": [ + "node_modules", + "coverage", + "build", + "scripts", + "acceptance-tests", + "webpack", + "jest", + "src/setupTests.ts", + "jest.config.js", + "docs", + "**/*.spec.ts", + "src/__integrationtests__", + "**/test" + ], + // indicates package dependencies; must be in sync with @kiltprotocol imports in package.json + "references": [ + { "path": "../asset-did" }, + { "path": "../augment-api" }, + { "path": "../chain-helpers" }, + { "path": "../config" }, + { "path": "../did" }, + { "path": "../type-definitions" }, + { "path": "../types" }, + { "path": "../utils" } + ] +} diff --git a/packages/did/package.json b/packages/did/package.json index 21e1bfa98..b44bd72b5 100644 --- a/packages/did/package.json +++ b/packages/did/package.json @@ -12,14 +12,15 @@ } }, "files": [ - "lib/**/*" + "lib/**/*.js", + "lib/**/*.d.ts", + "lib/**/*.json" ], "scripts": { "clean": "rimraf ./lib", - "build": "yarn clean && yarn build:ts", - "build:ts": "yarn build:cjs && yarn build:esm", - "build:cjs": "tsc --declaration -p tsconfig.build.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", - "build:esm": "tsc --declaration -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc -b tsconfig.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", + "build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" }, "repository": "github:kiltprotocol/sdk-js", "engines": { diff --git a/packages/did/tsconfig.build.json b/packages/did/tsconfig.build.json deleted file mode 100644 index ab24dae00..000000000 --- a/packages/did/tsconfig.build.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tsconfig.build.json", - - "compilerOptions": { - "module": "CommonJS", - "outDir": "./lib/cjs" - }, - - "include": [ - "src/**/*.ts", "src/**/*.js" - ], - - "exclude": [ - "coverage", - "**/*.spec.ts", - ] -} diff --git a/packages/did/tsconfig.esm.json b/packages/did/tsconfig.esm.json index e1f3b73b6..59d05a455 100644 --- a/packages/did/tsconfig.esm.json +++ b/packages/did/tsconfig.esm.json @@ -1,7 +1,9 @@ { - "extends": "./tsconfig.build.json", + "extends": "./tsconfig.json", "compilerOptions": { "module": "ES6", - "outDir": "./lib/esm" + "outDir": "./lib/esm", + "declaration": false, + "composite": false } } diff --git a/packages/did/tsconfig.json b/packages/did/tsconfig.json new file mode 100644 index 000000000..93a624d98 --- /dev/null +++ b/packages/did/tsconfig.json @@ -0,0 +1,30 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./lib/cjs", + "rootDir": "./src" + }, + "include": ["src/**/*.ts", "src/**/*.js"], + "exclude": [ + "node_modules", + "coverage", + "build", + "scripts", + "acceptance-tests", + "webpack", + "jest", + "src/setupTests.ts", + "jest.config.js", + "docs", + "**/*.spec.ts", + "src/__integrationtests__", + "**/test" + ], + // indicates package dependencies; must be in sync with @kiltprotocol imports in package.json + "references": [ + { "path": "../augment-api" }, + { "path": "../config" }, + { "path": "../types" }, + { "path": "../utils" } + ] +} diff --git a/packages/messaging/package.json b/packages/messaging/package.json index 72c6b1597..e1987037d 100644 --- a/packages/messaging/package.json +++ b/packages/messaging/package.json @@ -12,14 +12,15 @@ } }, "files": [ - "lib/**/*" + "lib/**/*.js", + "lib/**/*.d.ts", + "lib/**/*.json" ], "scripts": { "clean": "rimraf ./lib", - "build": "yarn clean && yarn build:ts", - "build:ts": "yarn build:cjs && yarn build:esm", - "build:cjs": "tsc --declaration -p tsconfig.build.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", - "build:esm": "tsc --declaration -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc -b tsconfig.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", + "build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" }, "repository": "github:kiltprotocol/sdk-js", "engines": { diff --git a/packages/messaging/tsconfig.build.json b/packages/messaging/tsconfig.build.json deleted file mode 100644 index ab24dae00..000000000 --- a/packages/messaging/tsconfig.build.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tsconfig.build.json", - - "compilerOptions": { - "module": "CommonJS", - "outDir": "./lib/cjs" - }, - - "include": [ - "src/**/*.ts", "src/**/*.js" - ], - - "exclude": [ - "coverage", - "**/*.spec.ts", - ] -} diff --git a/packages/messaging/tsconfig.esm.json b/packages/messaging/tsconfig.esm.json index e1f3b73b6..59d05a455 100644 --- a/packages/messaging/tsconfig.esm.json +++ b/packages/messaging/tsconfig.esm.json @@ -1,7 +1,9 @@ { - "extends": "./tsconfig.build.json", + "extends": "./tsconfig.json", "compilerOptions": { "module": "ES6", - "outDir": "./lib/esm" + "outDir": "./lib/esm", + "declaration": false, + "composite": false } } diff --git a/packages/messaging/tsconfig.json b/packages/messaging/tsconfig.json new file mode 100644 index 000000000..3d51513b7 --- /dev/null +++ b/packages/messaging/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./lib/cjs", + "rootDir": "./src" + }, + "include": ["src/**/*.ts", "src/**/*.js"], + "exclude": ["coverage", "**/*.spec.ts"], + // indicates package dependencies; must be in sync with @kiltprotocol imports in package.json + "references": [ + { "path": "../core" }, + { "path": "../did" }, + { "path": "../types" }, + { "path": "../utils" } + ] +} diff --git a/packages/sdk-js/package.json b/packages/sdk-js/package.json index 7d010dd97..3296168cf 100644 --- a/packages/sdk-js/package.json +++ b/packages/sdk-js/package.json @@ -12,15 +12,16 @@ } }, "files": [ - "lib/**/*", + "lib/**/*.js", + "lib/**/*.d.ts", + "lib/**/*.json", "dist/*" ], "scripts": { "clean": "rimraf ./lib dist", - "build": "yarn clean && yarn build:ts", - "build:ts": "yarn build:cjs && yarn build:esm", - "build:cjs": "tsc --declaration -p tsconfig.build.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", - "build:esm": "tsc --declaration -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json", + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc -b tsconfig.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", + "build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json", "bundle": "rimraf ./dist && webpack --config webpack.config.js" }, "repository": "github:kiltprotocol/sdk-js", diff --git a/packages/sdk-js/tsconfig.build.json b/packages/sdk-js/tsconfig.build.json deleted file mode 100644 index c7b062afb..000000000 --- a/packages/sdk-js/tsconfig.build.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../../tsconfig.build.json", - - "compilerOptions": { - "module": "CommonJS", - "outDir": "./lib/cjs" - }, - - "include": [ - "src/**/*.ts", "src/**/*.js" - ] -} diff --git a/packages/sdk-js/tsconfig.esm.json b/packages/sdk-js/tsconfig.esm.json index e1f3b73b6..59d05a455 100644 --- a/packages/sdk-js/tsconfig.esm.json +++ b/packages/sdk-js/tsconfig.esm.json @@ -1,7 +1,9 @@ { - "extends": "./tsconfig.build.json", + "extends": "./tsconfig.json", "compilerOptions": { "module": "ES6", - "outDir": "./lib/esm" + "outDir": "./lib/esm", + "declaration": false, + "composite": false } } diff --git a/packages/sdk-js/tsconfig.json b/packages/sdk-js/tsconfig.json new file mode 100644 index 000000000..1b74b0e67 --- /dev/null +++ b/packages/sdk-js/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./lib/cjs", + "rootDir": "./src" + }, + "include": ["src/**/*.ts", "src/**/*.js"], + "exclude": ["coverage", "**/*.spec.ts"], + // indicates package dependencies; must be in sync with @kiltprotocol imports in package.json + "references": [ + { "path": "../chain-helpers" }, + { "path": "../config" }, + { "path": "../core" }, + { "path": "../did" }, + { "path": "../messaging" }, + { "path": "../types" }, + { "path": "../utils" } + ] +} diff --git a/packages/testing/package.json b/packages/testing/package.json index d4907dca2..7264cd9cc 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -13,14 +13,15 @@ } }, "files": [ - "lib/**/*" + "lib/**/*.js", + "lib/**/*.d.ts", + "lib/**/*.json" ], "scripts": { "clean": "rimraf ./lib", - "build": "yarn clean && yarn build:ts", - "build:ts": "yarn build:cjs && yarn build:esm", - "build:cjs": "tsc --declaration -p tsconfig.build.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", - "build:esm": "tsc --declaration -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc -b tsconfig.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", + "build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" }, "repository": "github:kiltprotocol/sdk-js", "engines": { diff --git a/packages/testing/tsconfig.build.json b/packages/testing/tsconfig.build.json deleted file mode 100644 index d59aa31ce..000000000 --- a/packages/testing/tsconfig.build.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tsconfig.build.json", - - "compilerOptions": { - "module": "CommonJS", - "outDir": "./lib/cjs" - }, - - "include": [ - "src/**/*.ts", "src/**/*.js" - ], - - "exclude": [ - "coverage", - "**/*.spec.ts", - ] -} diff --git a/packages/testing/tsconfig.esm.json b/packages/testing/tsconfig.esm.json index e1f3b73b6..59d05a455 100644 --- a/packages/testing/tsconfig.esm.json +++ b/packages/testing/tsconfig.esm.json @@ -1,7 +1,9 @@ { - "extends": "./tsconfig.build.json", + "extends": "./tsconfig.json", "compilerOptions": { "module": "ES6", - "outDir": "./lib/esm" + "outDir": "./lib/esm", + "declaration": false, + "composite": false } } diff --git a/packages/testing/tsconfig.json b/packages/testing/tsconfig.json new file mode 100644 index 000000000..ac47556e4 --- /dev/null +++ b/packages/testing/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./lib/cjs", + "rootDir": "./src" + }, + "include": ["src/**/*.ts", "src/**/*.js"], + "exclude": ["coverage", "**/*.spec.ts"], + // indicates package dependencies; must be in sync with @kiltprotocol imports in package.json + "references": [ + { "path": "../chain-helpers" }, + { "path": "../config" }, + { "path": "../did" }, + { "path": "../type-definitions" }, + { "path": "../types" }, + { "path": "../utils" } + ] +} diff --git a/packages/type-definitions/package.json b/packages/type-definitions/package.json index cb132eb38..7f29b7ce6 100644 --- a/packages/type-definitions/package.json +++ b/packages/type-definitions/package.json @@ -12,14 +12,15 @@ } }, "files": [ - "lib/**/*" + "lib/**/*.js", + "lib/**/*.d.ts", + "lib/**/*.json" ], "scripts": { "clean": "rimraf ./lib", - "build": "yarn clean && yarn build:ts", - "build:ts": "yarn build:cjs && yarn build:esm", - "build:cjs": "tsc --declaration -p tsconfig.build.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", - "build:esm": "tsc --declaration -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc -b tsconfig.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", + "build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" }, "repository": "github:kiltprotocol/sdk-js", "engines": { diff --git a/packages/type-definitions/tsconfig.build.json b/packages/type-definitions/tsconfig.build.json deleted file mode 100644 index d59aa31ce..000000000 --- a/packages/type-definitions/tsconfig.build.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tsconfig.build.json", - - "compilerOptions": { - "module": "CommonJS", - "outDir": "./lib/cjs" - }, - - "include": [ - "src/**/*.ts", "src/**/*.js" - ], - - "exclude": [ - "coverage", - "**/*.spec.ts", - ] -} diff --git a/packages/type-definitions/tsconfig.esm.json b/packages/type-definitions/tsconfig.esm.json index e1f3b73b6..59d05a455 100644 --- a/packages/type-definitions/tsconfig.esm.json +++ b/packages/type-definitions/tsconfig.esm.json @@ -1,7 +1,9 @@ { - "extends": "./tsconfig.build.json", + "extends": "./tsconfig.json", "compilerOptions": { "module": "ES6", - "outDir": "./lib/esm" + "outDir": "./lib/esm", + "declaration": false, + "composite": false } } diff --git a/packages/type-definitions/tsconfig.json b/packages/type-definitions/tsconfig.json new file mode 100644 index 000000000..2d8492e57 --- /dev/null +++ b/packages/type-definitions/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./lib/cjs", + "rootDir": "./src" + }, + "include": ["src/**/*.ts", "src/**/*.js"], + "exclude": ["coverage", "**/*.spec.ts"] +} diff --git a/packages/types/package.json b/packages/types/package.json index 186096adb..91d161a20 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -12,14 +12,15 @@ } }, "files": [ - "lib/**/*" + "lib/**/*.js", + "lib/**/*.d.ts", + "lib/**/*.json" ], "scripts": { "clean": "rimraf ./lib", - "build": "yarn clean && yarn build:ts", - "build:ts": "yarn build:cjs && yarn build:esm", - "build:cjs": "tsc --declaration -p tsconfig.build.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", - "build:esm": "tsc --declaration -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc -b tsconfig.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", + "build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" }, "repository": "github:kiltprotocol/sdk-js", "engines": { diff --git a/packages/types/tsconfig.build.json b/packages/types/tsconfig.build.json deleted file mode 100644 index ebf76bd8e..000000000 --- a/packages/types/tsconfig.build.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tsconfig.build.json", - - "compilerOptions": { - "module": "CommonJS", - "outDir": "./lib/cjs", - }, - - "include": [ - "src/**/*.ts", "src/**/*.js" - ], - - "exclude": [ - "coverage", - "**/*.spec.ts", - ] -} diff --git a/packages/types/tsconfig.esm.json b/packages/types/tsconfig.esm.json index e1f3b73b6..59d05a455 100644 --- a/packages/types/tsconfig.esm.json +++ b/packages/types/tsconfig.esm.json @@ -1,7 +1,9 @@ { - "extends": "./tsconfig.build.json", + "extends": "./tsconfig.json", "compilerOptions": { "module": "ES6", - "outDir": "./lib/esm" + "outDir": "./lib/esm", + "declaration": false, + "composite": false } } diff --git a/packages/types/tsconfig.json b/packages/types/tsconfig.json new file mode 100644 index 000000000..2d8492e57 --- /dev/null +++ b/packages/types/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./lib/cjs", + "rootDir": "./src" + }, + "include": ["src/**/*.ts", "src/**/*.js"], + "exclude": ["coverage", "**/*.spec.ts"] +} diff --git a/packages/utils/package.json b/packages/utils/package.json index ffc40045b..db4d01fb4 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -12,14 +12,15 @@ } }, "files": [ - "lib/**/*" + "lib/**/*.js", + "lib/**/*.d.ts", + "lib/**/*.json" ], "scripts": { "clean": "rimraf ./lib", - "build": "yarn clean && yarn build:ts", - "build:ts": "yarn build:cjs && yarn build:esm", - "build:cjs": "tsc --declaration -p tsconfig.build.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", - "build:esm": "tsc --declaration -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc -b tsconfig.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", + "build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" }, "repository": "github:kiltprotocol/sdk-js", "engines": { diff --git a/packages/utils/tsconfig.build.json b/packages/utils/tsconfig.build.json deleted file mode 100644 index ab24dae00..000000000 --- a/packages/utils/tsconfig.build.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tsconfig.build.json", - - "compilerOptions": { - "module": "CommonJS", - "outDir": "./lib/cjs" - }, - - "include": [ - "src/**/*.ts", "src/**/*.js" - ], - - "exclude": [ - "coverage", - "**/*.spec.ts", - ] -} diff --git a/packages/utils/tsconfig.esm.json b/packages/utils/tsconfig.esm.json index e1f3b73b6..59d05a455 100644 --- a/packages/utils/tsconfig.esm.json +++ b/packages/utils/tsconfig.esm.json @@ -1,7 +1,9 @@ { - "extends": "./tsconfig.build.json", + "extends": "./tsconfig.json", "compilerOptions": { "module": "ES6", - "outDir": "./lib/esm" + "outDir": "./lib/esm", + "declaration": false, + "composite": false } } diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json new file mode 100644 index 000000000..1629b794a --- /dev/null +++ b/packages/utils/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./lib/cjs", + "rootDir": "./src" + }, + "include": ["src/**/*.ts", "src/**/*.js"], + "exclude": ["coverage", "**/*.spec.ts"], + // indicates package dependencies; must be in sync with @kiltprotocol imports in package.json + "references": [ + { + "path": "../types" + } + ] +} diff --git a/packages/vc-export/package.json b/packages/vc-export/package.json index 6ffda4e05..a8606f4d0 100644 --- a/packages/vc-export/package.json +++ b/packages/vc-export/package.json @@ -12,14 +12,15 @@ } }, "files": [ - "lib/**/*" + "lib/**/*.js", + "lib/**/*.d.ts", + "lib/**/*.json" ], "scripts": { "clean": "rimraf ./lib", - "build": "yarn clean && yarn build:ts", - "build:ts": "yarn build:cjs && yarn build:esm", - "build:cjs": "tsc --declaration -p tsconfig.build.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", - "build:esm": "tsc --declaration -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc -b tsconfig.json && echo '{\"type\":\"commonjs\"}' > ./lib/cjs/package.json", + "build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./lib/esm/package.json" }, "repository": "github:kiltprotocol/sdk-js", "engines": { diff --git a/packages/vc-export/tsconfig.build.json b/packages/vc-export/tsconfig.build.json deleted file mode 100644 index d59aa31ce..000000000 --- a/packages/vc-export/tsconfig.build.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tsconfig.build.json", - - "compilerOptions": { - "module": "CommonJS", - "outDir": "./lib/cjs" - }, - - "include": [ - "src/**/*.ts", "src/**/*.js" - ], - - "exclude": [ - "coverage", - "**/*.spec.ts", - ] -} diff --git a/packages/vc-export/tsconfig.esm.json b/packages/vc-export/tsconfig.esm.json index e1f3b73b6..59d05a455 100644 --- a/packages/vc-export/tsconfig.esm.json +++ b/packages/vc-export/tsconfig.esm.json @@ -1,7 +1,9 @@ { - "extends": "./tsconfig.build.json", + "extends": "./tsconfig.json", "compilerOptions": { "module": "ES6", - "outDir": "./lib/esm" + "outDir": "./lib/esm", + "declaration": false, + "composite": false } } diff --git a/packages/vc-export/tsconfig.json b/packages/vc-export/tsconfig.json new file mode 100644 index 000000000..64ec54e1f --- /dev/null +++ b/packages/vc-export/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./lib/cjs", + "rootDir": "./src" + }, + "include": ["src/**/*.ts", "src/**/*.js", "src/**/*.json"], + "exclude": ["coverage", "**/*.spec.ts"], + // indicates package dependencies; must be in sync with @kiltprotocol imports in package.json + "references": [ + { "path": "../config" }, + { "path": "../core" }, + { "path": "../did" }, + { "path": "../types" }, + { "path": "../utils" } + ] +} diff --git a/tests/bundle-test.html b/tests/bundle-test.html index 2ed21cbcb..4d46021b1 100644 --- a/tests/bundle-test.html +++ b/tests/bundle-test.html @@ -8,6 +8,6 @@
- +