@ui5/webcomponents-tools 0.0.0-fca1107e7 → 0.0.0-fd426fe8a

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +1078 -1
  2. package/README.md +2 -5
  3. package/assets-meta.js +1 -8
  4. package/components-package/eslint.js +59 -31
  5. package/components-package/nps.js +50 -30
  6. package/components-package/vite.config.js +7 -11
  7. package/components-package/wdio.js +415 -405
  8. package/icons-collection/nps.js +2 -2
  9. package/lib/cem/custom-elements-manifest.config.mjs +74 -45
  10. package/lib/cem/event.mjs +69 -32
  11. package/lib/cem/schema-internal.json +65 -0
  12. package/lib/cem/types-internal.d.ts +14 -2
  13. package/lib/cem/utils.mjs +69 -30
  14. package/lib/cem/validate.js +37 -40
  15. package/lib/create-icons/index.js +13 -10
  16. package/lib/create-illustrations/index.js +19 -1
  17. package/lib/create-new-component/{tsFileContentTemplate.js → Component.js} +12 -9
  18. package/lib/create-new-component/ComponentTemplate.js +12 -0
  19. package/lib/create-new-component/index.js +14 -22
  20. package/lib/css-processors/css-processor-components.mjs +3 -2
  21. package/lib/css-processors/css-processor-themes.mjs +2 -7
  22. package/lib/css-processors/shared.mjs +4 -24
  23. package/lib/dev-server/{dev-server.js → dev-server.mjs} +4 -4
  24. package/lib/dev-server/virtual-index-html-plugin.js +24 -20
  25. package/lib/generate-json-imports/i18n.js +46 -62
  26. package/lib/generate-json-imports/themes.js +17 -36
  27. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +12 -7
  28. package/lib/hbs2ui5/index.js +3 -3
  29. package/lib/i18n/defaults.js +3 -2
  30. package/lib/remove-dev-mode/remove-dev-mode.mjs +37 -0
  31. package/lib/scoping/get-all-tags.js +9 -2
  32. package/lib/scoping/lint-src.js +8 -7
  33. package/package.json +9 -8
  34. package/tsconfig.json +18 -0
  35. package/components-package/wdio.sync.js +0 -368
  36. package/lib/create-new-component/jsFileContentTemplate.js +0 -73
  37. package/lib/css-processors/css-processor-component-styles.mjs +0 -47
  38. package/lib/generate-custom-elements-manifest/index.js +0 -271
  39. package/lib/jsdoc/config.json +0 -29
  40. package/lib/jsdoc/configTypescript.json +0 -29
  41. package/lib/jsdoc/plugin.js +0 -2468
  42. package/lib/jsdoc/preprocess.js +0 -146
  43. package/lib/jsdoc/template/publish.js +0 -4120
@@ -1,23 +1,17 @@
1
- const virtualIndexPlugin = async () => {
2
- const path = await import("path");
3
- const { globby } = await import("globby");
4
- const files = await globby(["test/pages/**/*.html", "packages/*/test/pages/**/*.html"]);
5
-
6
- const pagesPerFolder = {};
7
- files.forEach(file => {
8
- let folder = pagesPerFolder[path.dirname(file)] = pagesPerFolder[path.dirname(file)] || [];
9
- folder.push(path.basename(file));
10
- });
1
+ const virtualIndexPlugin = () => {
2
+ return {
3
+ name: 'virtual-index-html',
4
+ async config() {
5
+ const path = (await import("path")).default;
6
+ const globby = (await import("globby")).globby;
7
+ const files = await globby(["test/pages/**/*.html", "packages/*/test/pages/**/*.html"]);
11
8
 
12
- const rollupInput = {};
9
+ const rollupInput = {};
13
10
 
14
- files.forEach(file => {
15
- rollupInput[file] = path.resolve(process.cwd(), file);
16
- })
11
+ files.forEach(file => {
12
+ rollupInput[file] = path.resolve(process.cwd(), file);
13
+ });
17
14
 
18
- return {
19
- name: 'virtual-index-html',
20
- config() {
21
15
  return {
22
16
  build: {
23
17
  rollupOptions: {
@@ -26,7 +20,17 @@ const virtualIndexPlugin = async () => {
26
20
  }
27
21
  }
28
22
  },
29
- configureServer(server) {
23
+ async configureServer(server) {
24
+ const path = (await import("path")).default;
25
+ const globby = (await import("globby")).globby;
26
+ const files = await globby(["test/pages/**/*.html", "packages/*/test/pages/**/*.html"]);
27
+
28
+ const pagesPerFolder = {};
29
+ files.forEach(file => {
30
+ let folder = pagesPerFolder[path.dirname(file)] = pagesPerFolder[path.dirname(file)] || [];
31
+ folder.push(path.basename(file));
32
+ });
33
+
30
34
  server.middlewares.use((req, res, next) => {
31
35
  if (req.url === "/") {
32
36
  const folders = Object.keys(pagesPerFolder);
@@ -37,8 +41,8 @@ const virtualIndexPlugin = async () => {
37
41
  const pages = pagesPerFolder[folder];
38
42
  return `<h1>${folder}</h1>
39
43
  ${pages.map(page => {
40
- return `<li><a href='${folder}/${page}'>${page}</a></li>`
41
- }).join("")}
44
+ return `<li><a href='${folder}/${page}'>${page}</a></li>`
45
+ }).join("")}
42
46
  `
43
47
  }).join("")}`);
44
48
  } else {
@@ -4,97 +4,81 @@ const path = require('path');
4
4
  const isTypeScript = process.env.UI5_TS;
5
5
  const ext = isTypeScript ? 'ts' : 'js';
6
6
 
7
+
8
+ const getContent = function(caseLines, languagesKeysStringArray, packageName) {
9
+ return `// @ts-nocheck
10
+ import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
11
+
12
+ const importMessageBundle = async (localeId) => {
13
+ switch (localeId) {
14
+ ${caseLines}
15
+ default: throw "unknown locale"
16
+ }
17
+ }
18
+
19
+ const importAndCheck = async (localeId) => {
20
+ const data = await importMessageBundle(localeId);
21
+ if (typeof data === "string" && data.endsWith(".json")) {
22
+ throw new Error(\`[i18n] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build. Check the \"Assets\" documentation for more information.\`);
23
+ }
24
+ return data;
25
+ }
26
+
27
+ const localeIds = [${languagesKeysStringArray}];
28
+
29
+ localeIds.forEach(localeId => {
30
+ registerI18nLoader(${ packageName.split("").map(c => `"${c}"`).join (" + ") }, localeId, importAndCheck);
31
+ });
32
+ `;
33
+ }
34
+
7
35
  const generate = async () => {
8
36
 
9
37
  const packageName = JSON.parse(await fs.readFile("package.json")).name;
10
38
 
11
39
  const inputFolder = path.normalize(process.argv[2]);
12
- const outputFile = path.normalize(`${process.argv[3]}/i18n-static.${ext}`);
13
40
  const outputFileDynamic = path.normalize(`${process.argv[3]}/i18n.${ext}`);
41
+ const outputFileFetchMetaResolve = path.normalize(`${process.argv[3]}/i18n-fetch.${ext}`);
42
+ const outputFileDynamicImportJSONImport = path.normalize(`${process.argv[3]}/i18n-node.${ext}`);
14
43
 
15
- // All languages present in the file system
44
+ // All languages present in the file system
16
45
  const files = await fs.readdir(inputFolder);
17
46
  const languages = files.map(file => {
18
47
  const matches = file.match(/messagebundle_(.+?).json$/);
19
48
  return matches ? matches[1] : undefined;
20
49
  }).filter(key => !!key);
21
50
 
22
- let contentStatic, contentDynamic;
51
+ let contentDynamic;
52
+ let contentFetchMetaResolve;
53
+ let contentDynamicImportJSONAttr;
23
54
 
24
- // No i18n - just import dependencies, if any
55
+ // No i18n - just import dependencies, if any
25
56
  if (languages.length === 0) {
26
- contentStatic = "";
27
57
  contentDynamic = "";
28
- // There is i18n - generate the full file
58
+ contentFetchMetaResolve = "";
59
+ contentDynamicImportJSONAttr = "";
60
+ // There is i18n - generate the full file
29
61
  } else {
30
62
  // Keys for the array
31
- const languagesKeysString = languages.map(key => `"${key}": _${key},`).join("\n\t");
32
63
  const languagesKeysStringArray = languages.map(key => `"${key}",`).join("\n\t");
33
64
 
34
- // Actual imports for json assets
35
- const assetsImportsString = languages.map(key => `import _${key} from "../assets/i18n/messagebundle_${key}.json";`).join("\n");
36
-
37
- // static imports
38
- contentStatic = `// @ts-nocheck
39
- import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
40
-
41
- ${assetsImportsString}
42
-
43
- const bundleMap = {
44
- ${languagesKeysString}
45
- };
46
-
47
- const fetchMessageBundle = async (localeId) => {
48
- if (typeof bundleMap[localeId] === "object") {
49
- // inlined from build
50
- throw new Error("[i18n] Inlined JSON not supported with static imports of assets. Use dynamic imports of assets or configure JSON imports as URLs")
51
- }
52
- return (await fetch(bundleMap[localeId])).json()
53
- }
54
-
55
- const localeIds = [${languagesKeysStringArray}];
56
-
57
- localeIds.forEach(localeId => {
58
- registerI18nLoader("${packageName}", localeId, fetchMessageBundle);
59
- });
60
- `;
61
-
62
65
  // Actual imports for json assets
63
66
  const dynamicImportsString = languages.map(key => ` case "${key}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-messagebundle-${key}" */ "../assets/i18n/messagebundle_${key}.json")).default;`).join("\n");
67
+ const fetchMetaResolveString = languages.map(key => ` case "${key}": return (await fetch(new URL("../assets/i18n/messagebundle_${key}.json", import.meta.url))).json();`).join("\n");
68
+ const dynamicImportJSONAttrString = languages.map(key => ` case "${key}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-messagebundle-${key}" */ "../assets/i18n/messagebundle_${key}.json", {with: { type: 'json'}})).default;`).join("\n");
64
69
 
65
70
  // Resulting file content
66
- contentDynamic = `// @ts-nocheck
67
- import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
68
-
69
- const importMessageBundle = async (localeId) => {
70
- switch (localeId) {
71
- ${dynamicImportsString}
72
- default: throw "unknown locale"
73
- }
74
- }
75
-
76
- const importAndCheck = async (localeId) => {
77
- const data = await importMessageBundle(localeId);
78
- if (typeof data === "string" && data.endsWith(".json")) {
79
- throw new Error(\`[i18n] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build or use 'import ".../Assets-static.js"'. Check the \"Assets\" documentation for more information.\`);
80
- }
81
- return data;
82
- }
83
-
84
- const localeIds = [${languagesKeysStringArray}];
85
-
86
- localeIds.forEach(localeId => {
87
- registerI18nLoader("${packageName}", localeId, importAndCheck);
88
- });
89
- `;
90
-
91
71
 
72
+ contentDynamic = getContent(dynamicImportsString, languagesKeysStringArray, packageName);
73
+ contentFetchMetaResolve = getContent(fetchMetaResolveString, languagesKeysStringArray, packageName);
74
+ contentDynamicImportJSONAttr = getContent(dynamicImportJSONAttrString, languagesKeysStringArray, packageName);
92
75
  }
93
76
 
94
- await fs.mkdir(path.dirname(outputFile), { recursive: true });
77
+ await fs.mkdir(path.dirname(outputFileDynamic), { recursive: true });
95
78
  return Promise.all([
96
- fs.writeFile(outputFile, contentStatic),
97
79
  fs.writeFile(outputFileDynamic, contentDynamic),
80
+ fs.writeFile(outputFileFetchMetaResolve, contentFetchMetaResolve),
81
+ fs.writeFile(outputFileDynamicImportJSONImport, contentDynamicImportJSONAttr),
98
82
  ]);
99
83
  }
100
84
 
@@ -7,13 +7,14 @@ const ext = isTypeScript ? 'ts' : 'js';
7
7
 
8
8
  const generate = async () => {
9
9
  const inputFolder = path.normalize(process.argv[2]);
10
- const outputFile = path.normalize(`${process.argv[3]}/Themes-static.${ext}`);
11
10
  const outputFileDynamic = path.normalize(`${process.argv[3]}/Themes.${ext}`);
11
+ const outputFileDynamicImportJSONAttr = path.normalize(`${process.argv[3]}/Themes-node.${ext}`);
12
+ const outputFileFetchMetaResolve = path.normalize(`${process.argv[3]}/Themes-fetch.${ext}`);
12
13
 
13
- // All supported optional themes
14
+ // All supported optional themes
14
15
  const allThemes = assets.themes.all;
15
16
 
16
- // All themes present in the file system
17
+ // All themes present in the file system
17
18
  const dirs = await fs.readdir(inputFolder);
18
19
  const themesOnFileSystem = dirs.map(dir => {
19
20
  const matches = dir.match(/sap_.*$/);
@@ -22,41 +23,19 @@ const generate = async () => {
22
23
 
23
24
  const packageName = JSON.parse(await fs.readFile("package.json")).name;
24
25
 
25
- const importLines = themesOnFileSystem.map(theme => `import ${theme} from "../assets/themes/${theme}/parameters-bundle.css.json";`).join("\n");
26
- const themeUrlsByName = "{\n" + themesOnFileSystem.join(",\n") + "\n}";
27
26
  const availableThemesArray = `[${themesOnFileSystem.map(theme => `"${theme}"`).join(", ")}]`;
28
27
  const dynamicImportLines = themesOnFileSystem.map(theme => `\t\tcase "${theme}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-${theme.replace("_", "-")}-parameters-bundle" */"../assets/themes/${theme}/parameters-bundle.css.json")).default;`).join("\n");
28
+ const dynamicImportJSONAttrLines = themesOnFileSystem.map(theme => `\t\tcase "${theme}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-${theme.replace("_", "-")}-parameters-bundle" */"../assets/themes/${theme}/parameters-bundle.css.json", {with: { type: 'json'}})).default;`).join("\n");
29
+ const fetchMetaResolveLines = themesOnFileSystem.map(theme => `\t\tcase "${theme}": return (await fetch(new URL("../assets/themes/${theme}/parameters-bundle.css.json", import.meta.url))).json();`).join("\n");
29
30
 
30
-
31
- // static imports file content
32
- const contentStatic = `// @ts-nocheck
33
- import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
34
-
35
- ${importLines}
36
-
37
- const themeUrlsByName = ${themeUrlsByName};
38
- const isInlined = obj => typeof (obj) === "object";
39
-
40
- const loadThemeProperties = async (themeName) => {
41
- if (typeof themeUrlsByName[themeName] === "object") {
42
- // inlined from build
43
- throw new Error("[themes] Inlined JSON not supported with static imports of assets. Use dynamic imports of assets or configure JSON imports as URLs");
44
- }
45
- return (await fetch(themeUrlsByName[themeName])).json();
46
- };
47
-
48
- ${availableThemesArray}
49
- .forEach(themeName => registerThemePropertiesLoader("${packageName}", themeName, loadThemeProperties));
50
- `;
51
-
52
-
53
- // dynamic imports file content
54
- const contentDynamic = `// @ts-nocheck
31
+ // dynamic imports file content
32
+ const contentDynamic = function (lines) {
33
+ return `// @ts-nocheck
55
34
  import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
56
35
 
57
36
  const loadThemeProperties = async (themeName) => {
58
37
  switch (themeName) {
59
- ${dynamicImportLines}
38
+ ${lines}
60
39
  default: throw "unknown theme"
61
40
  }
62
41
  };
@@ -64,19 +43,21 @@ ${dynamicImportLines}
64
43
  const loadAndCheck = async (themeName) => {
65
44
  const data = await loadThemeProperties(themeName);
66
45
  if (typeof data === "string" && data.endsWith(".json")) {
67
- throw new Error(\`[themes] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build or use 'import ".../Assets-static.js"'. Check the \"Assets\" documentation for more information.\`);
46
+ throw new Error(\`[themes] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build. Check the \"Assets\" documentation for more information.\`);
68
47
  }
69
48
  return data;
70
49
  };
71
50
 
72
51
  ${availableThemesArray}
73
- .forEach(themeName => registerThemePropertiesLoader("${packageName}", themeName, loadAndCheck));
52
+ .forEach(themeName => registerThemePropertiesLoader(${ packageName.split("").map(c => `"${c}"`).join (" + ") }, themeName, loadAndCheck));
74
53
  `;
54
+ }
75
55
 
76
- await fs.mkdir(path.dirname(outputFile), { recursive: true });
56
+ await fs.mkdir(path.dirname(outputFileDynamic), { recursive: true });
77
57
  return Promise.all([
78
- fs.writeFile(outputFile, contentStatic),
79
- fs.writeFile(outputFileDynamic, contentDynamic)
58
+ fs.writeFile(outputFileDynamic, contentDynamic(dynamicImportLines)),
59
+ fs.writeFile(outputFileDynamicImportJSONAttr, contentDynamic(dynamicImportJSONAttrLines)),
60
+ fs.writeFile(outputFileFetchMetaResolve, contentDynamic(fetchMetaResolveLines)),
80
61
  ]);
81
62
  };
82
63
 
@@ -3,11 +3,11 @@ const tsImports = (controlName, hasTypes) => {
3
3
  return "";
4
4
  }
5
5
 
6
- const importPrefix = process.env.UI5_BASE ? "../../../" : "@ui5/webcomponents-base/dist/"
6
+ const importPrefix = process.env.UI5_BASE ? "../../../../../src/" : "@ui5/webcomponents-base/dist/"
7
7
 
8
8
  return `import type UI5Element from "${importPrefix}UI5Element.js";
9
- ${importForControl(controlName, hasTypes)}
10
- import type { ClassMapValue } from "${importPrefix}types.js";
9
+ ${importForControl(controlName, hasTypes)}
10
+ import type { ClassMapValue } from "${importPrefix}types.js";
11
11
  `;
12
12
  }
13
13
  const importForControl = (controlName, hasTypes) => {
@@ -18,21 +18,26 @@ const importForControl = (controlName, hasTypes) => {
18
18
 
19
19
  if (process.env.UI5_BASE) {
20
20
  // base package has a component in `test/elements` instead of `src`
21
- return `import type ${controlName} from "../../../../test/elements/${controlName}.js";`
21
+ return `import type ${controlName} from "../../../${controlName}.js";`
22
22
  }
23
23
  return `import type ${controlName} from "../../${controlName}.js";`
24
24
  }
25
25
 
26
26
  const buildRenderer = (controlName, litTemplate, hasTypes) => {
27
- const importPrefix = process.env.UI5_BASE ? "../../../" : "@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 = {
@@ -24,7 +24,7 @@ const onError = (place) => {
24
24
  console.log(`A problem occoured when reading ${place}. Please recheck passed parameters.`);
25
25
  };
26
26
 
27
- const isHandlebars = (fileName) => fileName.indexOf('.hbs') !== -1;
27
+ const isHandlebars = (fileName) => fileName.endsWith('.hbs');
28
28
 
29
29
  const hasTypes = (file, componentName) => {
30
30
  const tsFile = path.join(path.dirname(file), componentName + ".ts")
@@ -36,7 +36,7 @@ const processFile = async (file, outputDir) => {
36
36
  const componentNameMatcher = /(\w+)(\.hbs)/gim;
37
37
  const componentName = componentNameMatcher.exec(file)[1];
38
38
  const componentHasTypes = hasTypes(file, componentName);
39
- if (!componentHasTypes) {
39
+ if (!componentHasTypes) {
40
40
  if (!missingTypesReported) {
41
41
  console.warn("[Warn] The following templates do not have a corresponging .ts or .d.ts file and won't be type checked:")
42
42
  missingTypesReported = true;
@@ -98,7 +98,7 @@ const writeRenderers = async (outputDir, controlName, fileContent) => {
98
98
 
99
99
  let existingFileContent = "";
100
100
  try {
101
- existingFileContent = await fs.readFile(compiledFilePath);
101
+ existingFileContent = (await fs.readFile(compiledFilePath)).toString();
102
102
  } catch (e) {}
103
103
 
104
104
  if (existingFileContent !== fileContentUnix) {
@@ -31,7 +31,8 @@ const generate = async () => {
31
31
  // (2) as the messagebundle.properties file is always written in English,
32
32
  // it makes sense to consider the messagebundle.properties content only when the default language is "en".
33
33
  if (defaultLanguage === "en") {
34
- defaultLanguageProperties = Object.assign({}, defaultLanguageProperties, properties);
34
+ // use messagebundle_en.properties to overwrite all developer properties, only the not translated ones will remain
35
+ defaultLanguageProperties = Object.assign({}, properties, defaultLanguageProperties);
35
36
  }
36
37
 
37
38
  /*
@@ -68,7 +69,7 @@ const generate = async () => {
68
69
  const texts = textKeys.map(prop => getTextInfo(prop, properties[prop], defaultLanguageProperties && defaultLanguageProperties[prop])).join('');
69
70
 
70
71
  // tabs are intentionally mixed to have proper identation in the produced file
71
- return `${tsMode ? `import { I18nText } from "@ui5/webcomponents-base/dist/i18nBundle.js";` : ""}
72
+ return `${tsMode ? `import type { I18nText } from "@ui5/webcomponents-base/dist/i18nBundle.js";` : ""}
72
73
  ${texts}
73
74
  export {${textKeys.join()}};`;
74
75
  };
@@ -0,0 +1,37 @@
1
+ import { globby } from "globby";
2
+ import * as esbuild from 'esbuild'
3
+ import * as fs from "fs";
4
+
5
+ let customPlugin = {
6
+ name: 'ui5-tools',
7
+ setup(build) {
8
+ build.onLoad({ filter: /UI5Element.ts$/ }, async (args) => {
9
+ let text = await fs.promises.readFile(args.path, 'utf8');
10
+ text = text.replaceAll(/const DEV_MODE = true/g, "");
11
+ text = text.replaceAll(/if \(DEV_MODE\)/g, "if (false)");
12
+ return {
13
+ contents: text,
14
+ loader: 'ts',
15
+ }
16
+ })
17
+ },
18
+ }
19
+
20
+ const getConfig = async () => {
21
+ const config = {
22
+ entryPoints: await globby("src/**/*.ts"),
23
+ bundle: false,
24
+ minify: true,
25
+ sourcemap: true,
26
+ outdir: 'dist/prod',
27
+ outbase: 'src',
28
+ plugins: [
29
+ customPlugin,
30
+ ]
31
+ };
32
+ return config;
33
+ }
34
+
35
+
36
+ const config = await getConfig();
37
+ const result = await esbuild.build(config);
@@ -4,8 +4,15 @@ const glob = require("glob");
4
4
 
5
5
  const getTag = file => {
6
6
  const fileContent = String(fs.readFileSync(file)).replace(/\n/g, "");
7
- const matches = fileContent.match(/\btag\b:\s*\"(.*?)\"/);
8
- return matches ? matches[1] : undefined;
7
+ let matches = fileContent.match(/\btag\b:\s*\"(.*?)\"/);
8
+ if (matches) {
9
+ return matches[1];
10
+ }
11
+ matches = fileContent.match(/@customElement\("(.*?)"\)/);
12
+ if (matches) {
13
+ return matches[1];
14
+ }
15
+ return undefined;
9
16
  };
10
17
 
11
18
  const getPackageTags = (packageDir) => {
@@ -7,25 +7,26 @@ const tags = getAllTags(process.cwd());
7
7
 
8
8
  const errors = [];
9
9
 
10
+ const removeComments = str => str.replaceAll(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm, "");
11
+
10
12
  glob.sync(path.join(process.cwd(), "src/**/*.css")).forEach(file => {
11
- let content = String(fs.readFileSync(file));
13
+ let content = removeComments(String(fs.readFileSync(file)));
12
14
  tags.forEach(tag => {
13
15
  if (content.match(new RegExp(`(^|[^\.\-_A-Za-z0-9"\[])(${tag})([^\-_A-Za-z0-9]|$)`, "g"))) {
14
- errors.push(`Warning! ${tag} found in ${file}`);
16
+ errors.push(`${tag} found in ${file}`);
15
17
  }
16
18
  });
17
19
  });
18
20
 
19
- glob.sync(path.join(process.cwd(), "src/**/*.js")).forEach(file => {
20
- let content = String(fs.readFileSync(file));
21
+ glob.sync(path.join(process.cwd(), "src/**/*.ts")).forEach(file => {
22
+ let content = removeComments(String(fs.readFileSync(file)));
21
23
  tags.forEach(tag => {
22
24
  if (content.match(new RegExp(`querySelector[A-Za-z]*..${tag}`, "g"))) {
23
- errors.push(`Warning! querySelector for ${tag} found in ${file}`);
25
+ errors.push(`querySelector for ${tag} found in ${file}`);
24
26
  }
25
27
  });
26
28
  });
27
29
 
28
30
  if (errors.length) {
29
- errors.forEach(error => console.log(error));
30
- throw new Error("Errors found.");
31
+ throw new Error(`Scoping-related errors found (f.e. used ui5-input instead of [ui5-input]): \n ${errors.join("\n")}`);
31
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-tools",
3
- "version": "0.0.0-fca1107e7",
3
+ "version": "0.0.0-fd426fe8a",
4
4
  "description": "UI5 Web Components: webcomponents.tools",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -21,7 +21,7 @@
21
21
  "directory": "packages/tools"
22
22
  },
23
23
  "dependencies": {
24
- "@custom-elements-manifest/analyzer": "^0.8.4",
24
+ "@custom-elements-manifest/analyzer": "^0.10.4",
25
25
  "@typescript-eslint/eslint-plugin": "^6.9.0",
26
26
  "@typescript-eslint/parser": "^6.9.0",
27
27
  "@wdio/cli": "^7.19.7",
@@ -34,7 +34,7 @@
34
34
  "cem-plugin-vs-code-custom-data-generator": "^1.4.2",
35
35
  "chai": "^4.3.4",
36
36
  "child_process": "^1.0.2",
37
- "chokidar": "^3.5.1",
37
+ "chokidar": "^3.6.0",
38
38
  "chokidar-cli": "^3.0.0",
39
39
  "command-line-args": "^5.1.1",
40
40
  "comment-parser": "^1.4.0",
@@ -44,7 +44,8 @@
44
44
  "escodegen": "^2.0.0",
45
45
  "eslint": "^7.22.0",
46
46
  "eslint-config-airbnb-base": "^14.2.1",
47
- "eslint-plugin-import": "^2.22.1",
47
+ "eslint-plugin-import": "^2.31.0",
48
+ "eslint-plugin-jsx-no-leaked-values": "^0.1.24",
48
49
  "esprima": "^4.0.1",
49
50
  "getopts": "^2.3.0",
50
51
  "glob": "^7.1.6",
@@ -52,7 +53,6 @@
52
53
  "globby": "^13.1.1",
53
54
  "handlebars": "^4.7.7",
54
55
  "is-port-reachable": "^3.1.0",
55
- "jsdoc": "^3.6.6",
56
56
  "json-beautify": "^1.1.1",
57
57
  "mkdirp": "^1.0.4",
58
58
  "nps": "^5.10.0",
@@ -65,12 +65,13 @@
65
65
  "resolve": "^1.20.0",
66
66
  "rimraf": "^3.0.2",
67
67
  "slash": "3.0.0",
68
- "vite": "^4.4.9",
68
+ "vite": "^5.4.8",
69
+ "vite-plugin-istanbul": "^6.0.2",
69
70
  "wdio-chromedriver-service": "^7.3.2"
70
71
  },
71
72
  "peerDependencies": {
72
73
  "chromedriver": "*",
73
- "typescript": "^5.2.2"
74
+ "typescript": "^5.6.2"
74
75
  },
75
76
  "peerDependenciesMeta": {
76
77
  "typescript": {
@@ -78,7 +79,7 @@
78
79
  }
79
80
  },
80
81
  "devDependencies": {
81
- "esbuild": "^0.19.9",
82
+ "esbuild": "^0.25.0",
82
83
  "yargs": "^17.5.1"
83
84
  }
84
85
  }
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2021",
4
+ "lib": [
5
+ "DOM",
6
+ "DOM.Iterable",
7
+ "ES2023"
8
+ ],
9
+ "declaration": true,
10
+ "skipLibCheck": true,
11
+ "sourceMap": true,
12
+ "inlineSources": true,
13
+ "strict": true,
14
+ "moduleResolution": "node",
15
+ "jsx": "react-jsx",
16
+ "jsxImportSource": "@ui5/webcomponents-base",
17
+ }
18
+ }