Registry / web-framework / zecorn

zecorn

JSON →
library0.10.1jsnpmunverified

zecorn is a Babel-compatible transpiler built on acorn, version 0.10.1. It provides a babel plugin layer with strong source mapping, enabling reuse of existing Babel plugins. Developed for WMR but usable standalone. Unlike Babel, it uses acorn for parsing, offering lighter weight and faster transforms. Ships TypeScript types. Release cadence is sporadic; check GitHub for latest.

npm install zecorn
INSTALL
IMPORT
SIG · ZECORN
Z
zecorn
web-frameworkjavascriptv0.10.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

transform
import { transform } from 'zecorn'
const { transform } = require('zecorn')
ESM-only; CommonJS require is not supported.
parse
import { parse } from 'zecorn'
const parse = require('zecorn').parse
Default parse function; ESM-only.
acornPlugins
import { acornPlugins } from 'zecorn'
Exported array of acorn plugins for custom parser setup.

Shows basic usage of transform with a custom Babel plugin replacing a numeric literal.

import { transform, parse } from 'zecorn'; function myBabelPlugin({ types: t }) { return { name: 'my-plugin', visitor: { NumericLiteral(path) { path.replaceWith(t.identifier('foobar')); }, }, }; } const result = transform('const a = 42', { parse, plugins: [myBabelPlugin], }); console.log(result.code); // 'const a = foobar;'
Debug
Known issues
breakingzecorn uses acorn for parsing, not Babel's parser. Some Babel plugins relying on Babel-specific AST types may not work.
fix
Use only plugins that are compatible with acorn AST or wrap them with acorn-specific adapters.
affects: >=0.1.0
gotchaThe 'parse' option in transform must provide a function with a specific signature. Using a custom parser without proper signature may cause errors.
fix
Ensure parse function accepts (code, opts) and returns an AST object compatible with acorn.
affects: >=0.1.0
deprecatedThis library is designed for WMR and may not receive frequent updates. Check for new releases before using in production.
fix
Monitor the repository for updates or consider using alternatives like Babel standalone.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'zecorn'
zecorn not installed or not in node_modules.
fix
Run 'npm install -D zecorn' or 'yarn add -D zecorn'.
TypeError: (0 , zecorn.transform) is not a function
Incorrect import style; using require with ESM package.
fix
Use ES module import syntax: import { transform } from 'zecorn'
Error: The 'parse' option must be a function
Missing or incorrect parse function passed to transform.
fix
Ensure you pass a valid parse function, e.g., import { parse } from 'zecorn' and pass it as { parse }.
Upgrade
Version history
0.10.1latest on npm
Audit
Dependencies
acornrequiredCore parser dependency; zecorn uses acorn internally.
Agent activity
27 hits · last 30 days
node
24
OpenAI (training)
1
Resources
zecorn — npm install zecorn · libregistry