{"id":25239,"library":"es6-module-crosspiler","title":"es6-module-crosspiler","description":"An ES6 and CommonJS cross-compatible transpiler that enables mixed usage of ES6 modules and CommonJS modules during migration. Version 2.0.1 is the latest stable release but appears to be in maintenance mode as the project has seen no recent updates and uses legacy dependencies like recast and esprima-fb. Unlike higher-level transpilers (e.g., Babel), this is a lower-level library that operates on recast ASTs, allowing flexibility in custom build pipelines but lacking file system resolution and custom formatters.","status":"maintenance","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/polyfills/es6-module-crosspiler","tags":["javascript","es6","module","transpiler","crosspiler","cjs","commonjs"],"install":[{"cmd":"npm install es6-module-crosspiler","lang":"bash","label":"npm"},{"cmd":"yarn add es6-module-crosspiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add es6-module-crosspiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for AST parsing and printing; the library expects a recast AST as input.","package":"recast","optional":false},{"reason":"Required for parsing ES6 module syntax, as official esprima versions did not fully support ES6 modules at the time of writing.","package":"esprima-fb","optional":true}],"imports":[{"note":"The library uses a default export. In CommonJS, require returns the default export directly.","wrong":"const Module = require('es6-module-crosspiler').default","symbol":"Module","correct":"import Module from 'es6-module-crosspiler'"},{"note":"Static convenience method; must be called on the Module class, not an instance.","wrong":"Module.transform(ast, { ... }) // incorrect: options should be passed as second argument","symbol":"Module.transform","correct":"Module.transform(ast, options)"},{"note":"Static convenience method; returns an array of dependency names.","wrong":"m.dependenciesOf(ast) // instance method does not exist; use static method","symbol":"Module.dependenciesOf","correct":"Module.dependenciesOf(ast)"}],"quickstart":{"code":"var recast = require('recast');\nvar esprima = require('esprima-fb');\nvar Module = require('es6-module-crosspiler');\n\nvar code = 'import { foo } from \\'./lib\\';';\nvar ast = recast.parse(code, { esprima: esprima });\n\nvar m = new Module(ast, {\n  dependencies: {\n    './lib': { type: 'module', default: false }\n  }\n});\n\nvar transformedAst = m.transform();\nvar result = recast.print(transformedAst);\nconsole.log(result.code);","lang":"javascript","description":"This shows how to transpile a simple ES6 import statement to CommonJS using recast, esprima-fb, and the crosspiler."},"warnings":[{"fix":"Use a more modern transpiler like Babel or TypeScript for ES6 module transpilation.","message":"The library depends on 'esprima-fb', which is deprecated and may not support recent ES6 features.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"When cross-compiling, ensure that CommonJS modules do not export a .default property, as it will be overridden.","message":"The default export handling differs from standard ES6 module semantics: CommonJS modules imported from ES6 modules are treated as default exports without the .default property.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Migrate to a maintained transpiler such as Babel or esbuild.","message":"The package has not been updated since 2015 and uses deprecated dependencies like 'recast' and 'esprima-fb'.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Always provide dependency metadata to avoid incorrect transpilation.","message":"The library requires explicit metadata for each dependency (.set() or constructor), otherwise it defaults to { type: 'module', default: false }.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use a custom esprima that supports ES6 modules, e.g., 'esprima-fb', when calling recast.parse().","cause":"The JavaScript parser does not support ES6 module syntax (requires esprima-fb or similar).","error":"SyntaxError: Unexpected token 'import'"},{"fix":"Use default import: import Module from 'es6-module-crosspiler'","cause":"Attempting 'import { Module } from ...' instead of 'import Module from ...'","error":"The module was imported incorrectly, e.g., using named import instead of default import."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}