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-dependenciesVerified import paths — ran on the pinned version, not inferred.
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.
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.
Only use this plugin when developing modules for Liferay portals, where the `liferay-npm-bundler` is the primary build tool.
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.
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.
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.
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.
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.