ui5-community / babel-plugin-transform-modules-ui5

A Babel transformer plugin for OpenUI5/SAPUI5. It allows you to develop UI5 applications by using the latest ECMAScript or TypeScript, including new syntax and objective oriented programming technology.
MIT License
34 stars 16 forks source link

fix: catch err for dynamic import to sap.ui.require #91

Closed petermuessig closed 1 year ago

petermuessig commented 1 year ago

To avoid an uncaught exception when rewriting dynamic imports and catching errors, the error handler for the sap.ui.require needs to be passed and finally reject the Promise. This will make the following code working:

import("luxon").then(({ Info }) => {
  console.log(`Luxon loaded: ${Info.toString()}`);
}).catch((ex) => {
  console.log("Failed to load luxon!");
});