
Product
Reachability for Ruby Now in Beta
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.
babel-plugin-transform-modules-ui5
Advanced tools
An unofficial experimental Babel transformer plugin for SAP UI5.
It allows you to develop SAP UI5 applications by using the latest ES2015, including classes and modules.
sergiirocks babel-plugin-transform-ui5 is a great choice if you use webpack. It allows you to configure which import paths to convert to sap.ui.define syntax and leaves the rest as ES2015 import statements, which allows webpack to load them in.
MagicCube's babel-plugin-ui5-example
super keywordmetadata fieldconstructor shorthand methodconstructor shorthand will still get fixedThis does transforms only the UI5 relevant things. It does not transform everything to ES5 (for example it does not transform const/let to var). This makes it easier to use babel-preset-env to determine how to transform everything else.
return statement to the end of the sap.ui.define block.
export default statement.MyError.js example).
extend(...) (See Cat.js example)npm install --save-dev git+https://git@github.com/r-murphy/babel-plugin-ui5.git
or
yarn add --dev git+https://git@github.com/r-murphy/babel-plugin-ui5.git
At a minimum, add ui5 to the plugins.
{
"plugins": ["ui5"]
}
Optionally, you can use decorators to override the namespace or name used when calling .extend(name, {...}). To do so, you will also need the plugin babel-plugin-syntax-decorators.
At the time of writing, the babel version is 6.26.0, which does not support class property syntax. To use that syntax also add the plugin babel-plugin-syntax-class-properties.
It is also recommended to use babel-preset-env to control which ES version the the final code is transformed to.
Please take a look at ui5-loader.
UI5 supports Modularization through a mechanism called preload, which can compile many JavaScript and xml files into just one preload file.
Some preload plugins:
/*---------------------------------*
* File: src/example/obj/Animal.js *
*---------------------------------*/
import ManagedObject from "sap/ui/base/ManagedObject";
export default class Animal extends ManagedObject {
metadata: {
properties: {
type: { type: "string" },
nickName: { type: "string" }
}
}
constructor(...args) {
super(...args);
// TODO: Add your own construction code here.
}
init() {
super.init();
// TODO: Add your own initialization code here.
}
callMe() {
alert(`I'm a ${this.getType()}.
Call me ${this.getNickName()}.`);
}
}
/*---------------------------------*
* File: src/example/obj/Cat.js *
*---------------------------------*/
import Animal from "./Animal";
@name("othernamespace.Cat")
export default class Cat extends Animal {
init() {
super.init();
this.setType("Cat");
}
callMe() {
super.callMe();
alert("Miao~");
}
static createCat(nickName) {
const cat = new example.obj.Cat({
nickName
});
return cat;
}
}
/*-----------------------------------*
* File: src/example/util/MyError.js *
*-----------------------------------*/
export default class MyError extends Error {
constructor(msg) {
super(msg);
this.name = 'MyError'
}
}
/*------------------------------------*
* File: assets/example/obj/Animal.js *
*------------------------------------*/
sap.ui.define(["sap/ui/base/ManagedObject"], function (ManagedObject) {
"use strict";
return ManagedObject.extend("example.obj.Animal", {
metadata: {
properties: {
type: { type: "string" },
nickName: { type: "string" }
}
},
constructor: function constructor() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
ManagedObject.apply(this, [].concat(args));
// TODO: Add your own construction code here.
},
init: function init() {
// TODO: Add your own initialization code here.
},
callMe: function callMe() {
alert("I'm a " + this.getType() + ". Call me " + this.getNickName() + ".");
}
});
});
/*---------------------------------*
* File: assets/example/obj/Cat.js *
*---------------------------------*/
sap.ui.define(["./Animal"], function (Animal) {
const Cat = Animal.extend("othernamespace.Cat", {
init: function init() {
Animal.prototype.init.apply(this, []);
this.setType("Cat");
},
callMe: function callMe() {
Animal.prototype.callMe.apply(this, []);
alert("Miao~");
}
});
Cat.createCat = function (nickName) {
const cat = new example.obj.Cat({
nickName
});
return cat;
};
});
/*--------------------------------------*
* File: assets/example/util/MyError.js *
*--------------------------------------*/
sap.ui.define([], function () {
class MyError extends Error {
constructor(msg) {
super(msg);
this.name = 'MyError'
}
}
return MyError
});
FAQs
An unofficial babel plugin for SAP UI5.
The npm package babel-plugin-transform-modules-ui5 receives a total of 40,456 weekly downloads. As such, babel-plugin-transform-modules-ui5 popularity was classified as popular.
We found that babel-plugin-transform-modules-ui5 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.

Research
/Security News
Malicious npm packages use Adspect cloaking and fake CAPTCHAs to fingerprint visitors and redirect victims to crypto-themed scam sites.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.