Registry / devops / babel-plugin-add-module-metadata

babel-plugin-add-module-metadata

JSON →
library2.32.2jsnpmunverified

A Babel plugin for the Liferay ecosystem that scans JavaScript modules for predefined code patterns and adds corresponding metadata entries to the manifest.json file generated by the liferay-npm-bundler. Version 2.32.2 is the latest stable release, maintained as part of the liferay-frontend-projects monorepo with monthly to quarterly releases. Unlike generic Babel plugins, this one is tailored specifically for Liferay's AMD module system, enabling module description prior to load or parse. It is used in conjunction with the Liferay JS Toolkit and npm bundler.

npm install babel-plugin-add-module-metadata
INSTALL
IMPORT
SIG · BABEL-PLUGIN-ADD-M
B
babel-plugin-add-module-metadata
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
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
Debug
Known issues
gotchaThis plugin only works in conjunction with liferay-npm-bundler. Without it, no manifest.json is generated.
fix
Ensure liferay-npm-bundler is part of your build process.
affects: *
gotchaPlugin does nothing if the code does not follow Liferay's AMD module patterns. Standard ES modules are not scanned.
fix
Use Liferay.Loader.define or compatible AMD module definitions.
affects: *
deprecatedThe older manifest.json format (v1) was deprecated in liferay-npm-bundler v2.0. Newer plugins generate v2 metadata but this plugin may not be updated for v2 format.
fix
Check liferay-npm-bundler version. If using bundler v2+, consider migrating to the latest js-toolkit.
affects: >=2.30.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-add-module-metadata'
Missing or incorrect installation of the plugin.
fix
Run `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.
fix
Use 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.
fix
Use `module.exports = { plugins: ['add-module-metadata'] };` instead of `export default`.
Upgrade
Version history
2.32.2latest on npm
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.
Agent activity
2 hits · last 30 days
node
2
Resources
babel-plugin-add-module-metadata — npm install babel-plugin-add-module-metadata · libregistry