Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@oxc-parser/wasm
Advanced tools
Experimental wasm package for the oxc parser, with full TypeScript typings support.
This package is built with different wasm-pack's target builds:
wasm-pack build --target web
for bundler (webpack / vite) consumption.wasm-pack build --target nodejs
for node.jsAnd exports the files as
"main": "./node/oxc_parser_wasm.js",
"browser": "./web/oxc_parser_wasm.js",
"types": "./node/oxc_parser_wasm.d.ts",
Checkout oxc-parser for usage in node.js via napi bindings.
Source code: https://github.com/oxc-project/oxc/tree/main/wasm/parser
import initWasm, { parseSync } from "@oxc-parser/wasm";
async function main() {
await initWasm();
const code = "let foo";
const result = parseSync(code, { sourceFilename: "test.ts" });
console.log(result);
}
main();
The span
value returned from the ASTs and diagnostics is in UTF8 byte offsets. Converting to UTF16 byte offsets:
let sourceTextUtf8 = new TextEncoder().encode(sourceText);
const convertToUtf8 = (sourceTextUtf8, d) => {
return new TextDecoder().decode(sourceTextUtf8.slice(0, d)).length;
}
const diagnostics = result.errors.map((d) => ({
from: convertToUtf8(sourceTextUtf8, d.start),
to: convertToUtf8(sourceTextUtf8, d.end),
severity: d.severity.toLowerCase(),
message: d.message,
}));
wasm-pack build --target web
is used for the wasm build.
You may need something like https://github.com/nshen/vite-plugin-wasm-pack to get it working with vite,
otherwise vite will load the wasm file as a HTML file causing a CompileError: WebAssembly.instantiate(): expected magic word
error.
FAQs
Wasm target for the oxc parser.
The npm package @oxc-parser/wasm receives a total of 8,427 weekly downloads. As such, @oxc-parser/wasm popularity was classified as popular.
We found that @oxc-parser/wasm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.