{"id":26681,"library":"zecorn","title":"zecorn","description":"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.","status":"active","version":"0.10.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","acorn","babel","transpiler","typescript"],"install":[{"cmd":"npm install zecorn","lang":"bash","label":"npm"},{"cmd":"yarn add zecorn","lang":"bash","label":"yarn"},{"cmd":"pnpm add zecorn","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core parser dependency; zecorn uses acorn internally.","package":"acorn","optional":false}],"imports":[{"note":"ESM-only; CommonJS require is not supported.","wrong":"const { transform } = require('zecorn')","symbol":"transform","correct":"import { transform } from 'zecorn'"},{"note":"Default parse function; ESM-only.","wrong":"const parse = require('zecorn').parse","symbol":"parse","correct":"import { parse } from 'zecorn'"},{"note":"Exported array of acorn plugins for custom parser setup.","wrong":"","symbol":"acornPlugins","correct":"import { acornPlugins } from 'zecorn'"}],"quickstart":{"code":"import { transform, parse } from 'zecorn';\nfunction myBabelPlugin({ types: t }) {\n  return {\n    name: 'my-plugin',\n    visitor: {\n      NumericLiteral(path) {\n        path.replaceWith(t.identifier('foobar'));\n      },\n    },\n  };\n}\nconst result = transform('const a = 42', {\n  parse,\n  plugins: [myBabelPlugin],\n});\nconsole.log(result.code); // 'const a = foobar;'","lang":"typescript","description":"Shows basic usage of transform with a custom Babel plugin replacing a numeric literal."},"warnings":[{"fix":"Use only plugins that are compatible with acorn AST or wrap them with acorn-specific adapters.","message":"zecorn uses acorn for parsing, not Babel's parser. Some Babel plugins relying on Babel-specific AST types may not work.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Ensure parse function accepts (code, opts) and returns an AST object compatible with acorn.","message":"The 'parse' option in transform must provide a function with a specific signature. Using a custom parser without proper signature may cause errors.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Monitor the repository for updates or consider using alternatives like Babel standalone.","message":"This library is designed for WMR and may not receive frequent updates. Check for new releases before using in production.","severity":"deprecated","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install -D zecorn' or 'yarn add -D zecorn'.","cause":"zecorn not installed or not in node_modules.","error":"Cannot find module 'zecorn'"},{"fix":"Use ES module import syntax: import { transform } from 'zecorn'","cause":"Incorrect import style; using require with ESM package.","error":"TypeError: (0 , zecorn.transform) is not a function"},{"fix":"Ensure you pass a valid parse function, e.g., import { parse } from 'zecorn' and pass it as { parse }.","cause":"Missing or incorrect parse function passed to transform.","error":"Error: The 'parse' option must be a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}