Registry / devops / liferay-npm-bundler-plugin-inject-peer-dependencies

liferay-npm-bundler-plugin-inject-peer-dependencies

JSON →
library2.32.2jsnpmunverified

This package, `liferay-npm-bundler-plugin-inject-peer-dependencies`, is a plugin for `liferay-npm-bundler` that automates the injection of peer and undeclared dependencies into `package.json` files. It specifically targets dependencies found within AMD `define()` calls in module files, provided they are installed in `node_modules`. This functionality is crucial for ensuring peer dependencies operate correctly within Liferay's OSGi-based npm architecture and can also resolve certain incorrect setups that might otherwise work in a standard Node.js environment. The plugin determines dependency versions using the standard Node.js resolution algorithm from the module's context. The current stable version is 2.32.2. As part of the broader `liferay-frontend-projects` monorepo, its release cadence is tied to Liferay's development cycles, with frequent updates across various tooling components. Its key differentiator is its specialized function within the Liferay ecosystem, addressing specific challenges of module loading and dependency resolution in that platform.

npm install liferay-npm-bundler-plugin-inject-peer-dependencies
INSTALL
IMPORT
SIG · LIFERAY-NPM-BUNDLE
L
liferay-npm-bundler-plugin-inject-peer-dependencies
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.

Configuring the plugin
/* In your .npmbundlerrc */ { "*": { "plugins": ["inject-peer-dependencies"] } }
import InjectPeerDependenciesPlugin from 'liferay-npm-bundler-plugin-inject-peer-dependencies';
This package is a bundler plugin and is configured declaratively in the `.npmbundlerrc` file, not imported directly into JavaScript/TypeScript code. The string 'inject-peer-dependencies' refers to the plugin's name within the bundler's context.
Configuring with options
/* In your .npmbundlerrc */ { "*": { "plugins": [ [ "inject-peer-dependencies", { "defineCall": "Liferay.Loader.define" } ] ] } }
Options for the plugin are passed as an array where the first element is the plugin name string and the second is an object containing the configuration properties.

This quickstart demonstrates how to configure the `inject-peer-dependencies` plugin within a `.npmbundlerrc` file, showing both basic inclusion and inclusion with custom options like `defineCall`. It also contextualizes its use with illustrative package.json and module file content.

{ "*": { "plugins": [ [ "inject-peer-dependencies", { "defineCall": "Liferay.Loader.define" } ] ] }, "test-module": { "dependencies": { "lodash": "*" } } } // Example package.json for a module that would benefit from this plugin /* { "name": "my-liferay-module", "version": "1.0.0", "peerDependencies": { "react": "^17.0.0" }, "devDependencies": { "liferay-npm-bundler-plugin-inject-peer-dependencies": "^2.0.0", "liferay-npm-bundler": "^2.0.0" } } */ // Example module.js content where 'react' would be detected as a peer dependency /* define(["react", "./MyComponent"], function(React, MyComponent) { return function App() { return React.createElement(MyComponent, null, "Hello"); }; }); */
Debug
Known issues
gotchaThe plugin only injects dependencies if they are already installed in `node_modules` and listed in the project's `package.json`. It does not automatically install missing packages.
fix
Ensure all peer and undeclared dependencies are explicitly listed in your module's `package.json` and installed via `npm install` or `yarn install` before running the bundler.
affects: >=1.0.0
gotchaThis plugin is specifically designed for the Liferay npm architecture and may not be necessary or function as expected in other bundling contexts. It relies on the AMD `define()` pattern for dependency detection.
fix
Only use this plugin when developing modules for Liferay portals, where the `liferay-npm-bundler` is the primary build tool.
affects: >=1.0.0
breakingOlder versions of `liferay-npm-bundler` or this plugin might have different resolution algorithms or configuration options for `defineCall` or similar properties. Always consult the specific version's documentation.
fix
Upgrade to the latest `liferay-npm-bundler` and `liferay-npm-bundler-plugin-inject-peer-dependencies` to ensure compatibility and leverage the most current features and fixes. Review changelogs for specific breaking changes in major versions.
affects: <2.0.0
gotchaMisconfigured `defineCall` (e.g., if Liferay's loader is customized) can prevent the plugin from correctly identifying AMD dependencies, leading to missed injections.
fix
Verify the `defineCall` option matches the actual AMD define function used by your Liferay environment. The default `Liferay.Loader.define` is common, but custom setups might vary.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Missing dependency '<dependency-name>' in module '<module-name>'
The bundler could not find a required dependency in `node_modules` or `package.json`, even after the injection plugin ran.
fix
Check that '<dependency-name>' is listed in the `dependencies`, `devDependencies`, or `peerDependencies` section of your module's `package.json` and that `npm install` has been run successfully.
Plugin 'inject-peer-dependencies' not found
The `liferay-npm-bundler-plugin-inject-peer-dependencies` package is not installed or not accessible to the bundler.
fix
Ensure the plugin is installed as a `devDependency` (`npm install --save-dev liferay-npm-bundler-plugin-inject-peer-dependencies`) and that `liferay-npm-bundler` is correctly configured to find plugins.
Module not found: Error: Can't resolve '<dependency>' in '<path>'
Despite the plugin, the bundler or runtime still cannot resolve a dependency, potentially due to incorrect path resolution or an unusual `define()` call.
fix
Verify the `defineCall` option in `.npmbundlerrc` is correct. Inspect the generated bundle to see if the dependency was actually injected. Manually check the module's AMD `define()` calls for any non-standard syntax.
Upgrade
Version history
2.32.2latest on npm
Audit
Dependencies
liferay-npm-bundlerrequiredThis package is a plugin for the liferay-npm-bundler and requires it to function. It is configured via the `.npmbundlerrc` file used by the bundler.
Agent activity
2 hits · last 30 days
node
2
Resources
liferay-npm-bundler-plugin-inject-peer-dependencies — npm install liferay-npm-bundler-plugin-inject-peer-dependencies · libregistry