babel-plugin-transform-modules-ui5
raw JSON → 7.8.1 verified Sat Apr 25 auth: no javascript
An unofficial Babel plugin for transforming ES6 modules to SAP UI5 module format. Version 7.8.1 is current, with a regular release cadence following UI5 conventions. Key differentiator: it enables using modern ES6 import/export syntax in SAP UI5 projects, converting them to UI5's define() calls. A preset is recommended over direct plugin use. Requires Node >=18 and @babel/core as a peer dependency.
Common errors
error Cannot find module '@babel/core' ↓
cause @babel/core is missing from node_modules.
fix
npm install @babel/core --save-dev
error Error: Plugin/Preset files are not allowed to export objects, only functions. ↓
cause Using CommonJS require instead of ESM import.
fix
Use import syntax in babel.config.js (ESM).
error TypeError: Cannot read properties of undefined (reading 'call') ↓
cause Incorrect Babel version or plugin not applied as a function.
fix
Ensure babel.config.js exports the plugin correctly as [plugin, options].
error Error: The preset 'babel-plugin-transform-modules-ui5/preset' is not found ↓
cause Preset path is incorrect or package not installed.
fix
Install the plugin package and use 'babel-plugin-transform-modules-ui5/preset' (case-sensitive).
Warnings
breaking Version 7.0.0 dropped support for Node < 10 and Babel 6. ↓
fix Upgrade to version 7.x and ensure Node >=10 (now >=18).
deprecated Direct use of the plugin is deprecated; the preset is recommended. ↓
fix Use babel-preset-transform-modules-ui5 instead.
breaking Version 7.8.0 requires Node >=18, breaking older Node versions. ↓
fix Update Node to >=18 or stay on older plugin version.
gotcha The plugin must be used with @babel/core as a peer dependency; missing it causes runtime errors. ↓
fix Install @babel/core as a devDependency.
gotcha Import paths in UI5 modules are case-sensitive and must match module names exactly; the plugin does not normalize paths. ↓
fix Ensure import paths match the UI5 module IDs.
Install
npm install babel-plugin-transform-modules-ui5 yarn add babel-plugin-transform-modules-ui5 pnpm add babel-plugin-transform-modules-ui5 Imports
- default wrong
const plugin = require('babel-plugin-transform-modules-ui5')correctimport plugin from 'babel-plugin-transform-modules-ui5' - transformModulesUI5 wrong
import transformModulesUI5 from 'babel-plugin-transform-modules-ui5'correctimport { transformModulesUI5 } from 'babel-plugin-transform-modules-ui5' - preset wrong
import preset from 'babel-plugin-transform-modules-ui5'correctimport preset from 'babel-plugin-transform-modules-ui5/preset'
Quickstart
// babel.config.js
import plugin from 'babel-plugin-transform-modules-ui5';
export default {
plugins: [
[plugin, {
// options
}]
]
};