Registry / devops / babel-plugin-namespace-amd-define

babel-plugin-namespace-amd-define

JSON →
library2.32.2jsnpmunverified

A Babel plugin that prefixes AMD define() calls with a configurable namespace string, primarily used by Liferay projects. Current stable version is 2.32.2. It transforms define() to Liferay.Loader.define() by default, and supports custom namespaces via options. Unlike general-purpose plugins, it targets a niche use case: prepending a namespace to all AMD define calls in legacy codebases.

npm install babel-plugin-namespace-amd-define
INSTALL
IMPORT
SIG · BABEL-PLUGIN-NAMES
B
babel-plugin-namespace-amd-define
devopsjavascriptv2.32.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default
import plugin from 'babel-plugin-namespace-amd-define'
const { namespaceAmdDefine } = require('babel-plugin-namespace-amd-define')
ESM default import is the correct way to import the plugin for programmatic use.
plugin as
// In .babelrc or babel.config.js: module.exports = { plugins: ['namespace-amd-define'] }
module.exports = { plugins: ['babel-plugin-namespace-amd-define'] }
When using string shorthand in Babel config, omit the 'babel-plugin-' prefix.
with options
module.exports = { plugins: [['namespace-amd-define', { namespace: 'MyApp' }]] }
module.exports = { plugins: [{ name: 'namespace-amd-define', options: { namespace: 'MyApp' } }] }
Options are passed as the second element of an array, not as an object property.

Configures Babel to prefix AMD define() calls with a custom namespace.

// babel.config.js module.exports = { plugins: [ [ 'namespace-amd-define', { namespace: 'window.MyApp' } ] ] }; // Input: define(['dep'], function() { }); // Output: window.MyApp.define(['dep'], function() { });
Debug
Known issues
gotchaIf you omit options, the plugin uses 'Liferay.Loader' as the default namespace, which may not be appropriate for non-Liferay projects.
fix
Explicitly set the 'namespace' option to your desired prefix.
affects: >=0.0.0
gotchaThe plugin only transforms top-level define() calls; nested define() inside functions or conditional blocks are not affected.
fix
Ensure your define() calls are at module top level.
affects: >=0.0.0
deprecatedThe plugin does not handle AMD require() calls; only define() is namespaced.
fix
Use a separate plugin or manual transformation for require() calls.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-namespace-amd-define'
Plugin not installed or incorrect import in Babel config.
fix
Run 'npm install --save-dev babel-plugin-namespace-amd-define' and use shorthand 'namespace-amd-define' in plugin list.
TypeError: plugin is not a function
Plugin was imported using default import but used incorrectly.
fix
Use the plugin as a string in Babel config: 'namespace-amd-define'.
Windows path issues when using absolute paths in options
The plugin may not normalize backslashes on Windows.
fix
Use forward slashes or path.resolve() to create cross-platform paths.
Upgrade
Version history
2.32.2latest on npm
Audit
Dependencies
@babel/corerequiredRequires Babel core to run
Agent activity
4 hits · last 30 days
node
4
Resources
babel-plugin-namespace-amd-define — npm install babel-plugin-namespace-amd-define · libregistry