Registry / devops / babel-plugin-normalize-requires

babel-plugin-normalize-requires

JSON →
library2.32.2jsnpmunverified

A Babel plugin that normalizes AMD require() calls by removing file extensions (e.g., .js) and trailing slashes from module paths. Version 2.32.2 is current; part of the Liferay Frontend Projects monorepo. It is designed for Liferay's AMD module system and does not handle CommonJS or ES module imports. Key differentiator: it preserves npm package names that contain .js (e.g., a package named 'foo.js') while normalizing module paths. Release cadence is irregular, tied to Liferay SDK updates.

npm install babel-plugin-normalize-requires
INSTALL
IMPORT
SIG · BABEL-PLUGIN-NORMA
B
babel-plugin-normalize-requires
devopsjavascriptv2.32.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
module.exports = require('babel-plugin-normalize-requires')
import plugin from 'babel-plugin-normalize-requires'
CJS-only; no ESM export. Use require() in .babelrc or programmatic Babel config.
babel plugin config
plugins: ['normalize-requires']
plugins: [['babel-plugin-normalize-requires', {}]]
In .babelrc, use shorthand name 'normalize-requires' (no options). Options object is currently unused.
programmatic usage
const normalizeRequires = require('babel-plugin-normalize-requires'); babel.transform(code, { plugins: [normalizeRequires] })
const { normalizeRequires } = require('babel-plugin-normalize-requires')
Default export is the plugin function; no named exports.

Configures Babel to strip .js suffixes and trailing slashes from AMD require() calls.

// .babelrc { "plugins": ["normalize-requires"] } // Input: require('./a-module.js'); // Output: require('./a-module');
Debug
Known issues
breakingPlugin only processes AMD define()/require() calls, not CommonJS require() or ES import statements.
fix
Use with Babel preset-env or other plugins if targeting CJS/ESM: the plugin will silently skip non-AMD calls.
affects: all
gotchaThe plugin does not handle dynamic require() calls (e.g., require(variable)).
fix
Ensure require() arguments are string literals for normalization to occur.
affects: all
deprecatedPackage may not be actively maintained as part of Liferay Frontend Projects; no recent releases for this package specifically.
fix
Consider forking or migrating to alternative module normalization tools if updates are needed.
affects: >=2.0.0
Errors
Common errors & fixes
require('./a-module.js') not normalized
The require() call is inside a non-AMD context or the plugin is not configured correctly.
fix
Ensure Babel is configured with the plugin in .babelrc and that the code is processed by Babel (check for exclude/include patterns).
Error: Cannot find module 'babel-plugin-normalize-requires'
Package not installed or missing from node_modules.
fix
Run 'npm install --save-dev babel-plugin-normalize-requires' and verify package.json.
Upgrade
Version history
2.32.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
babel-plugin-normalize-requires — npm install babel-plugin-normalize-requires · libregistry