@ui5/webcomponents-tools 2.5.0 → 2.6.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.6.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.5.0...v2.6.0-rc.0) (2024-12-12)
7
+
8
+
9
+ ### Features
10
+
11
+ * **framework:** add JSX template support with TypeScript ([#10046](https://github.com/SAP/ui5-webcomponents/issues/10046)) ([f42e7c1](https://github.com/SAP/ui5-webcomponents/commit/f42e7c18c846f923df4fec6ae02f1b4c20c006fa))
12
+
13
+
14
+
15
+
16
+
6
17
  # [2.5.0](https://github.com/SAP/ui5-webcomponents/compare/v2.5.0-rc.3...v2.5.0) (2024-12-05)
7
18
 
8
19
  **Note:** Version bump only for package @ui5/webcomponents-tools
@@ -3,10 +3,11 @@ const path = require("path");
3
3
  const tsMode = fs.existsSync(path.join(process.cwd(), "tsconfig.json"));
4
4
 
5
5
  /**
6
- * Typescript Rules
6
+ * Returns eslint rules specific to typescript files
7
+ * @returns
7
8
  */
8
- const overrides = tsMode ? [
9
- {
9
+ const getTsModeOverrides = () => {
10
+ const tsConfiguration = {
10
11
  files: ["*.ts"],
11
12
  parser: "@typescript-eslint/parser",
12
13
  plugins: ["@typescript-eslint"],
@@ -36,8 +37,22 @@ const overrides = tsMode ? [
36
37
  "@typescript-eslint/no-empty-interface": "off",
37
38
  "lines-between-class-members": "off",
38
39
  }
39
- },
40
- {
40
+ };
41
+
42
+ const tsxConfiguration = JSON.parse(JSON.stringify(tsConfiguration));
43
+ tsxConfiguration.files = ["*.tsx"];
44
+ tsxConfiguration.rules = {
45
+ ...tsxConfiguration.rules,
46
+ "@typescript-eslint/unbound-method": "off", // to be able to attach on* listeners
47
+ "@typescript-eslint/no-misused-promises": "off", // to be able to have async event listeners
48
+ "operator-linebreak": "off",
49
+ "no-nested-ternary": "off",
50
+ "implicit-arrow-linebreak": "off",
51
+ "function-paren-newline": "off",
52
+ "comma-dangle": "off"
53
+ };
54
+
55
+ const cypressConfiguration = {
41
56
  "files": ["**/cypress/**/*.ts"],
42
57
 
43
58
  "plugins": [
@@ -69,7 +84,13 @@ const overrides = tsMode ? [
69
84
  ]
70
85
  }
71
86
  }
72
- ] : [];
87
+
88
+ return [
89
+ tsConfiguration,
90
+ tsxConfiguration,
91
+ cypressConfiguration,
92
+ ];
93
+ }
73
94
 
74
95
  module.exports = {
75
96
  "env": {
@@ -78,7 +99,7 @@ module.exports = {
78
99
  },
79
100
  "root": true,
80
101
  "extends": "airbnb-base",
81
- overrides,
102
+ "overrides": tsMode ? getTsModeOverrides() : [],
82
103
  "parserOptions": {
83
104
  "ecmaVersion": 2018,
84
105
  "sourceType": "module"
@@ -121,6 +142,7 @@ module.exports = {
121
142
  "curly": [2, "all"],
122
143
  // "default-case": 1, // removed for UI5 WebComponents
123
144
  "import/extensions": ["error", "always"], // override for UI5 WebComponents
145
+ "import/order": "off",
124
146
  "no-alert": 2,
125
147
  "no-caller": 2,
126
148
  "no-div-regex": 2,
package/lib/cem/utils.mjs CHANGED
@@ -156,12 +156,22 @@ const findImportPath = (ts, sourceFile, typeName, modulePath) => {
156
156
  ?.replace("src", "dist")?.replace(".ts", ".js") || undefined
157
157
  );
158
158
  } else {
159
- const packageName = Object.keys(packageJSON?.dependencies || {}).find(
160
- (dependency) =>
161
- currentModuleSpecifier?.text?.startsWith(dependency)
162
- );
163
- return currentModuleSpecifier?.text
164
- ?.replace(`${packageName}/`, "") || undefined;
159
+ // my-package/test
160
+ // my-package
161
+ // @scope/my-package
162
+ // my.package
163
+ // _mypackage
164
+ // mypackage-
165
+ // scope/my-package/test
166
+ // @scope/my-package/test
167
+ const match = currentModuleSpecifier?.text.match(/^((@([a-z0-9._-]+)\/)?([a-z0-9._-]+))/);
168
+ let packageName;
169
+
170
+ if (match) {
171
+ packageName = match[1];
172
+ }
173
+
174
+ return packageName || undefined;
165
175
  }
166
176
  }
167
177
  };
@@ -24,15 +24,20 @@ const importForControl = (controlName, hasTypes) => {
24
24
  }
25
25
 
26
26
  const buildRenderer = (controlName, litTemplate, hasTypes) => {
27
- const importPrefix = process.env.UI5_BASE ? "../../../../../src/" : "@ui5/webcomponents-base/dist/"
27
+ const importPrefix = process.env.UI5_BASE ? "../../../../../src/" : "@ui5/webcomponents-base/dist/";
28
+
29
+ const mainTemplateFunction = process.env.UI5_TS ?
30
+ `function template(this: ${controlName}) { return block0.call(this, this, (this.constructor as typeof UI5Element).tagsToScope, getCustomElementsScopingSuffix()); }` :
31
+ `function template() { return block0.call(this, this, this.constructor.tagsToScope, getCustomElementsScopingSuffix()); }`;
28
32
 
29
33
  // typescript cannot process package imports for the same package and the paths are changed to relative for base package templates
30
34
  return `/* eslint no-unused-vars: 0 */
31
35
  import { html, svg, repeat, classMap, styleMap, ifDefined, unsafeHTML, scopeTag } from "${importPrefix}renderer/LitRenderer.js";
36
+ import { getCustomElementsScopingSuffix } from "${importPrefix}CustomElementsScopeUtils.js";
32
37
  ${tsImports(controlName, hasTypes)}
33
38
  ${litTemplate}
34
-
35
- export default block0;`;
39
+ ${mainTemplateFunction}
40
+ export default template;`;
36
41
  };
37
42
 
38
43
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-tools",
3
- "version": "2.5.0",
3
+ "version": "2.6.0-rc.0",
4
4
  "description": "UI5 Web Components: webcomponents.tools",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -86,5 +86,5 @@
86
86
  "esbuild": "^0.19.9",
87
87
  "yargs": "^17.5.1"
88
88
  },
89
- "gitHead": "fcedbbfe572884f193b3f8900b16931b51a5c48d"
89
+ "gitHead": "17869d45f20b28009feaac9d6f59054ba530b3ae"
90
90
  }