MatrixAI / js-db

Key-Value DB for TypeScript and JavaScript Applications
https://polykey.com
Apache License 2.0
5 stars 0 forks source link

updating to node 20 #69

Closed tegefaulkes closed 1 year ago

tegefaulkes commented 1 year ago

Description

In this PR we are updating to node 20. This includes nix changes and package updates.

Issues Fixed

Tasks

  1. [X] Update nix config to use node 20.
  2. [X] Update node dependencies to the appropriate versions. Using js-quic as reference.
  3. [X] Build js-db with the new versions.
  4. [x] Make sure all tests are working.

Final checklist

ghost commented 1 year ago
👇 Click on the image for a new way to code review #### [![Review these changes using an interactive CodeSee Map](https://s3.us-east-2.amazonaws.com/maps.codesee.io/images/github/MatrixAI/js-db/69/bf5e31c3/9ee4b28a867c0c08f3dea23671c6289ec838156c.svg)](https://app.codesee.io/r/reviews?pr=69&src=https%3A%2F%2Fgithub.com%2FMatrixAI%2Fjs-db) #### Legend CodeSee Map legend
tegefaulkes commented 1 year ago

Looks like almost everything is working. All but two tests are failing.

  1. parallelized batch put and del
  2. parallelized get and put and del

With the following errors.

GLOBAL SETUP

/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/dist/transpilers/swc.js:202
            throw new Error(`${swcDepName} threw an error when attempting to validate swc compiler options.\n` +
            ^

Error: @swc/core threw an error when attempting to validate swc compiler options.
You may be using an old version of swc which does not support the options used by ts-node.
Try upgrading to the latest version of swc.
Error message from swc:
Failed to deserialize buffer as swc::config::Options
JSON: {"sourceMaps":true,"module":{"noInterop":false,"type":"commonjs","strictMode":true,"ignoreDynamic":false},"swcrc":false,"jsc":{"parser":{"syntax":"typescript","tsx":false,"decorators":true,"dynamicImport":true,"importAssertions":true},"target":"es2022","transform":{"legacyDecorator":true,"react":{"throwIfNamespace":false,"useBuiltins":false}},"keepClassNames":true,"experimental":{"keepImportAssertions":true}}}

Caused by:
    unknown field `keepImportAssertions`, expected one of `plugins`, `keepImportAttributes`, `emitAssertForImportAttributes`, `cacheRoot`, `disableBuiltinTransformsForInternalTesting` at line 1 column 413
    at createVariant (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/transpilers/swc.ts:262:13)
    at createSwcOptions (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/transpilers/swc.ts:211:25)
    at create (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/transpilers/swc.ts:56:41)
    at createTranspiler (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/index.ts:784:16)
    at createTranspileOnlyGetOutputFunction (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/index.ts:1341:28)
    at createFromPreloadedConfig (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/index.ts:1404:34)
    at create (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/index.ts:624:10)
    at Object.register (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/index.ts:591:15)
    at Object.<anonymous> (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/register/transpile-only.js:1:16)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)

/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/dist/transpilers/swc.js:202
            throw new Error(`${swcDepName} threw an error when attempting to validate swc compiler options.\n` +
            ^

Error: @swc/core threw an error when attempting to validate swc compiler options.
You may be using an old version of swc which does not support the options used by ts-node.
Try upgrading to the latest version of swc.
Error message from swc:
Failed to deserialize buffer as swc::config::Options
JSON: {"sourceMaps":true,"module":{"noInterop":false,"type":"commonjs","strictMode":true,"ignoreDynamic":false},"swcrc":false,"jsc":{"parser":{"syntax":"typescript","tsx":false,"decorators":true,"dynamicImport":true,"importAssertions":true},"target":"es2022","transform":{"legacyDecorator":true,"react":{"throwIfNamespace":false,"useBuiltins":false}},"keepClassNames":true,"experimental":{"keepImportAssertions":true}}}

Caused by:
    unknown field `keepImportAssertions`, expected one of `plugins`, `keepImportAttributes`, `emitAssertForImportAttributes`, `cacheRoot`, `disableBuiltinTransformsForInternalTesting` at line 1 column 413
    at createVariant (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/transpilers/swc.ts:262:13)
    at createSwcOptions (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/transpilers/swc.ts:211:25)
    at create (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/transpilers/swc.ts:56:41)
    at createTranspiler (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/index.ts:784:16)
    at createTranspileOnlyGetOutputFunction (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/index.ts:1341:28)
    at createFromPreloadedConfig (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/index.ts:1404:34)
    at create (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/index.ts:624:10)
    at Object.register (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/src/index.ts:591:15)
    at Object.<anonymous> (/home/faulkes/matrixcode/polykey/js-db/node_modules/ts-node/register/transpile-only.js:1:16)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)

I'm still looking into this.

CMCDragonkai commented 1 year ago

You also need to update all scripts to support node 20 too. See https://github.com/MatrixAI/js-async-init/commit/300d01ee3a6bd20e701397b998f4433459cbc6dc

CMCDragonkai commented 1 year ago

Should also update .eslintrc https://github.com/MatrixAI/js-async-init/commit/7679c5b94768a26bda39ed4632b829de952473ed

You also need to update js-errors:

    "@matrixai/errors": "^1.2.0",

The js-async-init staging is on ESM. Use the 1.9.x series.

The js-errors staging is on ESM. Use the 1.2.x series.

CMCDragonkai commented 1 year ago

If your swc is broken, try:

rm -rf ./node_modules
rm package-lock.json
exit
nix-shell

If that doesn't work, do the same thing but also delete rm -rf ~/.npm.

tegefaulkes commented 1 year ago

AS per https://github.com/MatrixAI/js-workers/pull/13, @swc/core needs to be pinned to 1.3.82

tegefaulkes commented 1 year ago

Looks good, merging. I'll update the `js-workers dep in staging. getting a headstart on CI.

CMCDragonkai commented 1 year ago

Nice!