The `liferay-npm-bundler-preset-amd` package provides a specialized configuration preset for the `liferay-npm-bundler`, a tool integral to developing modules for Liferay DXP. Its core function is to facilitate the bundling of projects that rely on AMD (Asynchronous Module Definition) structured npm modules, making them compatible with the Liferay portal environment. Currently stable at version 1.8.0, this preset streamlines the build process by embedding the necessary Babel transformations, notably `babel-preset-liferay-amd`, which handles AMD-specific syntax and dependencies. While a strict release cadence isn't published, updates typically align with major `liferay-npm-bundler` or Liferay DXP platform releases, ensuring ongoing compatibility. A key differentiator is its deep integration with the Liferay ecosystem, providing an opinionated and optimized approach for handling legacy or specifically designed AMD modules within modern Liferay development workflows, avoiding manual configuration of complex Babel and Webpack rules for AMD support.
npm install liferay-npm-bundler-preset-amdVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to activate the AMD preset for the `liferay-npm-bundler` by modifying the project's `.npmbundlerrc` configuration file. This file must be located at the root of your project.
Always consult the `liferay-npm-bundler` release notes for compatibility when upgrading. Pin exact versions of bundler and preset in package.json to avoid unexpected updates.
Monitor the changelog for `babel-preset-liferay-amd` and related Babel packages. Test builds thoroughly after any `npm update` or `yarn upgrade`.
Ensure that your `.npmbundlerrc` and `babel.config.js` files do not have conflicting rules. Consider using explicit `extends` or `overrides` if combining configurations.
For problematic modules, check `liferay-npm-bundler` documentation for path aliases or custom resolver configurations. Verify the `baseUrl` and `paths` settings if applicable within your project.
Analyze build performance using bundler statistics. Consider optimizing the project's module structure or gradually migrating away from AMD if feasible for critical performance paths.
Ensure `npm install --save-dev liferay-npm-bundler-preset-amd` has been run and the package name in `.npmbundlerrc` is exactly 'liferay-npm-bundler-preset-amd'.
Modify `.npmbundlerrc` to set `"preset": "liferay-npm-bundler-preset-amd"` as a direct string value.
Verify that 'some-amd-module' is correctly installed and accessible. Check for any custom `baseUrl` or `paths` settings in your `.npmbundlerrc` or `webpack.config.js` if you are using custom module resolution.
Ensure that your Babel configuration (or the preset's internal Babel configuration) correctly identifies the `sourceType` for your modules. This might involve checking the `babel-preset-liferay-amd` or adding a specific Babel plugin.