Liferay NPM Bundler Plugin: Inject Imports Dependencies

2.32.2 · deprecated · verified Tue Apr 21

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

npm install --save-dev liferay-npm-bundler-plugin-inject-imports-dependencies

// Then, create or update your .npmbundlerrc file in your project root:
// (Example showing typical structure and plugin configuration)
{
	"*": {
		"plugins": [
			"inject-imports-dependencies"
		]
	},
	// Example: Define an import that the plugin should inject as a dependency
	"imports": {
		"some-lcom-module": {
			".": "/node_modules/some-lcom-module/index.js"
		},
		"another-utility": {
			".": "/node_modules/another-utility/dist/main.js"
		}
	}
}

view raw JSON →