Skip to content

Commit

Permalink
[BREAKING] Transform to native ESM (#790)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
This package has been transformed to native ESM. Therefore it no longer provides a CommonJS export.
If your project uses CommonJS, it needs to be converted to ESM or use a dynamic import.

For more information see also:
- https://sap.github.io/ui5-tooling/updates/migrate-v3/
- https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c


Co-authored-by: Florian Vogt <florian.vogt@sap.com>
Co-authored-by: Matthias Osswald <mat.osswald@sap.com>
  • Loading branch information
3 people authored Oct 24, 2022
1 parent 5fef03d commit a439aa9
Show file tree
Hide file tree
Showing 155 changed files with 3,825 additions and 4,664 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
"parserOptions": {
"sourceType": "module",
},
"env": {
"node": true,
"es2021": true
Expand Down Expand Up @@ -73,7 +76,8 @@ module.exports = {
"settings": {
"jsdoc": {
"tagNamePreference": {
"return": "returns"
"return": "returns",
"augments": "extends"
}
}
},
Expand Down
173 changes: 0 additions & 173 deletions index.js

This file was deleted.

9 changes: 9 additions & 0 deletions jsdoc-plugin.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* This plugin fixes unexpected JSDoc behavior that prevents us from using types that start with an at-sign (@).
* JSDoc doesn't see "{@" as a valid type expression, probably as there's also {@link ...}.
*/
exports.handlers = {
jsdocCommentFound: function(e) {
e.comment = e.comment.replace(/{@ui5\//g, "{ @ui5/");
}
};
13 changes: 0 additions & 13 deletions jsdoc-plugin.js

This file was deleted.

4 changes: 2 additions & 2 deletions jsdoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"allowUnknownTags": false
},
"source": {
"include": ["README.md", "index.js"],
"include": ["README.md"],
"exclude": ["lib/lbt/utils/JSTokenizer.js"],
"includePattern": ".+\\.js$",
"excludePattern": "(node_modules(\\\\|/))"
},
"plugins": [
"./jsdoc-plugin"
"./jsdoc-plugin.cjs"
],
"opts": {
"encoding": "utf8",
Expand Down
15 changes: 7 additions & 8 deletions lib/lbt/UI5ClientConstants.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"use strict";

module.exports.MODULE__UI5LOADER = "ui5loader.js";
module.exports.MODULE__UI5LOADER_AUTOCONFIG = "ui5loader-autoconfig.js";
module.exports.MODULE__JQUERY_SAP_GLOBAL = "jquery.sap.global.js";
module.exports.MODULE__SAP_UI_CORE_CORE = "sap/ui/core/Core.js";
module.exports.EVO_MARKER_RESOURCE = module.exports.MODULE__UI5LOADER;
export const MODULE__UI5LOADER = "ui5loader.js";
export const MODULE__UI5LOADER_AUTOCONFIG = "ui5loader-autoconfig.js";
export const MODULE__JQUERY_SAP_GLOBAL = "jquery.sap.global.js";
export const MODULE__SAP_UI_CORE_CORE = "sap/ui/core/Core.js";
export const EVO_MARKER_RESOURCE = MODULE__UI5LOADER;

module.exports.getRendererName = function( module ) {
export function getRendererName( module ) {
if ( /\.js$/.test(module) ) {
return module.replace(/\.js$/, "Renderer.js");
}
};
}
20 changes: 10 additions & 10 deletions lib/lbt/analyzer/ComponentAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
* This class can handle multiple concurrent analysis calls, it has no instance state
* other than the pool (which is readonly).
*/
"use strict";

const ModuleName = require("../utils/ModuleName");
const log = require("@ui5/logger").getLogger("lbt:analyzer:ComponentAnalyzer");
import {fromUI5LegacyName} from "../utils/ModuleName.js";
import logger from "@ui5/logger";
const log = logger.getLogger("lbt:analyzer:ComponentAnalyzer");

// ---------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -97,21 +97,21 @@ class ComponentAnalyzer {
} else {
rootView = ui5.rootView;
}
const module = ModuleName.fromUI5LegacyName(
const module = fromUI5LegacyName(
rootView.viewName,
".view." + rootView.type.toLowerCase() );
log.verbose("adding root view dependency ", module);
info.addDependency( module );
}

each( ui5.dependencies && ui5.dependencies.libs, (options, lib) => {
const module = ModuleName.fromUI5LegacyName(lib, "/library.js");
const module = fromUI5LegacyName(lib, "/library.js");
log.verbose("adding library dependency ", module, options.lazy || false);
info.addDependency( module, options.lazy ); // lazy -> conditional dependency
});

each( ui5.dependencies && ui5.dependencies.components, (options, component) => {
const module = ModuleName.fromUI5LegacyName(component, "/Component.js");
const module = fromUI5LegacyName(component, "/Component.js");
log.verbose("adding component dependency ", module, options.lazy || false);
info.addDependency( module, options.lazy ); // lazy -> conditional dependency
});
Expand Down Expand Up @@ -163,7 +163,7 @@ class ComponentAnalyzer {
log.warn(`Neither a type nor a dataSource has been defined for model "${model}".`);
return;
}
const module = ModuleName.fromUI5LegacyName( modelType );
const module = fromUI5LegacyName( modelType );
log.verbose("derived model implementation dependency ", module);
info.addDependency(module);
});
Expand All @@ -175,7 +175,7 @@ class ComponentAnalyzer {
// See sap/ui/core/UIComponent#init
if (routing.routes) {
const routerClassName = routingConfig.routerClass || "sap.ui.core.routing.Router";
const routerClassModule = ModuleName.fromUI5LegacyName(routerClassName);
const routerClassModule = fromUI5LegacyName(routerClassName);
log.verbose(`adding router dependency '${routerClassModule}'`);
info.addDependency(routerClassModule);
} else if (routing.targets) {
Expand All @@ -194,7 +194,7 @@ class ComponentAnalyzer {
if (target && target.viewName) {
// merge target config with default config
const config = Object.assign({}, routing.config, target);
const module = ModuleName.fromUI5LegacyName(
const module = fromUI5LegacyName(
(config.viewPath ? config.viewPath + "." : "") +
config.viewName, ".view." + config.viewType.toLowerCase() );
log.verbose("converting routing target '%s' to view dependency '%s'", targetName, module);
Expand All @@ -209,4 +209,4 @@ class ComponentAnalyzer {
}
}

module.exports = ComponentAnalyzer;
export default ComponentAnalyzer;
18 changes: 9 additions & 9 deletions lib/lbt/analyzer/FioriElementsAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
* This class can handle multiple concurrent analysis calls, it has no instance state other than the pool
* (which is readonly).
*/
"use strict";

const ModuleName = require("../utils/ModuleName");
const SapUiDefine = require("../calls/SapUiDefine");
const {parseJS, Syntax} = require("../utils/parseUtils");
const {getValue, isMethodCall, getStringValue} = require("../utils/ASTUtils");
const log = require("@ui5/logger").getLogger("lbt:analyzer:FioriElementAnalyzer");
import {fromUI5LegacyName} from "../utils/ModuleName.js";
import SapUiDefine from "../calls/SapUiDefine.js";
import {parseJS, Syntax} from "../utils/parseUtils.js";
import {getValue, isMethodCall, getStringValue} from "../utils/ASTUtils.js";
import logger from "@ui5/logger";
const log = logger.getLogger("lbt:analyzer:FioriElementAnalyzer");

// ---------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -129,7 +129,7 @@ class FioriElementsAnalyzer {
}
each(activityCfg, (actionCfg) => {
if ( actionCfg.template ) {
const module = ModuleName.fromUI5LegacyName( "sap.fe.templates." +
const module = fromUI5LegacyName( "sap.fe.templates." +
actionCfg.template + ".Component" );
log.verbose("template app: add dependency to template component %s", module);
info.addDependency(module);
Expand All @@ -151,7 +151,7 @@ class FioriElementsAnalyzer {
const templateName = (pageConfig.component && pageConfig.component.settings &&
pageConfig.component.settings.templateName) || defaultTemplateName;
if ( templateName ) {
const templateModuleName = ModuleName.fromUI5LegacyName( templateName, ".view.xml" );
const templateModuleName = fromUI5LegacyName( templateName, ".view.xml" );
log.verbose("template app: add dependency to template view %s", templateModuleName);
appInfo.addDependency(templateModuleName);
}
Expand Down Expand Up @@ -197,4 +197,4 @@ class FioriElementsAnalyzer {
}
}

module.exports = FioriElementsAnalyzer;
export default FioriElementsAnalyzer;
Loading

0 comments on commit a439aa9

Please sign in to comment.