surrealdb / surrealql.wasm

WebAssembly utility functions for SurrealQL parsing and validation
https://surrealdb.com
Apache License 2.0
6 stars 1 forks source link

Bug: Top Level await issue #5

Open SOG-web opened 2 days ago

SOG-web commented 2 days ago

Describe the bug

Am using Node 22.5.1

✘ [ERROR] Top-level await is not available in the configured target environment ("chrome130.0", "edge130.0", "firefox115.0", "ios17.0", "safari17.0" + 7 overrides)

node_modules/.pnpm/@surrealdb+ql-wasm@0.2.0-beta.9/node_modules/@surrealdb/ql-wasm/dist/surrealql/index.js:26:15:
  26 │     readFile: (await import("node:fs")).readFileSync
     ╵                ~~~~~

✘ [ERROR] Top-level await is not available in the configured target environment ("chrome130.0", "edge130.0", "firefox115.0", "ios17.0", "safari17.0" + 7 overrides)

node_modules/.pnpm/@surrealdb+ql-wasm@0.2.0-beta.9/node_modules/@surrealdb/ql-wasm/dist/surrealql/index.js:28:11:
  28 │   module = await (async () => {
     ╵            ~~~~~

✘ [ERROR] Top-level await is not available in the configured target environment ("chrome130.0", "edge130.0", "firefox115.0", "ios17.0", "safari17.0" + 7 overrides)

node_modules/.pnpm/@surrealdb+ql-wasm@0.2.0-beta.9/node_modules/@surrealdb/ql-wasm/dist/surrealql/index.js:897:15:
  897 │     wasmCode = await Deno.readFile(wasm_url);
      ╵                ~~~~~

✘ [ERROR] Top-level await is not available in the configured target environment ("chrome130.0", "edge130.0", "firefox115.0", "ios17.0", "safari17.0" + 7 overrides)

node_modules/.pnpm/@surrealdb+ql-wasm@0.2.0-beta.9/node_modules/@surrealdb/ql-wasm/dist/surrealql/index.js:902:15:
  902 │     wasmCode = await (await fetch(wasm_url)).arrayBuffer();
      ╵                ~~~~~

✘ [ERROR] Top-level await is not available in the configured target environment ("chrome130.0", "edge130.0", "firefox115.0", "ios17.0", "safari17.0" + 7 overrides)

node_modules/.pnpm/@surrealdb+ql-wasm@0.2.0-beta.9/node_modules/@surrealdb/ql-wasm/dist/surrealql/index.js:902:22:
  902 │     wasmCode = await (await fetch(wasm_url)).arrayBuffer();
      ╵                       ~~~~~

✘ [ERROR] Top-level await is not available in the configured target environment ("chrome130.0", "edge130.0", "firefox115.0", "ios17.0", "safari17.0" + 7 overrides)

node_modules/.pnpm/@surrealdb+ql-wasm@0.2.0-beta.9/node_modules/@surrealdb/ql-wasm/dist/surrealql/index.js:907:20:
  907 │ var wasmInstance = (await WebAssembly.instantiate(wasmCode, imports)).instance,
      ╵                     ~~~~~

Steps to reproduce

Just install fresh angular app the try use this package

Expected behaviour

To validate the surrealql

SurrealDB version

latest

Contact Details

raheemolaleknusman84@gmail.com

Is there an existing issue for this?

Code of Conduct

SOG-web commented 2 days ago

version: "@surrealdb/ql-wasm": "0.2.0-beta.9", or "@surrealdb/ql-wasm": "0.2.0-beta.1",

SOG-web commented 2 days ago

this is what causing error,

import { SurrealQL, Value } from "@surrealdb/ql-wasm"; const parsed = decodeCbor(Value.from_string(paramString).to_cbor().buffer);

export function validateThing(thing: string): string | undefined {
    try {
        SurrealQL.validate_thing(thing);
        return undefined;
    } catch (err: any) {
        return err;
    }
}