vlcn-io / cr-sqlite

Convergent, Replicated SQLite. Multi-writer and CRDT support for SQLite
https://vlcn.io
MIT License
2.61k stars 69 forks source link

fix deprecated import assertion #441

Open Azarattum opened 5 days ago

Azarattum commented 5 days ago

import something from "somewhere" assert { type: "json" }; has been deprecated in favour of import something from "somewhere" with { type: "json" };. Therefore on the latest node versions (tested on 22.2.0 and 22.3.0) the library just doesn't install:

import pkg from "./package.json" assert { type: "json" };
                                 ^^^^^^

SyntaxError: Unexpected identifier 'assert'
    at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:164:18)
    at callTranslator (node:internal/modules/esm/loader:429:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:435:30)
    at async ModuleJob._link (node:internal/modules/esm/module_job:106:19)

Node.js v22.3.0

This is a simple fix that changes assert to with in nodejs-install-helper.js.

NodeJS Docs

https://nodejs.org/docs/v20.15.0/api/esm.html#import-attributes

This feature was previously named "Import assertions", and using the assert keyword instead of with. Any uses in code of the prior assert keyword should be updated to use with instead.