From c624b20ff5acedc33f801c4d00ccdb9aa137dd32 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 18 Nov 2022 11:09:02 -0800 Subject: [PATCH 1/8] fix: include the build script in the npm package --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1bbdbbd9..06a5f9e2 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "src/util/*.h", "src/*.cc", "src/*.h", - "script/build.sh", + "script/build.ts", "prebuilds", "v5-compat.d.ts", "v5-compat.js", From cc55f92defaee48d8e3af1581ba6f8a20af14a2b Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 18 Nov 2022 11:22:25 -0800 Subject: [PATCH 2/8] fix: fix the types in the examples --- examples/threaded-worker/threaded-worker.ts | 4 ++-- examples/tsconfig.json | 14 ++++++++++++-- tsconfig.json | 16 +++++++++++----- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/examples/threaded-worker/threaded-worker.ts b/examples/threaded-worker/threaded-worker.ts index beda54a8..211bb739 100644 --- a/examples/threaded-worker/threaded-worker.ts +++ b/examples/threaded-worker/threaded-worker.ts @@ -4,7 +4,7 @@ import * as zmq from "zeromq" export class ThreadedWorker { static async spawn(threads: number) { const workers = Array.from({length: threads}).map(() => { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { const src = ` const zmq = require("zeromq") ${ThreadedWorker.toString()} @@ -13,7 +13,7 @@ export class ThreadedWorker { new Worker(src, {eval: true}).on("exit", code => { if (code === 0) { - resolve() + resolve(undefined) } else { reject(new Error(`Worker stopped with exit code ${code}`)) } diff --git a/examples/tsconfig.json b/examples/tsconfig.json index e472c026..1834134d 100644 --- a/examples/tsconfig.json +++ b/examples/tsconfig.json @@ -1,9 +1,19 @@ { - "include": ["*"], + "include": [ + "./**/*.ts" + ], "compilerOptions": { "target": "es2018", "module": "commonjs", - "lib": ["es2018", "esnext.asynciterable"], + "lib": [ + "es2018", + "esnext.asynciterable" + ], "strict": true, + "paths": { + "zeromq": [ + "../src/index.ts" + ], + }, } } diff --git a/tsconfig.json b/tsconfig.json index 9cae83ce..823f4f92 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,14 +1,20 @@ { - "exclude": ["*.d.ts"], "compilerOptions": { "allowJs": false, "target": "es2020", - "outDir": "lib", "declaration": true, "module": "commonjs", - "types": ["node", "mocha"], + "types": [ + "node", + "mocha" + ], "strict": true, "strictPropertyInitialization": false, - "lib": ["ES2020", "dom"] - } + "lib": [ + "ES2020", + "dom" + ], + "outDir": "lib" + }, + "include": ["src"] } From d05dae65fcd3719c2767bf238575c821db0153cb Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 18 Nov 2022 11:32:27 -0800 Subject: [PATCH 3/8] fix: compile the build typescript files for production --- .eslintrc | 7 +++---- .gitignore | 4 ++++ binding.gyp | 2 +- package.json | 35 ++++++++++++++++------------------- script/tsconfig.json | 8 ++++++++ 5 files changed, 32 insertions(+), 24 deletions(-) create mode 100644 script/tsconfig.json diff --git a/.eslintrc b/.eslintrc index 350b4bae..66dc93db 100644 --- a/.eslintrc +++ b/.eslintrc @@ -17,10 +17,9 @@ "node_modules/", "build/", "lib/", - "libzmq/", "tmp/", - "zmq/", - "v5-compat.d.ts", - "draft.d.ts" + "./*.d.ts", + "script/*.js", + "script/*.d.ts" ] } diff --git a/.gitignore b/.gitignore index 0864be2f..01d93b26 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,7 @@ prebuilds test.js .cache/ test/typings-compatibility/ +script/*.js +script/*.d.ts +script/*/*.js +script/*/*.d.ts diff --git a/binding.gyp b/binding.gyp index 2ff745c6..c4b431bd 100644 --- a/binding.gyp +++ b/binding.gyp @@ -25,7 +25,7 @@ 'outputs': ['<(module_root_dir)/build/libzmq/lib/libzmq.lib', '<(module_root_dir)/build/libzmq/include/zmq.h', '<(module_root_dir)/build/libzmq/include/zmq_utils.h'], }], ], - 'action': ['ts-node', '<(module_root_dir)/script/build.ts'], + 'action': ['node', '<(module_root_dir)/script/build.js'], }], }], ], diff --git a/package.json b/package.json index 06a5f9e2..eca241b8 100644 --- a/package.json +++ b/package.json @@ -17,23 +17,22 @@ "url": "https://github.com/zeromq/zeromq.js.git" }, "dependencies": { - "@types/node": "^18.11.9", - "@types/shelljs": "^0.8.11", - "cross-env": "^7.0.3", "node-addon-api": "^5.0.0", "node-gyp-build": "^4.5.0", - "shelljs": "^0.8.5", - "ts-node": "10.9" + "shelljs": "^0.8.5" }, "devDependencies": { "@gnd/typedoc": "^0.15.0-0", "@types/chai": ">=4.3", "@types/fs-extra": "^9.0.13", "@types/mocha": ">=10.0", + "@types/node": "^18.11.9", "@types/semver": ">=7", + "@types/shelljs": "^0.8.11", "@types/weak-napi": "^2.0.1", "benchmark": ">=2", "chai": ">=4.3", + "cross-env": "^7.0.3", "deasync": "^0.1.28", "eslint-config-atomic": "^1.18.1", "eslint-plugin-prettier": "^4.2.1", @@ -50,6 +49,7 @@ "shx": "^0.3.4", "tar-fs": "^2.1.1", "ts-morph": "^16.0.0", + "ts-node": "10.9", "typescript": "4.9", "weak-napi": "^2.0.2" }, @@ -61,30 +61,27 @@ "LICENSE", "README.md", "binding.gyp", - "draft.d.ts", - "draft.js", + "*.d.ts", + "*.js", "lib", - "src/util/*.h", - "src/*.cc", - "src/*.h", - "script/build.ts", + "src", + "script", "prebuilds", - "v5-compat.d.ts", - "v5-compat.js", - "vendor/*.h", - "vendor/LICENSE.md" + "tsconfig.json" ], "scripts": { "install": "node-gyp-build", "clean": "shx rm -rf ./build ./lib/ ./prebuilds", "clean.temp": "shx rm -rf ./tmp && shx mkdir -p tmp && shx touch tmp/.gitkeep", - "build.js": "tsc --project tsconfig-build.json && node script/ci/downlevel-dts.js", + "build.library": "shx rm -rf ./lib && tsc && node script/ci/downlevel-dts.js", + "build.script": "tsc -p ./script/tsconfig.json", + "build.js": "run-p build.script build.library", "build.doc": "typedoc --out docs --name zeromq.js --excludeProtected --excludePrivate --excludeNotExported --excludeExternals --externalPattern 'src/+(draft|native|compat).ts' --tsconfig tsconfig-build.json --mode file", - "prebuild": "ts-node -P ./tsconfig.json ./script/prebuild.ts", + "prebuild": "run-s build.js && node ./script/prebuild.js", "build.native": "node-gyp configure --release && node-gyp build --release", "build.native.debug": "cross-env CMAKE_BUILD_TYPE=Debug node-gyp configure --debug && cross-env CMAKE_BUILD_TYPE=Debug node-gyp build --debug", - "build": "run-p build.js build.native", - "build.debug": "run-p build.js build.native.debug", + "build": "run-s build.js build.native", + "build.debug": "run-s build.js build.native.debug", "test": "run-s build && mocha", "test.skip_gc_tests": "run-s build.debug && cross-env SKIP_GC_TESTS=true mocha", "lint.clang-format": "clang-format -i -style=file ./src/*.cc ./src/*.h ./src/util/*.h", diff --git a/script/tsconfig.json b/script/tsconfig.json new file mode 100644 index 00000000..5055f179 --- /dev/null +++ b/script/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "./" + }, + "include": ["./**/*.ts"], + "exclude": [] +} From 7add2e65b4faab3054723748d9b4406b58317ee6 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 18 Nov 2022 11:37:21 -0800 Subject: [PATCH 4/8] fix: check for the existence of build.js in a clean repo --- package.json | 6 ++--- pnpm-lock.yaml | 60 +++++++++++++++++++++++++++++--------------------- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index eca241b8..ba72fbeb 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "dependencies": { "node-addon-api": "^5.0.0", "node-gyp-build": "^4.5.0", - "shelljs": "^0.8.5" + "shelljs": "^0.8.5", + "shx": "^0.3.4" }, "devDependencies": { "@gnd/typedoc": "^0.15.0-0", @@ -46,7 +47,6 @@ "prettier": "^2.7.1", "rocha": "^2.5.10", "semver": ">=7", - "shx": "^0.3.4", "tar-fs": "^2.1.1", "ts-morph": "^16.0.0", "ts-node": "10.9", @@ -70,7 +70,7 @@ "tsconfig.json" ], "scripts": { - "install": "node-gyp-build", + "install": "(shx test -f ./script/build.js || run-s build.js) && node-gyp-build", "clean": "shx rm -rf ./build ./lib/ ./prebuilds", "clean.temp": "shx rm -rf ./tmp && shx mkdir -p tmp && shx touch tmp/.gitkeep", "build.library": "shx rm -rf ./lib && tsc && node script/ci/downlevel-dts.js", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index eb464d6e..b686e05c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,23 +36,23 @@ specifiers: weak-napi: ^2.0.2 dependencies: - '@types/node': 18.11.9 - '@types/shelljs': 0.8.11 - cross-env: 7.0.3 node-addon-api: 5.0.0 node-gyp-build: 4.5.0 shelljs: 0.8.5 - ts-node: 10.9.1_wup25etrarvlqkprac7h35hj7u + shx: 0.3.4 devDependencies: '@gnd/typedoc': 0.15.0-0 '@types/chai': 4.3.4 '@types/fs-extra': 9.0.13 '@types/mocha': 10.0.0 + '@types/node': 18.11.9 '@types/semver': 7.3.13 + '@types/shelljs': 0.8.11 '@types/weak-napi': 2.0.1 benchmark: 2.1.4 chai: 4.3.7 + cross-env: 7.0.3 deasync: 0.1.28 eslint-config-atomic: 1.18.1 eslint-plugin-prettier: 4.2.1_prettier@2.7.1 @@ -66,9 +66,9 @@ devDependencies: prettier: 2.7.1 rocha: 2.5.10 semver: 7.3.8 - shx: 0.3.4 tar-fs: 2.1.1 ts-morph: 16.0.0 + ts-node: 10.9.1_wup25etrarvlqkprac7h35hj7u typescript: 4.9.3 weak-napi: 2.0.2 @@ -341,7 +341,7 @@ packages: engines: {node: '>=12'} dependencies: '@jridgewell/trace-mapping': 0.3.9 - dev: false + dev: true /@eslint/eslintrc/1.3.3: resolution: {integrity: sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg==} @@ -422,6 +422,7 @@ packages: /@jridgewell/resolve-uri/3.1.0: resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==} engines: {node: '>=6.0.0'} + dev: true /@jridgewell/set-array/1.1.2: resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==} @@ -430,6 +431,7 @@ packages: /@jridgewell/sourcemap-codec/1.4.14: resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==} + dev: true /@jridgewell/trace-mapping/0.3.17: resolution: {integrity: sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==} @@ -443,7 +445,7 @@ packages: dependencies: '@jridgewell/resolve-uri': 3.1.0 '@jridgewell/sourcemap-codec': 1.4.14 - dev: false + dev: true /@nicolo-ribaudo/eslint-scope-5-internals/5.1.1-v1: resolution: {integrity: sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==} @@ -505,19 +507,19 @@ packages: /@tsconfig/node10/1.0.9: resolution: {integrity: sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==} - dev: false + dev: true /@tsconfig/node12/1.0.11: resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==} - dev: false + dev: true /@tsconfig/node14/1.0.3: resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==} - dev: false + dev: true /@tsconfig/node16/1.0.3: resolution: {integrity: sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==} - dev: false + dev: true /@types/chai/4.3.4: resolution: {integrity: sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==} @@ -534,7 +536,7 @@ packages: dependencies: '@types/minimatch': 5.1.2 '@types/node': 18.11.9 - dev: false + dev: true /@types/json-schema/7.0.11: resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==} @@ -556,7 +558,7 @@ packages: /@types/minimatch/5.1.2: resolution: {integrity: sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==} - dev: false + dev: true /@types/mocha/10.0.0: resolution: {integrity: sha512-rADY+HtTOA52l9VZWtgQfn4p+UDVM2eDVkMZT1I6syp0YKxW2F9v+0pbRZLsvskhQv/vMb6ZfCay81GHbz5SHg==} @@ -564,6 +566,7 @@ packages: /@types/node/18.11.9: resolution: {integrity: sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==} + dev: true /@types/normalize-package-data/2.4.1: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} @@ -584,7 +587,7 @@ packages: dependencies: '@types/glob': 8.0.0 '@types/node': 18.11.9 - dev: false + dev: true /@types/weak-napi/2.0.1: resolution: {integrity: sha512-07jFwDZ2JLexI5lGzRirWzsC8MdA1avc6QsdvidKvPOKNYXAAijpA/6ygxL1CEW/qbEU6udapLZmempcH3trXQ==} @@ -736,12 +739,13 @@ packages: /acorn-walk/8.2.0: resolution: {integrity: sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==} engines: {node: '>=0.4.0'} - dev: false + dev: true /acorn/8.8.1: resolution: {integrity: sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==} engines: {node: '>=0.4.0'} hasBin: true + dev: true /agent-base/6.0.2: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} @@ -854,7 +858,7 @@ packages: /arg/4.1.3: resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} - dev: false + dev: true /argparse/2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} @@ -1392,7 +1396,7 @@ packages: /create-require/1.1.1: resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} - dev: false + dev: true /cross-env/7.0.3: resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==} @@ -1400,7 +1404,7 @@ packages: hasBin: true dependencies: cross-spawn: 7.0.3 - dev: false + dev: true /cross-spawn/5.1.0: resolution: {integrity: sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==} @@ -1417,6 +1421,7 @@ packages: path-key: 3.1.1 shebang-command: 2.0.0 which: 2.0.2 + dev: true /crypto-random-string/1.0.0: resolution: {integrity: sha512-GsVpkFPlycH7/fRR7Dhcmnoii54gV1nz7y4CWyeFS14N+JVBBhY+r8amRHE4BwSYal7BPTDp8isvAlCxyFt3Hg==} @@ -1562,7 +1567,7 @@ packages: /diff/4.0.2: resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} engines: {node: '>=0.3.1'} - dev: false + dev: true /diff/5.0.0: resolution: {integrity: sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==} @@ -3063,6 +3068,7 @@ packages: /isexe/2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + dev: true /jquery/3.6.1: resolution: {integrity: sha512-opJeO4nCucVnsjiXOE+/PcCgYw9Gwpvs/a6B1LL/lQhwWwpbVEVYDZ1FokFr8PRc7ghYlrFPuyHuiiDNTQxmcw==} @@ -3287,7 +3293,7 @@ packages: /make-error/1.3.6: resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} - dev: false + dev: true /make-fetch-happen/10.2.1: resolution: {integrity: sha512-NgOPbRiaQM10DYXvN3/hhGVI2M5MtITFryzBGxHM5p4wnFxsVCbxkrBrDsk+EZ5OB4jEOT7AjDxtdF+KVEFT7w==} @@ -3375,7 +3381,6 @@ packages: /minimist/1.2.7: resolution: {integrity: sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==} - dev: true /minipass-collect/1.0.2: resolution: {integrity: sha512-6T6lH0H8OG9kITm/Jm6tdooIbogG9e0tLgpY6mphXSm/A9u8Nq1ryBG+Qspiub9LjWlBPsPS3tWQ/Botq4FdxA==} @@ -3827,6 +3832,7 @@ packages: /path-key/3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} + dev: true /path-parse/1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} @@ -4261,6 +4267,7 @@ packages: engines: {node: '>=8'} dependencies: shebang-regex: 3.0.0 + dev: true /shebang-regex/1.0.0: resolution: {integrity: sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==} @@ -4270,6 +4277,7 @@ packages: /shebang-regex/3.0.0: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} + dev: true /shell-quote/1.7.4: resolution: {integrity: sha512-8o/QEhSSRb1a5i7TFR0iM4G16Z0vYB2OQVs4G3aAFXjn3T6yEx8AZxy1PgDF7I00LZHYA3WxaSYIf5e5sAX8Rw==} @@ -4291,7 +4299,7 @@ packages: dependencies: minimist: 1.2.7 shelljs: 0.8.5 - dev: true + dev: false /side-channel/1.0.4: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} @@ -4639,7 +4647,7 @@ packages: typescript: 4.9.3 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 - dev: false + dev: true /tsconfig-paths/3.14.1: resolution: {integrity: sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==} @@ -4711,6 +4719,7 @@ packages: resolution: {integrity: sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==} engines: {node: '>=4.2.0'} hasBin: true + dev: true /uglify-js/3.17.4: resolution: {integrity: sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==} @@ -4819,7 +4828,7 @@ packages: /v8-compile-cache-lib/3.0.1: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} - dev: false + dev: true /validate-npm-package-license/3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} @@ -4891,6 +4900,7 @@ packages: hasBin: true dependencies: isexe: 2.0.0 + dev: true /wide-align/1.1.5: resolution: {integrity: sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==} @@ -4992,7 +5002,7 @@ packages: /yn/3.1.1: resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} engines: {node: '>=6'} - dev: false + dev: true /yocto-queue/0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} From 35b5f0132e8a64b570689413aad020ac44cfaa79 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 18 Nov 2022 11:57:59 -0800 Subject: [PATCH 5/8] fix: fix test type checks + make tsconfig more strict --- .eslintrc | 3 ++- .gitignore | 18 +++++++++--------- package.json | 2 +- src/tsconfig.json | 7 +++++++ test/tsconfig.json | 4 ++++ tsconfig.json | 17 +++++++++++++---- 6 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 src/tsconfig.json create mode 100644 test/tsconfig.json diff --git a/.eslintrc b/.eslintrc index 66dc93db..6e07d007 100644 --- a/.eslintrc +++ b/.eslintrc @@ -18,7 +18,8 @@ "build/", "lib/", "tmp/", - "./*.d.ts", + "v5-compat.d.ts", + "draft.d.ts", "script/*.js", "script/*.d.ts" ] diff --git a/.gitignore b/.gitignore index 01d93b26..bdcfa1d5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ -build -docs -lib -tmp +/build +/docs +/lib +/tmp node_modules yarn.lock yarn-error.log @@ -9,11 +9,11 @@ package-lock.json lib/binary/*.node lib/binary/napi-v*/*.node build-tmp-napi-v* -prebuilds +/prebuilds test.js .cache/ test/typings-compatibility/ -script/*.js -script/*.d.ts -script/*/*.js -script/*/*.d.ts +/script/*.js +/script/*.d.ts +/script/*/*.js +/script/*/*.d.ts diff --git a/package.json b/package.json index ba72fbeb..5c26a750 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "install": "(shx test -f ./script/build.js || run-s build.js) && node-gyp-build", "clean": "shx rm -rf ./build ./lib/ ./prebuilds", "clean.temp": "shx rm -rf ./tmp && shx mkdir -p tmp && shx touch tmp/.gitkeep", - "build.library": "shx rm -rf ./lib && tsc && node script/ci/downlevel-dts.js", + "build.library": "shx rm -rf ./lib && tsc -p ./src/tsconfig.json && node script/ci/downlevel-dts.js", "build.script": "tsc -p ./script/tsconfig.json", "build.js": "run-p build.script build.library", "build.doc": "typedoc --out docs --name zeromq.js --excludeProtected --excludePrivate --excludeNotExported --excludeExternals --externalPattern 'src/+(draft|native|compat).ts' --tsconfig tsconfig-build.json --mode file", diff --git a/src/tsconfig.json b/src/tsconfig.json new file mode 100644 index 00000000..2310c63b --- /dev/null +++ b/src/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../lib" + }, + "include": ["**/*.ts"] +} diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 00000000..e516b7fa --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig.json", + "include": ["**/*.ts"] +} diff --git a/tsconfig.json b/tsconfig.json index 823f4f92..695ddb3b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,13 +8,22 @@ "node", "mocha" ], + "strictPropertyInitialization": false, // TODO "strict": true, - "strictPropertyInitialization": false, + "strictNullChecks": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, "lib": [ "ES2020", "dom" - ], - "outDir": "lib" + ] }, - "include": ["src"] + "include": [ + "src", + "script", + "examples" + ] } From 52a41d5e9f91e27985b80234d034dff1c84e6a19 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 18 Nov 2022 11:58:11 -0800 Subject: [PATCH 6/8] fix: make the typescript builds incremental --- .gitignore | 1 + tsconfig.json | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index bdcfa1d5..7d5a9501 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ test/typings-compatibility/ /script/*.d.ts /script/*/*.js /script/*/*.d.ts +tsconfig.tsbuildinfo diff --git a/tsconfig.json b/tsconfig.json index 695ddb3b..be9f233c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,7 @@ "noImplicitThis": true, "noUnusedLocals": true, "noUnusedParameters": true, + "incremental": true, "lib": [ "ES2020", "dom" From 43f37045456c67fd0fa30e35b199190e52199e12 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 18 Nov 2022 11:59:10 -0800 Subject: [PATCH 7/8] fix: include source map in the built files --- .gitignore | 2 ++ tsconfig.json | 1 + 2 files changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 7d5a9501..d8ee0469 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,8 @@ test.js test/typings-compatibility/ /script/*.js /script/*.d.ts +/script/*.js.map /script/*/*.js /script/*/*.d.ts +/script/*/*.js.map tsconfig.tsbuildinfo diff --git a/tsconfig.json b/tsconfig.json index be9f233c..c7797816 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,6 +17,7 @@ "noUnusedLocals": true, "noUnusedParameters": true, "incremental": true, + "sourceMap": true, "lib": [ "ES2020", "dom" From 29645b2bb4b8b06db723126006fb4488149c4d77 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 18 Nov 2022 12:11:43 -0800 Subject: [PATCH 8/8] fix: relax the tsc rules for the unused variables --- test/unit/socket-stream-test.ts | 2 +- tsconfig.json | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/unit/socket-stream-test.ts b/test/unit/socket-stream-test.ts index 158f91ec..0d56bdf5 100644 --- a/test/unit/socket-stream-test.ts +++ b/test/unit/socket-stream-test.ts @@ -65,7 +65,7 @@ for (const proto of testProtos("tcp")) { const port = parseInt(address.split(":").pop()!, 10) const server = await new Promise(resolve => { - const http = createServer((req, res) => { + const http = createServer((_req, res) => { res.writeHead(200, { "Content-Type": "text/plain", "Content-Length": 12, diff --git a/tsconfig.json b/tsconfig.json index c7797816..dc1d2cdf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,8 +14,9 @@ "noImplicitAny": true, "noImplicitReturns": true, "noImplicitThis": true, - "noUnusedLocals": true, - "noUnusedParameters": true, + // eslint already warns about: + "noUnusedLocals": false, + "noUnusedParameters": false, "incremental": true, "sourceMap": true, "lib": [