{"id":15447,"library":"liferay-npm-bundler-plugin-inject-imports-dependencies","title":"Liferay NPM Bundler Plugin: Inject Imports Dependencies","description":"This is a specialized plugin for the `liferay-npm-bundler`, designed to automate the process of adding dependencies declared as imports within a project's `.npmbundlerrc` configuration directly into its `package.json` file. This streamlines dependency management for Liferay frontend modules, ensuring that all bundled modules are correctly listed as project dependencies, which is critical for Liferay Portal's OSGi-based module system. The current stable version of this plugin is 2.32.2. However, it's crucial to note that its host, `liferay-npm-bundler`, has been officially deprecated as of Liferay 2024.Q4/Portal GA129 and is slated for future removal. This plugin, therefore, is also considered deprecated as it relies entirely on the deprecated bundler's functionality. It served a key role in Liferay's prior frontend development workflow for packaging npm modules into OSGi bundles.","status":"deprecated","version":"2.32.2","language":"javascript","source_language":"en","source_url":"https://github.com/liferay/liferay-frontend-projects","tags":["javascript"],"install":[{"cmd":"npm install liferay-npm-bundler-plugin-inject-imports-dependencies","lang":"bash","label":"npm"},{"cmd":"yarn add liferay-npm-bundler-plugin-inject-imports-dependencies","lang":"bash","label":"yarn"},{"cmd":"pnpm add liferay-npm-bundler-plugin-inject-imports-dependencies","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is a plugin for liferay-npm-bundler and requires it for functionality. Note that liferay-npm-bundler itself is deprecated.","package":"liferay-npm-bundler","optional":false}],"imports":[{"note":"This package is a bundler plugin and is configured declaratively as a string in the `plugins` array within the `.npmbundlerrc` file. It does not export any JavaScript symbols for direct import.","wrong":"import { injectImportsDependencies } from 'liferay-npm-bundler-plugin-inject-imports-dependencies'","symbol":"\"inject-imports-dependencies\"","correct":"// In .npmbundlerrc plugins array:\n{\n\t\"*\": {\n\t\t\"plugins\": [\"inject-imports-dependencies\"]\n\t}\n}"},{"note":"Attempting to `require` this package in Node.js will not provide the plugin functionality. Its purpose is solely for configuration within `liferay-npm-bundler`.","wrong":"const injectPlugin = require('liferay-npm-bundler-plugin-inject-imports-dependencies');","symbol":"No direct CommonJS exports","correct":"N/A"},{"note":"This package does not expose an ES Module API for programmatic use. Its functionality is activated through its string name in the `.npmbundlerrc` configuration.","wrong":"import * as InjectImportsPlugin from 'liferay-npm-bundler-plugin-inject-imports-dependencies';","symbol":"No direct ES Module exports","correct":"N/A"}],"quickstart":{"code":"npm install --save-dev liferay-npm-bundler-plugin-inject-imports-dependencies\n\n// Then, create or update your .npmbundlerrc file in your project root:\n// (Example showing typical structure and plugin configuration)\n{\n\t\"*\": {\n\t\t\"plugins\": [\n\t\t\t\"inject-imports-dependencies\"\n\t\t]\n\t},\n\t// Example: Define an import that the plugin should inject as a dependency\n\t\"imports\": {\n\t\t\"some-lcom-module\": {\n\t\t\t\".\": \"/node_modules/some-lcom-module/index.js\"\n\t\t},\n\t\t\"another-utility\": {\n\t\t\t\".\": \"/node_modules/another-utility/dist/main.js\"\n\t\t}\n\t}\n}","lang":"json","description":"This quickstart demonstrates how to install the plugin and enable it in your Liferay frontend project's `.npmbundlerrc` file to automatically inject declared import dependencies into `package.json`. **Note:** The underlying `liferay-npm-bundler` and its plugins are deprecated."},"warnings":[{"fix":"Plan migration of Liferay frontend projects away from `liferay-npm-bundler` and its plugins to modern JavaScript bundlers (esbuild, Webpack, Vite) as recommended by Liferay. Remove `liferay-npm-bundler-plugin-inject-imports-dependencies` and its configuration from `.npmbundlerrc` files.","message":"The underlying `liferay-npm-bundler` (which this plugin extends) has been officially deprecated as of Liferay 2024.Q4/Portal GA129 and is planned for future removal. Liferay is transitioning to standard JavaScript tooling (e.g., esbuild, Webpack, Vite) for frontend development. Using this plugin in new projects or continuing its use in existing projects beyond the stated deprecation timeline will lead to an unsupported and eventually non-functional build process.","severity":"breaking","affected_versions":">=2.32.2"},{"fix":"Consult the Liferay frontend projects documentation or changelog for specific compatibility matrices. Upgrade or downgrade `liferay-npm-bundler` and related toolkit packages as needed.","message":"This plugin is tightly coupled with `liferay-npm-bundler` and the Liferay frontend build ecosystem. Ensure compatibility between the plugin's version, the bundler's version, and your Liferay Portal version to avoid unexpected build failures or incorrect dependency injection.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Verify that `liferay-npm-bundler-plugin-inject-imports-dependencies` is listed in your `devDependencies` and that 'inject-imports-dependencies' is correctly spelled in the 'plugins` array within your `.npmbundlerrc` file. Ensure the plugin is placed in the correct `pre-process` or `post-process` phase if specified.","cause":"The plugin name is misspelled in `.npmbundlerrc` or the package was not installed correctly.","error":"Plugin 'inject-imports-dependencies' not found or invalid."},{"fix":"Ensure the plugin is correctly listed in the `plugins` array in your `.npmbundlerrc`. Double-check the structure and paths within your `imports` configuration to ensure they are valid and resolvable by the bundler. Check bundler logs for any warnings or errors during the build process.","cause":"The `liferay-npm-bundler-plugin-inject-imports-dependencies` plugin might not be correctly activated or there are issues with the `imports` configuration itself in `.npmbundlerrc`.","error":"Declared imports are not being added to package.json dependencies."}],"ecosystem":"npm"}