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

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,25 @@
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.1](https://github.com/SAP/ui5-webcomponents/compare/v2.6.0-rc.0...v2.6.0-rc.1) (2024-12-16)
7
+
8
+ **Note:** Version bump only for package @ui5/webcomponents-tools
9
+
10
+
11
+
12
+
13
+
14
+ # [2.6.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.5.0...v2.6.0-rc.0) (2024-12-12)
15
+
16
+
17
+ ### Features
18
+
19
+ * **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))
20
+
21
+
22
+
23
+
24
+
6
25
  # [2.5.0](https://github.com/SAP/ui5-webcomponents/compare/v2.5.0-rc.3...v2.5.0) (2024-12-05)
7
26
 
8
27
  **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
  };
@@ -28,7 +28,7 @@ let customPlugin = {
28
28
 
29
29
  // JS/TS
30
30
  const jsPath = f.path.replace(/dist[\/\\]css/, "src/generated/").replace(".css", extension);
31
- const jsContent = getFileContent(tsMode, jsPath, packageJSON.name, "\`" + newText + "\`", true);
31
+ const jsContent = getFileContent(packageJSON.name, "\`" + newText + "\`", true);
32
32
  writeFileIfChanged(jsPath, jsContent);
33
33
  });
34
34
  })
@@ -42,16 +42,11 @@ let scopingPlugin = {
42
42
  // JSON
43
43
  const jsonPath = f.path.replace(/dist[\/\\]css/, "dist/generated/assets").replace(".css", ".css.json");
44
44
  await mkdir(path.dirname(jsonPath), {recursive: true});
45
- const data = {
46
- packageName: packageJSON.name,
47
- fileName: jsonPath.substr(jsonPath.lastIndexOf("themes")),
48
- content: newText,
49
- };
50
- writeFileIfChanged(jsonPath, JSON.stringify({_: data}));
45
+ writeFileIfChanged(jsonPath, JSON.stringify(newText));
51
46
 
52
47
  // JS/TS
53
48
  const jsPath = f.path.replace(/dist[\/\\]css/, "src/generated/").replace(".css", extension);
54
- const jsContent = getFileContent(tsMode, jsPath, packageJSON.name, "\`" + newText + "\`");
49
+ const jsContent = getFileContent(packageJSON.name, "\`" + newText + "\`");
55
50
  writeFileIfChanged(jsPath, jsContent);
56
51
  });
57
52
  })
@@ -47,30 +47,10 @@ registerThemePropertiesLoader("${packageName}", "${DEFAULT_THEME}", async () =>
47
47
  `;
48
48
  };
49
49
 
50
- const getFileContent = (tsMode, targetFile, packageName, css, includeDefaultTheme) => {
51
- if (tsMode) {
52
- return getTSContent(targetFile, packageName, css, includeDefaultTheme);
53
- }
54
-
55
- return getJSContent(targetFile, packageName, css, includeDefaultTheme);
56
- }
57
-
58
- const getTSContent = (targetFile, packageName, css, includeDefaultTheme) => {
59
- const typeImport = "import type { StyleData } from \"@ui5/webcomponents-base/dist/types.js\";"
50
+ const getFileContent = (packageName, css, includeDefaultTheme) => {
60
51
  const defaultTheme = includeDefaultTheme ? getDefaultThemeCode(packageName) : "";
61
-
62
- // tabs are intentionally mixed to have proper identation in the produced file
63
- return `${typeImport}
64
- ${defaultTheme}
65
- const styleData: StyleData = {packageName:"${packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}};
66
- export default styleData;
67
- `;
52
+ return `${defaultTheme}export default ${css.trim()}`
68
53
  }
69
54
 
70
- const getJSContent = (targetFile, packageName, css, includeDefaultTheme) => {
71
- const defaultTheme = includeDefaultTheme ? getDefaultThemeCode(packageName) : "";
72
-
73
- return `${defaultTheme}export default {packageName:"${packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}}`
74
- }
75
55
 
76
56
  export { writeFileIfChanged, stripThemingBaseContent, getFileContent}
@@ -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.1",
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": "f002a980bcb67a9eb7135c887a4c94c7378a6918"
90
90
  }
package/tsconfig.json CHANGED
@@ -12,5 +12,7 @@
12
12
  "inlineSources": true,
13
13
  "strict": true,
14
14
  "moduleResolution": "node",
15
+ "jsx": "react-jsx",
16
+ "jsxImportSource": "@ui5/webcomponents-base",
15
17
  }
16
18
  }