mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 20:28:58 +00:00
[](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---|---|---| | | | lockFileMaintenance | All locks refreshed | | | | | | [axios](https://axios-http.com) ([source](https://togithub.com/axios/axios)) | devDependencies | patch | [`1.7.0` -> `1.7.2`](https://renovatebot.com/diffs/npm/axios/1.7.0/1.7.2) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | | [pnpm](https://pnpm.io) ([source](https://togithub.com/pnpm/pnpm)) | packageManager | patch | [`9.1.1` -> `9.1.2`](https://renovatebot.com/diffs/npm/pnpm/9.1.1/9.1.2) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Release Notes <details> <summary>axios/axios (axios)</summary> ### [`v1.7.2`](https://togithub.com/axios/axios/blob/HEAD/CHANGELOG.md#172-2024-05-21) [Compare Source](https://togithub.com/axios/axios/compare/v1.7.1...v1.7.2) ##### Bug Fixes - **fetch:** enhance fetch API detection; ([#​6413](https://togithub.com/axios/axios/issues/6413)) ([4f79aef]( |
||
|---|---|---|
| .. | ||
| src | ||
| .gitignore | ||
| Cargo.toml | ||
| package.json | ||
| pnpm-lock.yaml | ||
| README.md | ||
| test-node.mjs | ||
About
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 webfor bundler (webpack / vite) consumption.wasm-pack build --target nodejsfor node.js
And 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
Usage
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();
Notes
UTF8 vs UTF16 byte offsets
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,
}));
Vite
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.