Liferay NPM Bundler Plugin: Exclude Imports

2.32.2 · deprecated · verified Tue Apr 21

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.

Common errors

Warnings

Install

Imports

Quickstart

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"
        ]
      }
    }
  }
}

view raw JSON →