Registry / serialization / amd-to-es6

amd-to-es6

JSON →
library0.2.0jsnpmunverified

A CLI and programmatic tool to convert AMD modules (define pattern) into ES6 module syntax. Current version 0.2.0, last updated in 2014. It handles simple cases like modules with/without dependencies and imports for side-effects, but does NOT support named define modules, multiple define per file, or UMD patterns. The library is effectively abandoned as there are more modern alternatives like jscodeshift or lebab, and no updates since 2014. It works by parsing AMD define calls and rewriting to import/export statements, with options for directory batch processing, glob patterns, and beautification via jsbeautify.

npm install amd-to-es6
INSTALL
IMPORT
SIG · AMD-TO-ES6
A
amd-to-es6
serializationjavascriptv0.2.0
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.

convert
import { convert } from 'amd-to-es6'
var convert = require('amd-to-es6')
Package is ESM-only; CommonJS require will fail because the package does not export a UMD wrapper.
default
import amdToEs6 from 'amd-to-es6'
const amdToEs6 = require('amd-to-es6').default
The package only exports a named convert function, not a default export. This pattern will result in undefined.
convertSync
import { convertSync } from 'amd-to-es6'
Not exported; convertSync does not exist in this package. Use convert() which is async.

Demonstrates programmatic conversion of an AMD module with two dependencies to ES6 module syntax using the convert function.

import { convert } from 'amd-to-es6'; const amdCode = `define(['path/to/a', 'path/to/b'], function (a, b) { return function (x) { return a(b(x)); }; });`; try { const es6Code = convert(amdCode); console.log(es6Code); } catch (error) { console.error('Conversion failed:', error.message); }
amd-to-es6 --version
Debug
Known issues
deprecatedPackage is unmaintained since 2014; no support for modern JavaScript features or fixes.
fix
Consider using jscodeshift or lebab for AMD to ES6 conversion.
affects: >=0.0.0
breakingDoes not support named define modules; those will throw an error or be silently skipped.
fix
Manually rename named defines to anonymous before conversion or use an alternative tool.
affects: >=0.0.0
breakingDoes not support UMD modules where define callback is not a function literal (e.g., define(factoryFn)).
fix
Rewrite UMD modules to plain AMD define patterns before conversion.
affects: >=0.0.0
gotchaGenerated variable names for dynamic requires use ugly prefixes like $__path_to_a, which may break coding standards.
fix
Manually rename generated variable names after conversion.
affects: >=0.0.0
breakingThe package is ESM-only; using require() will fail with ReferenceError or undefined.
fix
Use import syntax and ensure your Node.js version supports ESM, or transpile your code.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: convert is not a function
Incorrect import or using require on an ESM-only package.
fix
Use import { convert } from 'amd-to-es6' instead of require.
Error: Unsupported define format
Named define modules or UMD patterns not supported.
fix
Remove the name from define('name', ...) or rewrite UMD to anonymous define.
SyntaxError: Unexpected token
Input contains multiple define calls or invalid AMD syntax.
fix
Ensure each file has exactly one define call with a function literal callback.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
42 hits · last 30 days
node
38
OpenAI (training)
1
Resources
amd-to-es6 — npm install amd-to-es6 · libregistry