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-packagesVerified import paths — ran on the pinned version, not inferred.
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.
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.
Consult the changelogs for both `liferay-npm-bundler` and this plugin. Update to compatible versions as recommended by Liferay documentation.
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.
Ensure `babel-plugin-namespace-modules` is correctly configured in your Babel pipeline when using this bundler plugin to achieve full module isolation.
Always verify the package name. The correct installation command is `npm install --save-dev liferay-npm-bundler-plugin-namespace-packages`.
Install and configure `babel-plugin-namespace-modules` in your Babel configuration to ensure module identifiers within code are also namespaced.
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.
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.