Skip to content

Commit

Permalink
feat: update tsconfig and use tsdx
Browse files Browse the repository at this point in the history
  • Loading branch information
yknl committed Aug 23, 2020
1 parent 01c8f82 commit a82dd0c
Show file tree
Hide file tree
Showing 10 changed files with 11,703 additions and 1,306 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Expand Up @@ -41,4 +41,8 @@ src/testing/browser/blockstack-proofs.js

lib
dist
docs
docs

.rts2_cache_cjs
.rts2_cache_esm
.rts2_cache_umd/
2 changes: 1 addition & 1 deletion packages/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions packages/common/package.json
Expand Up @@ -5,20 +5,27 @@
"author": "yknl <yukanliao@gmail.com>",
"homepage": "https://blockstack.org",
"license": "GPL-3.0-or-later",
"main": "lib/index.js",
"main": "./dist/index.js",
"umd:main": "./dist/common.umd.production.js",
"module": "./dist/common.esm.js",
"directories": {
"lib": "lib",
"dist": "dist",
"test": "__tests__"
},
"files": [
"lib"
"dist"
],
"repository": {
"type": "git",
"url": "git+https://github.com/blockstack/blockstack.js.git"
},
"scripts": {
"build": "rimraf lib && tsc -b tsconfig.build.json",
"build": "cross-env NODE_ENV=production tsdx build --format=cjs,esm,umd",
"build-all": "run-p build:*",
"build:cjs": "tsc --outDir ./lib -m commonjs -t es2017",
"build:esm": "tsc --outDir ./lib-esm -m es6 -t es2017",
"build:cjs:watch": "tsc --outDir ./lib -m commonjs -t es2017 --watch",
"build:esm:watch": "tsc --outDir ./lib-esm -m es6 -t es2017 --watch",
"test": "echo \"Error: run tests from root\" && exit 1"
},
"bugs": {
Expand Down
10 changes: 5 additions & 5 deletions packages/common/src/errors.ts
Expand Up @@ -62,7 +62,7 @@ export class BlockstackError extends Error {
please file a bug report: https://github.com/blockstack/blockstack.js/issues\n\n${bugDetails}`
this.message = message
this.code = error.code
this.parameter = error.parameter ? error.parameter : null
this.parameter = error.parameter ? error.parameter : undefined
}

toString() {
Expand Down Expand Up @@ -224,7 +224,7 @@ export interface HubErrorDetails {
* @ignore
*/
export class GaiaHubError extends BlockstackError {
hubError: HubErrorDetails
hubError?: HubErrorDetails

constructor(error: ErrorData, response: GaiaHubErrorResponse) {
super(error)
Expand All @@ -237,8 +237,8 @@ export class GaiaHubError extends BlockstackError {
this.hubError.message = response.body
} else if (typeof response.body === 'object') {
Object.assign(this.hubError, response.body)
}
}
}
}
}
}

Expand Down Expand Up @@ -297,7 +297,7 @@ export class ValidationError extends GaiaHubError {
*/
export class PayloadTooLargeError extends GaiaHubError {
/** Can be `null` when an oversized payload is detected client-side. */
hubError: HubErrorDetails
hubError?: HubErrorDetails

maxUploadByteSize: number;

Expand Down
8 changes: 4 additions & 4 deletions packages/common/src/utils.ts
Expand Up @@ -165,7 +165,7 @@ export function isSameOriginAbsoluteUrl(uri1: string, uri2: string) {
parseUrl = url => new nodeUrl(url)
} catch (error) {
console.log(error)
console.error('Global URL class is not available')
throw new Error('Global URL class is not available')
}
}

Expand Down Expand Up @@ -262,8 +262,8 @@ interface GetGlobalObjectOptions {
export function getGlobalObject<K extends Extract<keyof Window, string>>(
name: K,
{ throwIfUnavailable, usageDesc, returnEmptyObject }: GetGlobalObjectOptions = { }
): Window[K] {
let globalScope: Window
): Window[K] | undefined {
let globalScope: Window | undefined = undefined;
try {
globalScope = getGlobalScope()
if (globalScope) {
Expand Down Expand Up @@ -298,7 +298,7 @@ export function getGlobalObjects<K extends Extract<keyof Window, string>>(
names: K[],
{ throwIfUnavailable, usageDesc, returnEmptyObject }: GetGlobalObjectOptions = {}
): Pick<Window, K> {
let globalScope: Window
let globalScope: Window | undefined
try {
globalScope = getGlobalScope()
} catch (error) {
Expand Down
11 changes: 9 additions & 2 deletions packages/encryption/package.json
Expand Up @@ -5,7 +5,9 @@
"author": "yknl <yukanliao@gmail.com>",
"homepage": "https://blockstack.org",
"license": "GPL-3.0-or-later",
"main": "lib/index.js",
"main": "./dist/index.js",
"umd:main": "./dist/common.umd.production.js",
"module": "./dist/common.esm.js",
"directories": {
"lib": "lib",
"test": "__tests__"
Expand All @@ -18,7 +20,12 @@
"url": "git+https://github.com/blockstack/blockstack.js.git"
},
"scripts": {
"build": "rimraf lib && tsc -b tsconfig.build.json",
"build": "cross-env NODE_ENV=production tsdx build --format=cjs,esm,umd",
"build-all": "run-p build:*",
"build:cjs": "tsc --outDir ./lib -m commonjs -t es2017",
"build:esm": "tsc --outDir ./lib-esm -m es6 -t es2017",
"build:cjs:watch": "tsc --outDir ./lib -m commonjs -t es2017 --watch",
"build:esm:watch": "tsc --outDir ./lib-esm -m es6 -t es2017 --watch",
"test": "echo \"Error: run tests from root\" && exit 1"
},
"bugs": {
Expand Down
4 changes: 3 additions & 1 deletion packages/encryption/src/cryptoRandom.ts
@@ -1,4 +1,6 @@
import * as randombytes from 'randombytes'
import * as randombytes_ from 'randombytes'

let randombytes = randombytes_

export { randombytes as randomBytes }

Expand Down

0 comments on commit a82dd0c

Please sign in to comment.