# babel-openui5-module-formatter

> This is a custom module formatter for the babel js transpiler. It transpiles ES6 modules to `sap.ui.define` calls (AMD-like syntax).

Latest version **0.0.1** (published 2015-04-06) · Apache 2.0 license · 0 weekly downloads

## Install

```sh
npm install babel-openui5-module-formatter
pnpm add babel-openui5-module-formatter
yarn add babel-openui5-module-formatter
bun add babel-openui5-module-formatter
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2015-04-06 |
| First published | 2015-04-06 |
| Weekly downloads | 0 |
| License | Apache 2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Christian Theilemann |
| Maintainers | geekflyer |
| Keywords | ui5, sapui5, openui5, babel, babeljs, es6 |

## Links

- npm: https://www.npmjs.com/package/babel-openui5-module-formatter
- npm.io page: https://npm.io/package/babel-openui5-module-formatter

## Dependencies (2)

- [ramda](https://npm.io/package/ramda.md) ^0.13.0
- [babel-core](https://npm.io/package/babel-core.md) ^5.0.6

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2015-04-06

## README

# babel-ui5-module-formatter [![Build Status](https://travis-ci.org/geekflyer/babel-ui5-module-formatter.svg?branch=master)](https://travis-ci.org/geekflyer/babel-ui5-module-formatter) [![npm version](https://badge.fury.io/js/babel-ui5-module-formatter.svg)](http://badge.fury.io/js/babel-ui5-module-formatter)

This is a custom module formatter for the babel js transpiler. It transpiles ES6 modules to `sap.ui.define` calls (AMD-like syntax).

## Install

```sh
$ npm install --save-dev babel-ui5-module-formatter
```

## Usage

Configure your babel transpiler to use a custom module formatter as described here: https://babeljs.io/docs/usage/modules/#custom and here https://babeljs.io/docs/usage/options/.

## Example

check this: https://github.com/geekflyer/babel-ui5-module-example

## Current Limitations

- The formatter transpiles your ES6 module code into `sap.ui.define` calls. Therefore generally speaking the same limitations as described here apply: https://openui5beta.hana.ondemand.com/#docs/api/symbols/sap.ui.html#.define . Noteworthy ones are:
	- Relative imports only work within the same or a subdirectory, but not a parent. E.g. `import foo from '../bla/bar'` won't work, while `import foo from './sub/bar'` works. You have to use absolute imports instead then, e.g. `import foo from 'mycompany/myapp/bla/bar'`. This problem might be solved by the formatter / transpiler in future, by statically resolving the module paths to absolute ones at transpile time.
	- In ES6 one can define *named exports* and *default* exports at the same time. However in AMD / sap.ui.define there's no equivalent. **Therefore you should have per module either only a *default export* or *named exports*.** If you violate this, the behaviour the transpiled module won't be as expected. For clarification refer to http://www.2ality.com/2014/09/es6-modules-final.html .
	- In ES6 syntax one can define global module / namespace mappings etc. via `System.map`. This doesn't work with the current transpiler and instead the global module mappings from UI5, e.g. `jQuery.sap.registerModulepath` and `data-sap-ui-resourceroots=` apply.
- Even though the formatter supports *named exports* it does not support *named imports* yet. Instead one on has to import the whole module via the wildcard syntax. This will be fixed soon in the formatter. 
For example: 

```js
// mymodule.js
// named exports
export var foo = () => 'bla';
export var bar = () => 'blub';
```
```js
// doesn't work at the moment:
import {foo} from './mymodule'
foo(); // ERROR
```
```js
// works:
import * as mymodule from './mymodule';
mymodule.foo();
```

## License

Apache 2.0 © [Christian Theilemann](https://github.com/geekflyer)

---
_Source: https://npm.io/package/babel-openui5-module-formatter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
