Registry / devops / liferay-npm-bundler-plugin-exclude-imports

liferay-npm-bundler-plugin-exclude-imports

JSON →
library2.32.2jsnpmunverified

liferay-npm-bundler-plugin-exclude-imports is a plugin designed for the liferay-npm-bundler tool, currently at version 2.32.2. Its core function is to allow developers to explicitly exclude specific imported dependencies from the final JavaScript bundle generated for Liferay DXP projects. This is critical for managing bundle sizes and leveraging Liferay's OSGi module runtime, where certain dependencies might be provided globally or by other deployed modules, preventing duplication. While it facilitates fine-grained control over bundling, the liferay-npm-bundler itself, and by extension this plugin, has been officially deprecated as of Liferay 2024 Q4/Portal GA129, with plans for future removal in favor of standard JavaScript tooling like Esbuild, Webpack, or Vite. Releases are part of the broader liferay-frontend-projects monorepo, suggesting its lifecycle is tied to the evolution of Liferay's frontend tooling, although this specific package does not have frequent individual releases. It's a key tool for legacy Liferay DXP projects requiring fine-grained control over OSGi-compliant module bundling.

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

ExcludeImportsPlugin
import ExcludeImportsPlugin from 'liferay-npm-bundler-plugin-exclude-imports';
import { ExcludeImportsPlugin } from 'liferay-npm-bundler-plugin-exclude-imports';
This plugin is primarily configured via a string reference ('exclude-imports') within the `.npmbundlerrc` file. Direct programmatic import of its main export (e.g., a plugin class or factory function) is less common for end-users, but might be used when customizing the bundler's internal plugin loading or for testing.
ExcludeImportsPlugin
const ExcludeImportsPlugin = require('liferay-npm-bundler-plugin-exclude-imports');
CommonJS `require` syntax for environments that do not support ESM or for legacy custom bundler scripts. While modern Liferay frontend projects often use ESM, `require` might still be encountered in some contexts. The bundler itself loads plugins internally by name resolution, making direct `require` by end-users rare.
ExcludeImportsPluginType
import type { ExcludeImportsPluginType } from 'liferay-npm-bundler-plugin-exclude-imports';
import { ExcludeImportsPluginType } from 'liferay-npm-bundler-plugin-exclude-imports';
For TypeScript users who might need to type a plugin instance if interacting with it programmatically. This assumes the package provides a corresponding type definition for its primary export.

Demonstrates how to configure the plugin in a Liferay project's `.npmbundlerrc` file to exclude specific dependencies like 'some-common-utility' or 'react' from being bundled for either all modules or a specific module, leveraging Liferay's OSGi runtime for provision. The `excludedPackages` property is a hypothetical common configuration option for such a plugin.

{ "*": { "plugins": [ "exclude-imports" ], "config": { "exclude-imports": { "excludedPackages": [ "some-common-utility", "@liferay/some-portal-api" ] } } }, "my-custom-module": { "plugins": [ "exclude-imports" ], "config": { "exclude-imports": { "excludedPackages": [ "react", "react-dom" ] } } } }
Debug
Known issues
breakingThe underlying liferay-npm-bundler, for which this is a plugin, has been officially deprecated as of Liferay 2024 Q4/Portal GA129. It is planned for future removal. This means the plugin will become obsolete with the bundler's deprecation and eventual removal.
fix
Migrate your Liferay frontend projects to use modern standard JavaScript bundlers like Esbuild, Webpack, or Vite. Consult Liferay's official migration guides for updated best practices on migrating away from the liferay-npm-bundler ecosystem.
affects: >=2.x
gotchaIncorrectly excluding a dependency that is not actually provided by the Liferay runtime or another OSGi module will lead to runtime errors (e.g., 'Module not found' or `undefined` references) in the browser. This plugin bypasses standard bundling, operating on the assumption that the excluded dependency is externally available.
fix
Thoroughly verify that any excluded dependency is indeed available at runtime via Liferay's module system. Use Liferay's module debug tools to inspect available modules. Avoid excluding critical application dependencies unless explicitly instructed or certain of their external provision by the Liferay platform or other OSGi bundles.
affects: >=1.0.0
gotchaThe liferay-npm-bundler's plugin loading mechanism can be sensitive to configuration. Ensure the plugin name ('exclude-imports') is correctly specified in your `.npmbundlerrc` file within the appropriate `plugins`, `pre-plugins`, or `post-plugins` section, and that any specific plugin options are correctly nested under a `config['exclude-imports']` object.
fix
Double-check `.npmbundlerrc` syntax and placement according to Liferay documentation for bundler plugins. If issues persist, enable `dump-report: true` in your `.npmbundlerrc` to generate a detailed HTML report for debugging the bundler's processing and plugin application.
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'some-dependency-name' in 'path/to/your/module'
A dependency was excluded by the liferay-npm-bundler-plugin-exclude-imports plugin but is not available at runtime in the Liferay DXP environment.
fix
Review your `.npmbundlerrc` configuration and ensure 'some-dependency-name' is either removed from the exclusion list, or confirm that it is correctly provided by another OSGi bundle or the Liferay runtime. Inspect the generated OSGi bundle to verify its contents.
LiferayNPMBundler: Plugin 'exclude-imports' not found or invalid.
The liferay-npm-bundler could not locate or correctly instantiate the plugin, often due to a typo in the plugin name within `.npmbundlerrc` or an installation issue.
fix
Verify that `liferay-npm-bundler-plugin-exclude-imports` is correctly installed in your project's `node_modules`. Check for typos in the plugin name `"exclude-imports"` within your `.npmbundlerrc` file under the `plugins` array. Ensure the `.npmbundlerrc` file is valid JSON and correctly placed.
Upgrade
Version history
2.32.2latest on npm
Audit
Dependencies
liferay-npm-bundlerrequiredThis package is a plugin specifically designed to extend the functionality of liferay-npm-bundler. It is a peer dependency.
Agent activity
8 hits · last 30 days
node
8
Resources
liferay-npm-bundler-plugin-exclude-imports — npm install liferay-npm-bundler-plugin-exclude-imports · libregistry