Given an ES Module dictionaryAPI.mjs
:
export const DICTIONARY_API = Object.freeze({
someKey: "someValue"
});
I want to import it to my UI5 controller. As far, as I understand, UI5 doesn't support .mjs
extensions, therefore I've changed an extension from .mjs
to .js
. Then, I try to add it into the UI5 controller, precisely, to the utility controller ControllerUtilities.js
:
sap.ui.define([
"com/myApp/dictionaryAPI"
],
(dictionaryAPI) => ({…}));
When I run the app, I get an error:
'com/myApp/controller/ControllerUtilities.js': Unexpected token 'export'
sap-ui-core.js:53 Uncaught (in promise) ModuleError: Failed to resolve dependencies of 'com/myApp/controller/Login.controller.js'
-> 'com/myApp/controller/BaseController.js'
-> 'com/myApp/controller/ControllerUtilities.js': Unexpected token 'export'
at p1 (https://openui5nightly.hana.ondemand.com/resources/sap-ui-core.js:53:213)
at j1.failWith (https://openui5nightly.hana.ondemand.com/resources/sap-ui-core.js:40:43)
at https://openui5nightly.hana.ondemand.com/resources/sap-ui-core.js:65:1556
Caused by: SyntaxError: Unexpected token 'export'
It looks like, UI5 doesn't recognize the export
statemen from the ES Module.
Is there any option to import ES Module into UI5 controller?
Used version: OpenUI5 1.96.0