# esm-ast-to-cjs **Repository Path**: als2014/esm-ast-to-cjs ## Basic Information - **Project Name**: esm-ast-to-cjs - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2024-02-20 - **Last Updated**: 2024-02-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README This library converts and the AST (Abstract Syntax Tree) of an ESM program to CommonJS. Note: Dynamic imports are not yet supported. ```js import acorn from 'acorn' import astring from 'astring' import convert from 'esm-ast-to-cjs' const script = ` import test from 'test' export default test ` const opts = { sourceType: 'module' } const ast = acorn.parse(script, opts) convert(ast) const cjs = astring.generate(ast) console.log(cjs) // const test = require('test');\nmodule.exports = test'\n ```