{"id":19110,"library":"babel-plugin-namespace-amd-define","title":"babel-plugin-namespace-amd-define","description":"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.","status":"active","version":"2.32.2","language":"javascript","source_language":"en","source_url":"https://github.com/liferay/liferay-frontend-projects","tags":["javascript"],"install":[{"cmd":"npm install babel-plugin-namespace-amd-define","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-namespace-amd-define","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-namespace-amd-define","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Requires Babel core to run","package":"@babel/core","optional":false}],"imports":[{"note":"ESM default import is the correct way to import the plugin for programmatic use.","wrong":"const { namespaceAmdDefine } = require('babel-plugin-namespace-amd-define')","symbol":"default","correct":"import plugin from 'babel-plugin-namespace-amd-define'"},{"note":"When using string shorthand in Babel config, omit the 'babel-plugin-' prefix.","wrong":"module.exports = { plugins: ['babel-plugin-namespace-amd-define'] }","symbol":"plugin as","correct":"// In .babelrc or babel.config.js:\nmodule.exports = { plugins: ['namespace-amd-define'] }"},{"note":"Options are passed as the second element of an array, not as an object property.","wrong":"module.exports = { plugins: [{ name: 'namespace-amd-define', options: { namespace: 'MyApp' } }] }","symbol":"with options","correct":"module.exports = { plugins: [['namespace-amd-define', { namespace: 'MyApp' }]] }"}],"quickstart":{"code":"// babel.config.js\nmodule.exports = {\n  plugins: [\n    [\n      'namespace-amd-define',\n      { namespace: 'window.MyApp' }\n    ]\n  ]\n};\n\n// Input: define(['dep'], function() { });\n// Output: window.MyApp.define(['dep'], function() { });","lang":"javascript","description":"Configures Babel to prefix AMD define() calls with a custom namespace."},"warnings":[{"fix":"Explicitly set the 'namespace' option to your desired prefix.","message":"If you omit options, the plugin uses 'Liferay.Loader' as the default namespace, which may not be appropriate for non-Liferay projects.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure your define() calls are at module top level.","message":"The plugin only transforms top-level define() calls; nested define() inside functions or conditional blocks are not affected.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use a separate plugin or manual transformation for require() calls.","message":"The plugin does not handle AMD require() calls; only define() is namespaced.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install --save-dev babel-plugin-namespace-amd-define' and use shorthand 'namespace-amd-define' in plugin list.","cause":"Plugin not installed or incorrect import in Babel config.","error":"Error: Cannot find module 'babel-plugin-namespace-amd-define'"},{"fix":"Use the plugin as a string in Babel config: 'namespace-amd-define'.","cause":"Plugin was imported using default import but used incorrectly.","error":"TypeError: plugin is not a function"},{"fix":"Use forward slashes or path.resolve() to create cross-platform paths.","cause":"The plugin may not normalize backslashes on Windows.","error":"Windows path issues when using absolute paths in options"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}