A Babel plugin that rewrites aliased require() calls based on fields in package.json, such as the 'browser' field. Version 2.32.2 is current, maintained as part of the Liferay npm bundler toolkit. It enables module aliasing like webpack's resolve.aliasFields, scanning package.json for alias fields and redirecting require() calls. It only handles the local redirection part; external aliasing is handled by a companion plugin. Useful for isomorphic packages and browser polyfills.
npm install babel-plugin-alias-modulesVerified import paths — ran on the pinned version, not inferred.
Basic Babel plugin configuration to alias modules using the 'browser' field from package.json.
Explicitly set resolve.aliasFields to include 'unpkg' or 'jsdelivr' if needed.
Move configuration from .npmbundlerrc to Babel plugin options.
Include the companion plugin for full alias functionality.
Run npm install babel-plugin-alias-modules --save-dev
Use require('babel-plugin-alias-modules') (CommonJS) or default import.