Middleware for ui5-server, doing on-the-fly transpilation of ES6+ sources to ES5 (incl IE11 compatability :) )
npm install ui5-middleware-livetranspile --save-dev-
debug: true|false
verbose logging -
excludePatterns:
String<Array>
array of paths inside$yourapp/webapp/to exclude from live transpilation,
e.g. 3-rd party libs inlib/*
- Define the dependency in
$yourapp/package.json:
"devDependencies": {
// ...
"ui5-middleware-livetranspile": "*"
// ...
},
"ui5": {
"dependencies": [
// ...
"ui5-middleware-livetranspile",
// ...
]
}As the devDependencies are not recognized by the UI5 tooling, they need to be listed in the
ui5 > dependenciesarray. In addition, once using theui5 > dependenciesarray you need to list all UI5 tooling relevant dependencies.
- configure it in
$yourapp/ui5.yaml:
server:
customMiddleware:
- name: ui5-middleware-livetranspile
afterMiddleware: compression
configuration:
debug: true
excludePatterns:
- "lib/"
- "another/dir/in/webapp"
- "yet/another/dir"The middleware intercepts every .js-file before it is sent to the client. The file is then transpiled on-the-fly via babel, including dynamic creation of a sourcemap.
The transpiled code and the sourcemap are subsequently delivered to the client instead of the original .js-file. Because of the sourcemap, setting breakpoints in the original (ES6+) source will cause the debugger to stop when the corresponding transpiled source code is reached.
async/awaitis transpiled at runtime, but the requiredasyncGeneratorsources are not yet delivered on the fly. They need to besap.ui.required or<script src="...">d separately.
.js-files requested by the server that are missing in the application (such as Component-preload.js) are logged as a WARN message, but will not cause the middleware to break/stop.
This work is dual-licensed under Apache 2.0 and the Derived Beer-ware License. The official license will be Apache 2.0 but finally you can choose between one of them if you use this work.
When you like this stuff, buy @vobu a beer or buy @pmuessig a coke when you see them.