jQueReact

raw JSON →
0.0.1 verified Fri May 01 auth: no javascript deprecated

jQueReact is a pre-release jQuery-to-React transpiler that converts imperative jQuery code into declarative React/JSX components at build time. Version 0.0.1 is an early placeholder. It uses a Rust-based parser compiled to WebAssembly for fast AST processing, targeting Node.js and browser environments. Unlike alternatives like jquerty or manual migration, jQueReact aims for fully automatic transformation without runtime jQuery dependencies. Key differentiators include WASM performance, build-time transformation, and support for common jQuery methods (css, on, attr, append). Note that this is a very early release with limited feature completeness; complex patterns like animations and AJAX require manual refactoring.

error Error: WebAssembly module not initialized. Call init() first.
cause Forgot to call init() before transpile_jquery_to_react.
fix
Add 'await init();' before using transpile function.
error TypeError: transpile_jquery_to_react is not a function
cause Using wrong import (e.g., named import for init, or CJS require).
fix
Use default import for init: 'import init from "jquereact"' and named import for transpile: 'import { transpile_jquery_to_react } from "jquereact"'.
error Uncaught (in promise) RuntimeError: memory access out of bounds
cause WebAssembly module compiled incorrectly or incompatible environment.
fix
Rebuild WASM with 'wasm-pack build --target bundler' and ensure Node.js >= 16 or modern browser.
error jquereact: Transpiled output is empty string
cause Input jQuery code uses patterns not supported by the transpiler (e.g., animations, AJAX).
fix
Simplify the jQuery code to basic DOM manipulation (css, text, on, etc.) or manually refactor.
breaking jQueReact is pre-release v0.0.1 and the API is unstable. Expect many changes.
fix Pin to exact version and test upgrades thoroughly.
gotcha The package uses WebAssembly and requires async initialization before any transpilation. Calling transpile_jquery_to_react without init() will throw.
fix Always call init() and await it before using transpile.
deprecated This package is a placeholder and not actively maintained. It is not recommended for production use.
fix Consider alternatives like jscodeshift for jQuery migration.
breaking jQueReact only transforms a limited subset of jQuery methods. Complex patterns like animations, AJAX, or event namespaces will produce incorrect or empty output.
fix Manually refactor such code before or after transpilation.
gotcha The transpiler does not handle jQuery plugins or custom extensions. Any code using third-party jQuery plugins will not be transformed.
fix Replace plugins with React equivalents before transpilation.
npm install jquereact
yarn add jquereact
pnpm add jquereact

Initializes WASM, transpiles a simple jQuery chain to a React component, and logs the result.

import init, { transpile_jquery_to_react } from 'jquereact';

async function run() {
  await init();
  const jqCode = `$("div.container").css("color", "red").text("Hello!")`;
  const reactCode = transpile_jquery_to_react(jqCode);
  console.log(reactCode);
}
run();
// Expected output: function TransformedComponent() { return (<div className="container" style={{ color: "red" }}>Hello!</div>); }