Registry / devops / liferay-npm-bundler-plugin-namespace-packages

liferay-npm-bundler-plugin-namespace-packages

JSON →
library2.32.2jsnpmunverified

This plugin for `liferay-npm-bundler` modifies `package.json` files during the bundling process to prefix package names with the root project's name. This mechanism creates isolated dependency graphs for individual Liferay projects, effectively preventing dependency conflicts and ensuring predictable runtime behavior, particularly crucial when dealing with peer dependencies. It specifically targets package name entries and handles scoped packages by prepending the project's name to the scope (e.g., `@a-scope/a-package` becomes `@my-project$a-scope/a-package`). Introduced with `liferay-npm-bundler` 2.x to enable isolated dependencies, it addresses scenarios where package names need to be unique per bundle. The current stable version is 2.32.2. However, it is critical to note that its core dependency, `liferay-npm-bundler`, has been deprecated as of Liferay 2024.Q4/Portal GA129 and is slated for future removal, as Liferay shifts towards standard JavaScript tooling like esbuild, webpack, or vite. While still functional for existing Liferay DXP setups, its long-term relevance is diminishing. Its primary differentiator is providing project-level dependency sandboxing within the Liferay ecosystem, prioritizing stability and predictability over cross-project dependency deduplication.

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

"namespace-packages"
{ "*": { "plugins": ["namespace-packages"] } }
import { namespacePackages } from 'liferay-npm-bundler-plugin-namespace-packages'
This plugin is configured as a string literal within the `plugins` array of a `.npmbundlerrc` configuration file, typically at the root level (`"*"`) to apply to all modules. It is not imported as a JavaScript or TypeScript module.

Demonstrates how to install the `liferay-npm-bundler-plugin-namespace-packages` via npm and configure it within the `.npmbundlerrc` file to enable project-level package namespacing for the Liferay npm bundler.

npm install --save-dev liferay-npm-bundler-plugin-namespace-packages // Add the following to your .npmbundlerrc file in the project root // This enables the plugin for all modules within the bundler process. // Make sure to also configure babel-plugin-namespace-modules for full effect. { "*": { "plugins": ["namespace-packages"] } }
Debug
Known issues
deprecatedThe underlying `liferay-npm-bundler` tool, which this plugin extends, has been deprecated as of Liferay DXP 2024.Q4/Portal GA129 and is planned for future removal. Liferay recommends migrating to standard JavaScript tooling like esbuild, webpack, or vite.
fix
Plan to migrate your Liferay frontend projects away from `liferay-npm-bundler` and its plugins to modern JavaScript bundlers. Consult Liferay's official documentation for migration guides.
affects: >=2.0.0
breakingMajor version updates of `liferay-npm-bundler` may introduce breaking changes to its plugin API, potentially requiring an update to this plugin for compatibility.
fix
Consult the changelogs for both `liferay-npm-bundler` and this plugin. Update to compatible versions as recommended by Liferay documentation.
affects: >=2.0.0
gotchaThis plugin intentionally disables cross-project package deduplication to ensure dependency isolation and stability. This can lead to increased bundle sizes.
fix
Understand that this is a design choice for stability. Profile your bundle if size is a critical concern, but generally accept this trade-off for Liferay projects requiring strict dependency isolation.
affects: *
gotchaFor complete module sandboxing, this plugin should be used in conjunction with `babel-plugin-namespace-modules`. Without its Babel counterpart, only `package.json` entries are namespaced, not actual `define()` or `require()` calls within the JavaScript code.
fix
Ensure `babel-plugin-namespace-modules` is correctly configured in your Babel pipeline when using this bundler plugin to achieve full module isolation.
affects: *
gotchaSome documentation or examples might incorrectly reference a different plugin during installation (e.g., `liferay-npm-bundler-plugin-inject-angular-dependencies`).
fix
Always verify the package name. The correct installation command is `npm install --save-dev liferay-npm-bundler-plugin-namespace-packages`.
affects: *
Errors
Common errors & fixes
ModuleNotFoundError: Cannot find module 'my-scoped-package' after namespacing plugin enabled.
The `babel-plugin-namespace-modules` is not configured, meaning module `import`/`require` statements are not rewritten to match the namespaced package names.
fix
Install and configure `babel-plugin-namespace-modules` in your Babel configuration to ensure module identifiers within code are also namespaced.
Bundled output size significantly larger than expected after enabling namespacing.
The `liferay-npm-bundler-plugin-namespace-packages` intentionally prevents package deduplication across different projects to ensure strict isolation, leading to larger bundle sizes.
fix
This is expected behavior and a trade-off for increased stability and predictability in Liferay environments. Evaluate if the isolation benefits justify the increased bundle size for your use case.
Plugin does not seem to be applied, package names in output bundles are not modified.
The plugin is either not correctly specified in the `.npmbundlerrc` file's `plugins` array, or the `liferay-npm-bundler` itself is not executing with the correct configuration.
fix
Double-check that your `.npmbundlerrc` file contains `"plugins": ["namespace-packages"]` under the appropriate configuration scope (e.g., `"*"`). Verify that your build process correctly invokes `liferay-npm-bundler` with this configuration.
Upgrade
Version history
2.32.2latest on npm
Audit
Dependencies
liferay-npm-bundlerrequiredThis plugin extends `liferay-npm-bundler` and requires it to function. Note that `liferay-npm-bundler` is deprecated.
babel-plugin-namespace-modulesoptionalStrongly recommended as a counterpart plugin to fully namespace module `define()` and `require()` calls within JavaScript files, complementing this plugin's `package.json` modification.
Agent activity
2 hits · last 30 days
node
2
Resources