{"id":19114,"library":"babel-plugin-normalize-requires","title":"babel-plugin-normalize-requires","description":"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.","status":"active","version":"2.32.2","language":"javascript","source_language":"en","source_url":"https://github.com/liferay/liferay-frontend-projects","tags":["javascript"],"install":[{"cmd":"npm install babel-plugin-normalize-requires","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-normalize-requires","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-normalize-requires","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CJS-only; no ESM export. Use require() in .babelrc or programmatic Babel config.","wrong":"import plugin from 'babel-plugin-normalize-requires'","symbol":"default","correct":"module.exports = require('babel-plugin-normalize-requires')"},{"note":"In .babelrc, use shorthand name 'normalize-requires' (no options). Options object is currently unused.","wrong":"plugins: [['babel-plugin-normalize-requires', {}]]","symbol":"babel plugin config","correct":"plugins: ['normalize-requires']"},{"note":"Default export is the plugin function; no named exports.","wrong":"const { normalizeRequires } = require('babel-plugin-normalize-requires')","symbol":"programmatic usage","correct":"const normalizeRequires = require('babel-plugin-normalize-requires');\nbabel.transform(code, { plugins: [normalizeRequires] })"}],"quickstart":{"code":"// .babelrc\n{\n  \"plugins\": [\"normalize-requires\"]\n}\n\n// Input: require('./a-module.js');\n// Output: require('./a-module');","lang":"javascript","description":"Configures Babel to strip .js suffixes and trailing slashes from AMD require() calls."},"warnings":[{"fix":"Use with Babel preset-env or other plugins if targeting CJS/ESM: the plugin will silently skip non-AMD calls.","message":"Plugin only processes AMD define()/require() calls, not CommonJS require() or ES import statements.","severity":"breaking","affected_versions":"all"},{"fix":"Ensure require() arguments are string literals for normalization to occur.","message":"The plugin does not handle dynamic require() calls (e.g., require(variable)).","severity":"gotcha","affected_versions":"all"},{"fix":"Consider forking or migrating to alternative module normalization tools if updates are needed.","message":"Package may not be actively maintained as part of Liferay Frontend Projects; no recent releases for this package specifically.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure Babel is configured with the plugin in .babelrc and that the code is processed by Babel (check for exclude/include patterns).","cause":"The require() call is inside a non-AMD context or the plugin is not configured correctly.","error":"require('./a-module.js') not normalized"},{"fix":"Run 'npm install --save-dev babel-plugin-normalize-requires' and verify package.json.","cause":"Package not installed or missing from node_modules.","error":"Error: Cannot find module 'babel-plugin-normalize-requires'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}