🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis
Socket
Book a DemoInstallSign in
Socket

@oxc-parser/wasm

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oxc-parser/wasm

Wasm target for the oxc parser.

Source
npmnpm
Version
0.56.5
Version published
Weekly downloads
153K
-2.16%
Maintainers
1
Weekly downloads
 
Created
Source

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 web for bundler (webpack / vite) consumption.
  • wasm-pack build --target nodejs for 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",

Check out oxc-parser for an alternative in Node.js which performs the same function, but using native code via NAPI bindings (slightly faster).

Source code: https://github.com/oxc-project/oxc/tree/main/wasm/parser

Usage

Node.js

import { parseSync } from '@oxc-parser/wasm';

const code = 'let foo';
const result = parseSync(code, { sourceFilename: 'test.ts' });
console.log(result.program);

Browser

import { initSync, parseSync } from '@oxc-parser/wasm';

initSync();

const code = 'let foo';
const result = parseSync(code, { sourceFilename: 'test.ts' });
console.log(result.program);

Notes

The AST returned conforms to the ESTree spec for JS syntax.

For TypeScript code, the AST is broadly aligned with typescript-eslint's format, though there may be some differences.

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.

Keywords

JavaScript

FAQs

Package last updated on 07 Mar 2025

Did you know?

Socket

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.

Install

Related posts