esmod is a fast in-place transpiler for converting ES6 import/export statements to CommonJS require/exports. Version 1.0.0 is currently stable, with a focus on speed by leveraging AST-based transformation rather than regex-only approaches. It distinguishes itself from tools like esbuild or Babel by being designed for lightweight, single-file transformations without module resolution or bundling — ideal for build tool authors and custom pipelines.
npm install esmodNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Converts an ES module file (.mjs) to CommonJS (.cjs) using esmod's transform function with explicit source and target formats.
Wrap in try/catch (not .catch()) since it's not a Promise.
Ensure code is pure ES module syntax before passing to transform.
Always specify both targets to avoid accidental no-op.
Access result.code immediately after calling transform() without await.
Set { from: 'esm' } in options.Set 'to' to 'cjs' to convert to CommonJS.
No dependency data recorded yet.