{"id":13453,"library":"liferay-npm-bundler-preset-amd","title":"Liferay NPM Bundler AMD Preset","description":"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.","status":"active","version":"1.8.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install liferay-npm-bundler-preset-amd","lang":"bash","label":"npm"},{"cmd":"yarn add liferay-npm-bundler-preset-amd","lang":"bash","label":"yarn"},{"cmd":"pnpm add liferay-npm-bundler-preset-amd","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is a configuration preset for liferay-npm-bundler and requires it to be installed in the project for bundling operations.","package":"liferay-npm-bundler","optional":false}],"imports":[{"note":"The preset is applied by specifying its package name as a string value for the 'preset' field in your project's .npmbundlerrc configuration file. This is the primary method of 'importing' this preset.","symbol":"preset","correct":"{\n    \"preset\": \"liferay-npm-bundler-preset-amd\"\n}"},{"note":"This package exports a configuration preset for a build tool, not a JavaScript module for direct programmatic import via ES Module syntax in application code. Attempting to import it directly will result in runtime errors or an empty module.","wrong":"import LiferayAmdPreset from 'liferay-npm-bundler-preset-amd';","symbol":"LiferayAmdPresetESM"},{"note":"Similar to ESM imports, this package is not designed for direct CommonJS require statements. It is purely a declarative configuration for the liferay-npm-bundler tool and does not expose a programmatic API.","wrong":"const LiferayAmdPreset = require('liferay-npm-bundler-preset-amd');","symbol":"liferayAmdPresetCJS"}],"quickstart":{"code":"// .npmbundlerrc\n{\n    \"preset\": \"liferay-npm-bundler-preset-amd\"\n}","lang":"json","description":"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."},"warnings":[{"fix":"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.","message":"Major version updates to the core `liferay-npm-bundler` package can introduce breaking changes that might require an update or specific version constraints for this preset to function correctly.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Monitor the changelog for `babel-preset-liferay-amd` and related Babel packages. Test builds thoroughly after any `npm update` or `yarn upgrade`.","message":"Changes in the underlying Babel presets, specifically `babel-preset-liferay-amd`, which this preset relies on, can lead to unexpected build failures or altered module transformations.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure that your `.npmbundlerrc` and `babel.config.js` files do not have conflicting rules. Consider using explicit `extends` or `overrides` if combining configurations.","message":"This preset might conflict with other custom Babel configurations or additional `liferay-npm-bundler` plugins if not carefully managed, potentially leading to incorrect module transformations or build errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"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.","message":"Incorrect module resolution for specific AMD modules, especially those with non-standard paths or complex dependency trees, can occur if not explicitly handled by the preset or custom bundler configuration.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"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.","message":"The extensive transformations required for AMD modules can lead to increased build times, particularly in large projects with many dependencies.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"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'.","cause":"The `liferay-npm-bundler-preset-amd` package was not installed or is misspelled in `.npmbundlerrc`.","error":"Error: Preset \"liferay-npm-bundler-preset-amd\" not found"},{"fix":"Modify `.npmbundlerrc` to set `\"preset\": \"liferay-npm-bundler-preset-amd\"` as a direct string value.","cause":"The `preset` value in `.npmbundlerrc` is not a simple string, but an object or array.","error":"ERROR in ./.npmbundlerrc Configuration validation error: \"preset\" must be a string"},{"fix":"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.","cause":"The bundler could not locate an AMD module required by your project, often due to incorrect paths or missing `baseUrl` configuration.","error":"ModuleNotFoundError: Module not found: Error: Can't resolve 'some-amd-module' in '/path/to/project'"},{"fix":"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.","cause":"A module is being treated as CommonJS by Babel despite containing ES Module syntax, indicating a misconfiguration in Babel or the preset.","error":"SyntaxError: 'import' and 'export' may only appear with 'sourceType: module'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}