{"id":19308,"library":"babel-preset-liferay-standard","title":"babel-preset-liferay-standard","description":"A Babel preset for bundling standard (browser-compatible) npm modules in Liferay projects. Current stable version is 2.32.2. It is maintained as part of the Liferay frontend projects monorepo, with releases tied to the liferay-js-toolkit package. The preset includes plugins for normalizing requires, inlining NODE_ENV, dead code elimination, AMD module wrapping, naming, and namespace handling. It differentiates from generic Babel presets by providing Liferay-specific transformations for AMD module support and namespace isolation.","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-preset-liferay-standard","lang":"bash","label":"npm"},{"cmd":"yarn add babel-preset-liferay-standard","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-preset-liferay-standard","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"normalizes require paths","package":"babel-plugin-normalize-requires","optional":false},{"reason":"inlines NODE_ENV checks","package":"babel-plugin-transform-node-env-inline","optional":false},{"reason":"removes dead code","package":"babel-plugin-minify-dead-code-elimination","optional":false},{"reason":"wraps modules in AMD define","package":"babel-plugin-wrap-modules-amd","optional":false},{"reason":"names AMD modules","package":"babel-plugin-name-amd-modules","optional":false},{"reason":"namespaces modules","package":"babel-plugin-namespace-modules","optional":false},{"reason":"namespaces AMD define calls","package":"babel-plugin-namespace-amd-define","optional":false}],"imports":[{"note":"ESM default import is preferred; CommonJS require works but may not tree-shake.","wrong":"const babelPresetLiferayStandard = require('babel-preset-liferay-standard')","symbol":"default","correct":"import babelPresetLiferayStandard from 'babel-preset-liferay-standard'"},{"note":"Named export is lowercase camelCase.","wrong":"import { LiferayStandard } from 'babel-preset-liferay-standard'","symbol":"liferayStandard","correct":"import { liferayStandard } from 'babel-preset-liferay-standard'"},{"note":"Use type import for TypeScript type definitions.","wrong":"import { Config } from 'babel-preset-liferay-standard'","symbol":"Config","correct":"import type { Config } from 'babel-preset-liferay-standard'"}],"quickstart":{"code":"// Install: npm install --save-dev babel-preset-liferay-standard\n\n// .babelrc\n{\n  \"presets\": [\"liferay-standard\"]\n}\n\n// babel.config.js\nmodule.exports = {\n  presets: ['babel-preset-liferay-standard']\n};\n\n// package.json\n{\n  \"babel\": {\n    \"presets\": [\"liferay-standard\"]\n  }\n}","lang":"javascript","description":"Demonstrates three ways to configure babel-preset-liferay-standard: .babelrc file, babel.config.js, and package.json babel field."},"warnings":[{"fix":"Upgrade to Babel 7 or use babel-preset-liferay-standard@1.x.","message":"In version 2.x, the preset requires Babel 7. Using with Babel 6 will throw errors.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Manually replace with the standalone plugin if needed.","message":"babel-plugin-transform-node-env-inline may be deprecated in future releases; prefer using @babel/plugin-transform-node-env-inline.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Set NODE_ENV=production for production builds or use cross-env.","message":"The preset includes dead code elimination; ensure that process.env.NODE_ENV is set correctly to avoid accidental removal of development code.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use the preset only in Liferay AMD environments or disable AMD plugins if not needed.","message":"AMD module wrapping can cause conflicts with other module systems (e.g., CommonJS). Ensure your project is AMD-compatible.","severity":"gotcha","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":"Run: npm install --save-dev babel-preset-liferay-standard","cause":"Package not installed or missing from devDependencies.","error":"Error: Cannot find module 'babel-preset-liferay-standard'"},{"fix":"Ensure an AMD loader (like RequireJS) is included or use the preset with a bundler that supports AMD output.","cause":"AMD module wrapping expects an AMD loader (e.g., RequireJS) to be present in the browser.","error":"ReferenceError: define is not defined"},{"fix":"Export an object with a presets array: module.exports = { presets: ['liferay-standard'] };","cause":"Babel configuration file is malformed or missing module.exports.","error":"TypeError: Cannot read property 'presets' of undefined"},{"fix":"Upgrade to Babel 7 or ensure all peer dependencies match.","cause":"Incompatible Babel plugin version (e.g., Babel 6 plugin in Babel 7).","error":"Error: Plugin 2 specified in \".../node_modules/babel-preset-liferay-standard/index.js\" returned an object with a \"visitor\" property, but Babel expects a function.","affected_versions":">=2.0.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}