Registry /
devops / babel-plugin-add-module-metadata
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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ module.exports = function() { return { visitor: { ... } }; };
✗ import plugin from 'babel-plugin-add-module-metadata'; export default plugin;
This is a Babel plugin designed for CommonJS; it should be used in .babelrc or babel.config.js as a string 'add-module-metadata'. Direct import/export is rare but if needed, use require() for CJS.
add-module-metadata
✓ plugins: ['add-module-metadata']
✗ plugins: ['babel-plugin-add-module-metadata']
Babel resolves the plugin name without the 'babel-plugin-' prefix when listed in .babelrc or babel.config.js.
babel-plugin-add-module-metadata
✓ const plugin = require('babel-plugin-add-module-metadata'); plugins: [plugin];
✗ import plugin from 'babel-plugin-add-module-metadata'; plugins: [plugin];
You can require and pass the plugin as an object, but the simpler string form is recommended.
Shows minimal .babelrc configuration and the expected transformation from an AMD module to manifest.json metadata.
// .babelrc
{
"plugins": ["add-module-metadata"]
}
// Example input (to trigger metadata generation):
// file: src/foo.js
Liferay.Loader.define('my-module', ['exports', 'require'], function(exports, require) {
'use strict';
exports.default = 'hello';
});
// After building with liferay-npm-bundler, manifest.json will include:
// {
// "packages": {
// "my-module": {
// "metadata": { ... }
// }
// }
// }
liferay-npm-bundler --version
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-add-module-metadata'
Missing or incorrect installation of the plugin.
fixRun `npm install --save-dev babel-plugin-add-module-metadata` and ensure it's in node_modules.
TypeError: plugin is not a function
Passing the plugin string instead of a function in a JavaScript config file that expects function references.
fixUse the string syntax: `plugins: ['add-module-metadata']`.
SyntaxError: Unexpected token 'export'
Using ES module syntax in a Babel config file that is treated as CommonJS.
fixUse `module.exports = { plugins: ['add-module-metadata'] };` instead of `export default`. Audit
Dependencies
@babel/corerequiredRequired as a peer dependency because the plugin is a Babel transformation.
liferay-npm-bundlerrequiredThe plugin's output (manifest.json) is consumed by the bundler; without it, the plugin is useless.