Registry / serialization / babel-plugin-wrap-modules-amd

babel-plugin-wrap-modules-amd

JSON →
library2.32.2jsnpmunverified

A Babel plugin (v2.32.2, last released 2024-03-05) that wraps CommonJS modules inside AMD define() calls. It automatically detects require() calls and adds them as AMD dependencies, removing the need for manual dependency arrays. Part of the Liferay Frontend Projects monorepo, maintained for liferay-portal build system. Infrequently updated; stable but low community adoption outside Liferay. Requires Babel 6/7 and the plugin must be listed in .babelrc. No active development seen in recent years.

npm install babel-plugin-wrap-modules-amd
INSTALL
IMPORT
SIG · BABEL-PLUGIN-WRAP-
B
babel-plugin-wrap-modules-amd
serializationjavascriptv2.32.2
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import plugin from 'babel-plugin-wrap-modules-amd'; // ESM
✗ const plugin = require('babel-plugin-wrap-modules-amd'); // CJS require
Plugin is CommonJS internally but can be imported via ESM in Babel config when using module system.
wrapModuleAmdPlugin
✓ import { wrapModuleAmdPlugin } from 'babel-plugin-wrap-modules-amd';
✗ import wrapModuleAmdPlugin from 'babel-plugin-wrap-modules-amd';
Plugin does not export a named symbol; only default export is available.
babel.config.js usage
✓ module.exports = { plugins: ['wrap-modules-amd'] };
✗ module.exports = { plugins: ['babel-plugin-wrap-modules-amd'] };
Babel resolves short plugin name; the full npm package name is not required.

Shows how to configure the plugin in .babelrc and its effect: a CommonJS module with require() gets wrapped in an AMD define() call with dependencies auto-detected.

// .babelrc { "plugins": ["wrap-modules-amd"] } // Input file (source.js) var fs = require('fs'); console.log(fs.readFileSync('data.txt', 'utf8')); // After Babel transformation, output becomes: define(['module', 'exports', 'require', 'fs'], function (module, exports, require) { var fs = require('fs'); console.log(fs.readFileSync('data.txt', 'utf8')); });
Debug
Known issues
gotchaPlugin only supports CommonJS require() calls; does not handle dynamic imports or ES modules.
fix
Use Babel plugin-transform-modules-commonjs first if using ES import syntax.
affects: >=2.0.0
gotchaThe plugin does not support named AMD modules; define() always uses anonymous definition.
fix
If you need named modules, use a different plugin like babel-plugin-amd-define.
affects: >=2.0.0
deprecatedMaintenance mode; no new features planned. Consider migrating to modern bundlers like Webpack or Rollup if possible.
fix
Use a modern bundler that outputs AMD if needed, or adopt a different output format.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-wrap-modules-amd'
The plugin is not installed, or Node.js cannot resolve it when running Babel.
fix
Run: npm install --save-dev babel-plugin-wrap-modules-amd and ensure node_modules path is correct.
ReferenceError: define is not defined
The wrapped AMD module is executed in an environment without an AMD loader (like RequireJS).
fix
Include an AMD loader such as RequireJS, or use the plugin to output CommonJS instead.
Upgrade
Version history
2.32.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
22
OpenAI (training)
2
Anthropic
1
Resources
babel-plugin-wrap-modules-amd — npm install babel-plugin-wrap-modules-amd · libregistry