@ui5/webcomponents-tools 1.3.0 → 1.5.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +5 -6
  3. package/bin/dev.js +1 -5
  4. package/components-package/nps.js +51 -38
  5. package/components-package/vite.config.js +12 -0
  6. package/components-package/wdio.js +21 -4
  7. package/components-package/wdio.sync.js +1 -1
  8. package/icons-collection/nps.js +1 -7
  9. package/lib/copy-and-watch/index.js +0 -1
  10. package/lib/copy-list/index.js +16 -16
  11. package/lib/create-icons/index.js +82 -72
  12. package/lib/create-illustrations/index.js +101 -90
  13. package/lib/dev-server/dev-server.js +66 -0
  14. package/lib/dev-server/virtual-index-html-plugin.js +52 -0
  15. package/lib/esm-abs-to-rel/index.js +13 -9
  16. package/lib/generate-json-imports/i18n.js +38 -31
  17. package/lib/generate-json-imports/themes.js +31 -24
  18. package/lib/hbs2lit/src/compiler.js +2 -2
  19. package/lib/hbs2lit/src/includesReplacer.js +5 -5
  20. package/lib/hbs2ui5/index.js +37 -21
  21. package/lib/i18n/defaults.js +49 -57
  22. package/lib/i18n/toJSON.js +12 -11
  23. package/lib/postcss-css-to-esm/index.js +13 -1
  24. package/lib/postcss-css-to-json/index.js +12 -1
  25. package/lib/postcss-p/postcss-p.mjs +3 -0
  26. package/lib/replace-global-core/index.js +13 -8
  27. package/lib/scoping/scope-test-pages.js +1 -1
  28. package/lib/test-runner/test-runner.js +63 -0
  29. package/package.json +14 -17
  30. package/components-package/rollup-plugins/empty-module.js +0 -15
  31. package/components-package/rollup.js +0 -150
  32. package/lib/documentation/index.js +0 -165
  33. package/lib/documentation/templates/api-component-since.js +0 -3
  34. package/lib/documentation/templates/api-css-variables-section.js +0 -24
  35. package/lib/documentation/templates/api-events-section.js +0 -35
  36. package/lib/documentation/templates/api-methods-section.js +0 -26
  37. package/lib/documentation/templates/api-properties-section.js +0 -42
  38. package/lib/documentation/templates/api-slots-section.js +0 -28
  39. package/lib/documentation/templates/template.js +0 -39
  40. package/lib/hash/config.js +0 -10
  41. package/lib/hash/generate.js +0 -19
  42. package/lib/hash/upToDate.js +0 -31
  43. package/lib/serve/index.js +0 -46
  44. package/lib/serve/serve.json +0 -3
  45. package/package-lock.json +0 -48
@@ -1,10 +1,9 @@
1
- const fs = require('fs');
1
+ const fs = require('fs').promises;
2
2
  const getopts = require('getopts');
3
3
  const hbs2lit = require('../hbs2lit');
4
4
  const path = require('path');
5
5
  const litRenderer = require('./RenderTemplates/LitRenderer');
6
6
  const recursiveReadDir = require("recursive-readdir");
7
- const mkdirp = require('mkdirp');
8
7
 
9
8
  const args = getopts(process.argv.slice(2), {
10
9
  alias: {
@@ -24,13 +23,13 @@ const onError = (place) => {
24
23
 
25
24
  const isHandlebars = (fileName) => fileName.indexOf('.hbs') !== -1;
26
25
 
27
- const processFile = (file, outputDir) => {
28
- const litCode = hbs2lit(file);
26
+ const processFile = async (file, outputDir) => {
27
+ const litCode = await hbs2lit(file);
29
28
  const absoluteOutputDir = composeAbsoluteOutputDir(file, outputDir);
30
29
  const componentNameMatcher = /(\w+)(\.hbs)/gim;
31
30
  const componentName = componentNameMatcher.exec(file)[1];
32
31
 
33
- writeRenderers(absoluteOutputDir, componentName, litRenderer.generateTemplate(componentName, litCode));
32
+ return writeRenderers(absoluteOutputDir, componentName, litRenderer.generateTemplate(componentName, litCode));
34
33
  };
35
34
 
36
35
  const composeAbsoluteOutputDir = (file, outputDir) => {
@@ -40,39 +39,54 @@ const composeAbsoluteOutputDir = (file, outputDir) => {
40
39
  const fileDir = file.split(path.sep).slice(1, -1).join(path.sep);
41
40
 
42
41
  // (2) Compose full output dir - "dist/generated/templates/lvl1/lvl2"
43
- return `${outputDir}${path.sep}${fileDir}`;
42
+ return `${outputDir}${path.sep}${fileDir}`;
44
43
  };
45
44
 
46
45
  const wrapDirectory = (directory, outputDir) => {
47
46
  directory = path.normalize(directory);
48
47
  outputDir = path.normalize(outputDir);
49
48
 
50
- recursiveReadDir(directory, (err, files) => {
49
+ return new Promise((resolve, reject) => {
50
+ recursiveReadDir(directory, (err, files) => {
51
51
 
52
- if (err) {
53
- onError('directory');
54
- }
55
-
56
- files.forEach(fileName => {
57
- if (isHandlebars(fileName)) {
58
- processFile(fileName, outputDir);
52
+ if (err) {
53
+ onError('directory');
54
+ reject();
59
55
  }
56
+
57
+ const promises = files.map(fileName => {
58
+ if (isHandlebars(fileName)) {
59
+ return processFile(fileName, outputDir);
60
+ }
61
+ }).filter(x => !!x);
62
+
63
+ resolve(Promise.all(promises));
60
64
  });
61
- })
65
+ });
62
66
  };
63
67
 
64
- const writeRenderers = (outputDir, controlName, fileContent) => {
68
+ const writeRenderers = async (outputDir, controlName, fileContent) => {
65
69
  try {
66
- if (!fs.existsSync(outputDir)) {
67
- mkdirp.sync(outputDir);
68
- }
70
+
71
+ await fs.mkdir(outputDir, { recursive: true });
69
72
 
70
73
  const compiledFilePath = `${outputDir}${path.sep}${controlName}Template.lit.js`;
71
74
 
72
75
  // strip DOS line endings because the break the source maps
73
76
  let fileContentUnix = fileContent.replace(/\r\n/g, "\n");
74
77
  fileContentUnix = fileContentUnix.replace(/\r/g, "\n");
75
- fs.writeFileSync(compiledFilePath, fileContentUnix);
78
+
79
+ // Only write to the file system actual changes - each updated file, no matter if the same or not, triggers an expensive operation for rollup
80
+ // Note: .hbs files that include a changed .hbs file will also be recompiled as their content will be updated too
81
+
82
+ let existingFileContent = "";
83
+ try {
84
+ existingFileContent = await fs.readFile(compiledFilePath);
85
+ } catch (e) {}
86
+
87
+ if (existingFileContent !== fileContentUnix) {
88
+ return fs.writeFile(compiledFilePath, fileContentUnix);
89
+ }
76
90
 
77
91
  } catch (e) {
78
92
  console.log(e);
@@ -82,5 +96,7 @@ const writeRenderers = (outputDir, controlName, fileContent) => {
82
96
  if (!args['d'] || !args['o']) {
83
97
  console.log('Please provide an input and output directory (-d and -o)');
84
98
  } else {
85
- wrapDirectory(args['d'], args['o']);
99
+ wrapDirectory(args['d'], args['o']).then(() => {
100
+ console.log("Templates generated");
101
+ });
86
102
  }
@@ -1,74 +1,66 @@
1
- const fs = require('fs');
1
+ const fs = require('fs').promises;
2
2
  const path = require('path');
3
3
  const PropertiesReader = require('properties-reader');
4
- const mkdirp = require("mkdirp");
5
4
  const assets = require('../../assets-meta.js');
6
5
 
7
- const defaultLanguage = assets.languages.default;
6
+ const generate = async () => {
7
+ const defaultLanguage = assets.languages.default;
8
8
 
9
- const messageBundle = path.normalize(`${process.argv[2]}/messagebundle.properties`);
10
- const messageBundleDefaultLanguage = path.normalize(`${process.argv[2]}/messagebundle_${defaultLanguage}.properties`);
11
- const outputFile = path.normalize(`${process.argv[3]}/i18n-defaults.js`);
9
+ const messageBundle = path.normalize(`${process.argv[2]}/messagebundle.properties`);
10
+ const messageBundleDefaultLanguage = path.normalize(`${process.argv[2]}/messagebundle_${defaultLanguage}.properties`);
11
+ const outputFile = path.normalize(`${process.argv[3]}/i18n-defaults.js`);
12
12
 
13
- if (!messageBundle || !outputFile) {
14
- return;
15
- }
13
+ if (!messageBundle || !outputFile) {
14
+ return;
15
+ }
16
16
 
17
- const properties = PropertiesReader(messageBundle)._properties;
17
+ const properties = PropertiesReader(messageBundle)._properties;
18
18
 
19
- let defaultLanguageProperties;
20
- try {
21
- defaultLanguageProperties = PropertiesReader(messageBundleDefaultLanguage)._properties;
22
- }
23
- catch (e) {}
19
+ let defaultLanguageProperties;
20
+ try {
21
+ defaultLanguageProperties = PropertiesReader(messageBundleDefaultLanguage)._properties;
22
+ } catch (e) {
23
+ }
24
24
 
25
25
 
26
- /*
27
- * Returns the single text object to enable single export.
28
- *
29
- * Example:
30
- * const ARIA_LABEL_CARD_CONTENT = {
31
- * key: "ARIA_LABEL_CARD_CONTENT",
32
- * defaultText: "Card Content",
33
- * };
34
- */
35
- const getTextInfo = (key, value, defaultLanguageValue) => {
36
- let effectiveValue = defaultLanguageValue || value;
37
- effectiveValue = effectiveValue.replace(/\"/g, "\\\""); // escape double quotes in translations
26
+ /*
27
+ * Returns the single text object to enable single export.
28
+ *
29
+ * Example:
30
+ * const ARIA_LABEL_CARD_CONTENT = {
31
+ * key: "ARIA_LABEL_CARD_CONTENT",
32
+ * defaultText: "Card Content",
33
+ * };
34
+ */
35
+ const getTextInfo = (key, value, defaultLanguageValue) => {
36
+ let effectiveValue = defaultLanguageValue || value;
37
+ effectiveValue = effectiveValue.replace(/\"/g, "\\\""); // escape double quotes in translations
38
38
 
39
- return `const ${key} = {key: "${key}", defaultText: "${effectiveValue}"};`;
40
- };
39
+ return `const ${key} = {key: "${key}", defaultText: "${effectiveValue}"};`;
40
+ };
41
41
 
42
- /*
43
- * Returns the complete content of i18n-defaults.js file:
44
- * (1) the single text objects
45
- * (2) the export statement at the end of the file
46
- *
47
- * Example:
48
- * export {
49
- * ARIA_LABEL_CARD_CONTENT,
50
- * }
51
- */
52
- const getOutputFileContent = (properties, defaultLanguageProperties) => {
53
- const textKeys = Object.keys(properties);
54
- const texts = textKeys.map(prop => getTextInfo(prop, properties[prop], defaultLanguageProperties && defaultLanguageProperties[prop])).join('');
42
+ /*
43
+ * Returns the complete content of i18n-defaults.js file:
44
+ * (1) the single text objects
45
+ * (2) the export statement at the end of the file
46
+ *
47
+ * Example:
48
+ * export {
49
+ * ARIA_LABEL_CARD_CONTENT,
50
+ * }
51
+ */
52
+ const getOutputFileContent = (properties, defaultLanguageProperties) => {
53
+ const textKeys = Object.keys(properties);
54
+ const texts = textKeys.map(prop => getTextInfo(prop, properties[prop], defaultLanguageProperties && defaultLanguageProperties[prop])).join('');
55
55
 
56
- return `${texts}
56
+ return `${texts}
57
57
  export {${textKeys.join()}};`;
58
- };
59
-
60
- /*
61
- * Writes the i18n-defaults.js.
62
- */
63
- const writeI18nDefaultsFile = (file, content) => {
64
- fs.writeFile(file, content, (err) => {
65
- if (err) {
66
- return console.log(err);
67
- }
58
+ };
68
59
 
69
- console.log(`[i18n]: "${file}" file has been created`);
70
- });
60
+ await fs.mkdir(path.dirname(outputFile), { recursive: true });
61
+ await fs.writeFile(outputFile, getOutputFileContent(properties, defaultLanguageProperties));
71
62
  };
72
63
 
73
- mkdirp.sync(path.dirname(outputFile));
74
- writeI18nDefaultsFile(outputFile, getOutputFileContent(properties, defaultLanguageProperties));
64
+ generate().then(() => {
65
+ console.log("i18n default file generated.");
66
+ });
@@ -8,18 +8,16 @@
8
8
  * The 2nd param './../dist/generated/assets/i18n' is where the JSON files would be written to.
9
9
  */
10
10
  const path = require("path");
11
- const glob = require("glob");
12
11
  const PropertiesReader = require('properties-reader');
13
- const fs = require('fs');
12
+ const fs = require('fs').promises;
14
13
  const assets = require('../../assets-meta.js');
15
- const mkdirp = require("mkdirp");
16
14
 
17
15
  const allLanguages = assets.languages.all;
18
16
 
19
17
  const messagesBundles = path.normalize(`${process.argv[2]}/messagebundle_*.properties`);
20
18
  const messagesJSONDist = path.normalize(`${process.argv[3]}`);
21
19
 
22
- const convertToJSON = (file) => {
20
+ const convertToJSON = async (file) => {
23
21
  const properties = PropertiesReader(file)._properties;
24
22
  const filename = path.basename(file, path.extname(file));
25
23
  const language = filename.match(/^messagebundle_(.*?)$/)[1];
@@ -29,14 +27,17 @@ const messagesJSONDist = path.normalize(`${process.argv[3]}`);
29
27
  }
30
28
  const outputFile = path.normalize(`${messagesJSONDist}/${filename}.json`);
31
29
 
32
- fs.writeFileSync(outputFile, JSON.stringify(properties));
30
+ return fs.writeFile(outputFile, JSON.stringify(properties));
33
31
  // console.log(`[i18n]: "${filename}.json" has been generated!`);
34
32
  };
35
33
 
36
- mkdirp.sync(messagesJSONDist);
37
- glob(messagesBundles, {}, (err, files) => {
38
- if (err) {
39
- return console.log("No messagebundle files found!");
40
- }
41
- files.forEach(convertToJSON);
34
+ const generate = async () => {
35
+ const { globby } = await import("globby");
36
+ await fs.mkdir(messagesJSONDist, { recursive: true });
37
+ const files = await globby(messagesBundles);
38
+ return Promise.all(files.map(convertToJSON));
39
+ };
40
+
41
+ generate().then(() => {
42
+ console.log("Message bundle JSON files generated.");
42
43
  });
@@ -38,7 +38,19 @@ module.exports = function (opts) {
38
38
 
39
39
  const filePath = `${targetFile}.js`;
40
40
  const defaultTheme = opts.includeDefaultTheme ? getDefaultThemeCode(opts.packageName) : ``;
41
- fs.writeFileSync(filePath, `${defaultTheme}export default {packageName:"${opts.packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}}`);
41
+
42
+ // it seems slower to read the old content, but writing the same content with no real changes
43
+ // (as in initial build and then watch mode) will cause an unnecessary dev server refresh
44
+ let oldContent = "";
45
+ try {
46
+ oldContent = fs.readFileSync(filePath).toString();
47
+ } catch (e) {
48
+ // file not found
49
+ }
50
+ const content = `${defaultTheme}export default {packageName:"${opts.packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}}`
51
+ if (content !== oldContent) {
52
+ fs.writeFileSync(filePath, content);
53
+ }
42
54
  }
43
55
  };
44
56
  };
@@ -28,7 +28,18 @@ module.exports = function (opts) {
28
28
  fileName: targetFile.substr(targetFile.lastIndexOf("themes")),
29
29
  content: css
30
30
  };
31
- fs.writeFileSync(filePath, JSON.stringify({_: data}));
31
+ // it seems slower to read the old content, but writing the same content with no real changes
32
+ // (as in initial build and then watch mode) will cause an unnecessary dev server refresh
33
+ let oldContent = "";
34
+ try {
35
+ oldContent = fs.readFileSync(filePath).toString();
36
+ } catch (e) {
37
+ // file not found
38
+ }
39
+ const content = JSON.stringify({_: data});
40
+ if (content !== oldContent) {
41
+ fs.writeFileSync(filePath, content);
42
+ }
32
43
  }
33
44
  };
34
45
  };
@@ -1,5 +1,8 @@
1
1
  import 'zx/globals';
2
2
 
3
+ // don't print executed commands and their output
4
+ $.verbose = false;
5
+
3
6
  const inputFiles = await globby("src/**/parameters-bundle.css");
4
7
 
5
8
  const restArgs = process.argv.slice(2);
@@ -1,20 +1,25 @@
1
- const fs = require("fs");
2
- const glob = require("glob");
1
+ const fs = require("fs").promises;
3
2
 
4
3
  const basePath = process.argv[2];
5
4
 
6
- const replaceGlobalCoreUsage = (srcPath) => {
5
+ const replaceGlobalCoreUsage = async (srcPath) => {
7
6
 
8
- const original = fs.readFileSync(srcPath).toString();
7
+ const original = (await fs.readFile(srcPath)).toString();
9
8
  let replaced = original.replace(/sap\.ui\.getCore\(\)/g, `Core`);
10
9
 
11
10
  if (original !== replaced) {
12
11
  replaced = `import Core from 'sap/ui/core/Core';
13
12
  ${replaced}`;
14
- fs.writeFileSync(srcPath, replaced);
13
+ return fs.writeFile(srcPath, replaced);
15
14
  }
16
15
  };
17
16
 
18
- const fileNames = glob.sync(basePath + "**/*.js");
19
- fileNames.forEach(replaceGlobalCoreUsage);
20
- console.log("Success: Replaced global core usage in:", basePath);
17
+ const generate = async () => {
18
+ const { globby } = await import("globby");
19
+ const fileNames = await globby(basePath + "**/*.js");
20
+ return Promise.all(fileNames.map(replaceGlobalCoreUsage).filter(x => !!x));
21
+ };
22
+
23
+ generate().then(() => {
24
+ console.log("Success: Replaced global core usage in:", basePath);
25
+ });
@@ -27,7 +27,7 @@ const replaceTagsAny = content => {
27
27
  // Replace bundle names and HTML tag names in test pages
28
28
  glob.sync(path.join(root, "/**/*.html")).forEach(file => {
29
29
  let content = String(fs.readFileSync(file));
30
- content = content.replace(/bundle\.(.*?)\.js/g, `bundle.scoped.$1.js`);
30
+ content = content.replace(/bundle\.(.*?)\.js/g, `../bundle.scoped.$1.js`);
31
31
  content = replaceTagsHTML(content);
32
32
  fs.writeFileSync(file, content);
33
33
  });
@@ -0,0 +1,63 @@
1
+ const child_process = require("child_process");
2
+ const { readFileSync } = require("fs");
3
+ const path = require("path");
4
+
5
+ // search for dev-server port
6
+ // start in current folder
7
+ // traversing upwards in case of mono repo tests and dev-server running in root folder of repository
8
+ let devServerFolder = process.cwd();
9
+ let devServerPort;
10
+ while (true) {
11
+ try {
12
+ devServerPort = readFileSync(path.join(devServerFolder, ".dev-server-port")).toString();
13
+ break; // found
14
+ } catch (e) {
15
+ // file not found
16
+ if (devServerFolder === path.dirname(devServerFolder)) {
17
+ break; // reached root folder "/"
18
+ }
19
+ devServerFolder = path.dirname(devServerFolder);
20
+ }
21
+ }
22
+
23
+ // check if we are in a monorepo and extract path from package.json
24
+ let packageRepositoryPath = "";
25
+ const pkg = require(path.join(process.cwd(), "package.json"));
26
+ packageRepositoryPath = pkg.repository.directory;
27
+
28
+ // construct base url
29
+ // use devServerPort if a dev server is running, otherwise let the baseUrl in the wdio config be used
30
+ // if a dev server is running in the root of a mono repo, append tha package path like this
31
+ // http://localhost:${devServerPort}/packages/main/
32
+ let baseUrl = "";
33
+ if (devServerPort) {
34
+ console.log(`Found port ${devServerPort} from '${path.join(devServerFolder, ".dev-server-port")}'`);
35
+ const devServerInRoot = !devServerFolder.includes(packageRepositoryPath);
36
+ if (devServerInRoot) {
37
+ baseUrl = `--base-url http://localhost:${devServerPort}/${packageRepositoryPath}/`;
38
+ } else {
39
+ baseUrl = `--base-url http://localhost:${devServerPort}/`;
40
+ }
41
+ }
42
+
43
+ if (!baseUrl) {
44
+ console.log("No dev server running, running tests served from `dist`, make sure it is up to date");
45
+ }
46
+
47
+ // add single spec parameter if passed
48
+ let spec = "";
49
+ if (process.argv.length === 3) {
50
+ const specFile = process.argv[2];
51
+ spec = `--spec ${specFile}`;
52
+ }
53
+
54
+ // more parameters - pass them to wdio
55
+ let restParams = "";
56
+ if (process.argv.length > 3) {
57
+ restParams = process.argv.slice(2).join(" ");
58
+ }
59
+
60
+ // run wdio with calculated parameters
61
+ const cmd = `yarn cross-env WDIO_LOG_LEVEL=error wdio config/wdio.conf.js ${spec} ${baseUrl} ${restParams}`;
62
+ console.log(`executing: ${cmd}`);
63
+ child_process.execSync(cmd, {stdio: 'inherit'});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-tools",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "UI5 Web Components: webcomponents.tools",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -21,20 +21,17 @@
21
21
  "directory": "packages/tools"
22
22
  },
23
23
  "dependencies": {
24
- "@openui5/sap.ui.core": "1.95.0",
25
- "@rollup/plugin-json": "^4.1.0",
26
- "@rollup/plugin-node-resolve": "^13.0.5",
27
- "@rollup/plugin-replace": "^3.0.0",
28
- "@wdio/cli": "^7.12.2",
29
- "@wdio/dot-reporter": "^7.10.1",
30
- "@wdio/local-runner": "^7.12.2",
31
- "@wdio/mocha-framework": "^7.12.2",
32
- "@wdio/spec-reporter": "^7.10.1",
24
+ "@wdio/cli": "^7.19.7",
25
+ "@wdio/devtools-service": "^7.19.7",
26
+ "@wdio/dot-reporter": "^7.19.7",
27
+ "@wdio/local-runner": "^7.19.7",
28
+ "@wdio/mocha-framework": "^7.19.7",
29
+ "@wdio/spec-reporter": "^7.19.7",
30
+ "@wdio/static-server-service": "^7.19.5",
33
31
  "chai": "^4.3.4",
34
32
  "child_process": "^1.0.2",
35
33
  "chokidar": "^3.5.1",
36
34
  "chokidar-cli": "^3.0.0",
37
- "cli-color": "^2.0.1",
38
35
  "command-line-args": "^5.1.1",
39
36
  "concurrently": "^6.0.0",
40
37
  "cross-env": "^7.0.3",
@@ -44,10 +41,10 @@
44
41
  "eslint-config-airbnb-base": "^14.2.1",
45
42
  "eslint-plugin-import": "^2.22.1",
46
43
  "esprima": "^4.0.1",
47
- "folder-hash": "^4.0.1",
48
44
  "getopts": "^2.3.0",
49
45
  "glob": "^7.1.6",
50
46
  "glob-parent": "^6.0.2",
47
+ "globby": "^13.1.1",
51
48
  "handlebars": "^4.7.7",
52
49
  "is-port-reachable": "^3.1.0",
53
50
  "jsdoc": "^3.6.6",
@@ -62,15 +59,15 @@
62
59
  "recursive-readdir": "^2.2.2",
63
60
  "resolve": "^1.20.0",
64
61
  "rimraf": "^3.0.2",
65
- "rollup": "^2.41.4",
66
- "rollup-plugin-livereload": "^2.0.0",
67
- "rollup-plugin-terser": "^7.0.2",
68
- "serve": "^12.0.0",
69
62
  "slash": "3.0.0",
70
- "wdio-chromedriver-service": "^7.0.0",
63
+ "vite": "^2.9.12",
64
+ "wdio-chromedriver-service": "^7.3.2",
71
65
  "zx": "^4.3.0"
72
66
  },
73
67
  "peerDependencies": {
74
68
  "chromedriver": "*"
69
+ },
70
+ "devDependencies": {
71
+ "yargs": "^17.5.1"
75
72
  }
76
73
  }
@@ -1,15 +0,0 @@
1
- const slash = require("slash");
2
-
3
- function emptyModulePlugin({ emptyModules }) {
4
- return {
5
- name: "ui5-dev-empty-module-plugin",
6
- load(id) {
7
- if (emptyModules.some(mod => slash(id).includes(mod))) {
8
- return `export default ""`;
9
- }
10
- return null;
11
- },
12
- };
13
- }
14
-
15
- module.exports = emptyModulePlugin;
@@ -1,150 +0,0 @@
1
- const process = require("process");
2
- const fs = require("fs");
3
- const os = require("os");
4
- const { nodeResolve } = require("@rollup/plugin-node-resolve");
5
- const { terser } = require("rollup-plugin-terser");
6
- const json = require("@rollup/plugin-json");
7
- const replace = require("@rollup/plugin-replace");
8
- const colors = require("cli-color");
9
- const livereload = require("rollup-plugin-livereload");
10
- const emptyModulePlugin = require("./rollup-plugins/empty-module.js");
11
-
12
- const packageFile = JSON.parse(fs.readFileSync("./package.json"));
13
- const packageName = packageFile.name;
14
-
15
- const warningsToSkip = [{
16
- warningCode: "THIS_IS_UNDEFINED",
17
- filePath: /.+zxing.+/,
18
- }];
19
-
20
- function ui5DevImportCheckerPlugin() {
21
- return {
22
- name: "ui5-dev-import-checker-plugin",
23
- transform(code, file) {
24
- const re = new RegExp(`^import.*"${packageName}/`);
25
- if (re.test(code)) {
26
- throw new Error(`illegal import in ${file}`);
27
- }
28
- },
29
- };
30
- }
31
-
32
- function onwarn(warning, warn) {
33
- // Skip warning for known false positives that will otherwise polute the log
34
- let skip = warningsToSkip.find(warningToSkip => {
35
- let loc, file;
36
- return warning.code === warningToSkip.warningCode
37
- && (loc = warning.loc)
38
- && (file = loc.file)
39
- && file.match(warningToSkip.filePath);
40
- });
41
- if (skip) {
42
- return;
43
- }
44
-
45
- // warn everything else
46
- warn( warning );
47
- }
48
-
49
- const reportedForPackages = new Set(); // sometimes writeBundle is called more than once per bundle -> suppress extra messages
50
- function ui5DevReadyMessagePlugin() {
51
- return {
52
- name: "ui5-dev-message-ready-plugin",
53
- writeBundle: (assets, bundle) => {
54
- if (reportedForPackages.has(packageName)) {
55
- return;
56
- }
57
- console.log(colors.blue(`${colors.bold(packageName)} successfully built!`));
58
-
59
- if (fs.existsSync(".port")) {
60
- const port = `${fs.readFileSync(".port")}`;
61
- if (port) {
62
- console.log(colors.blue(`Navigate to: ${colors.bold(`http://localhost:${port}/test-resources/pages/`)}`));
63
- }
64
- }
65
- reportedForPackages.add(packageName);
66
- },
67
- };
68
- }
69
-
70
- const getPlugins = () => {
71
- const plugins = [];
72
-
73
- if (process.env.DEV) {
74
- plugins.push(replace({
75
- values: {
76
- 'const DEV_MODE = false': 'const DEV_MODE = true',
77
- },
78
- preventAssignment: false,
79
- }));
80
- }
81
-
82
- if (process.env.DEV && !process.env.ENABLE_CLDR) {
83
- // Empty the CLDR assets file for better performance during development
84
- plugins.push(emptyModulePlugin({
85
- emptyModules: [
86
- "localization/dist/Assets.js",
87
- ],
88
- }));
89
- }
90
-
91
- plugins.push(ui5DevImportCheckerPlugin());
92
-
93
- plugins.push(json({
94
- include: [
95
- /.*assets\/.*\.json/,
96
- ],
97
- namedExports: false,
98
- }));
99
-
100
- plugins.push(nodeResolve());
101
-
102
- if (!process.env.DEV) {
103
- plugins.push(terser({
104
- numWorkers: 1,
105
- }));
106
- }
107
-
108
- const es6DevMain = process.env.DEV && packageName === "@ui5/webcomponents";
109
- if (es6DevMain && os.platform() !== "win32") {
110
- plugins.push(livereload({
111
- watch: [
112
- "dist/resources/bundle.esm.js",
113
- "dist/**/*.html",
114
- "dist/**/*.json",
115
- ],
116
- }));
117
- }
118
-
119
- if (process.env.DEV) {
120
- plugins.push(ui5DevReadyMessagePlugin());
121
- }
122
-
123
- return plugins;
124
- };
125
-
126
- const getES6Config = (input = "bundle.esm.js") => {
127
- return [{
128
- input,
129
- output: {
130
- dir: "dist/resources",
131
- format: "esm",
132
- sourcemap: true,
133
- },
134
- watch: {
135
- clearScreen: false,
136
- },
137
- plugins: getPlugins(),
138
- onwarn: onwarn,
139
- }];
140
- };
141
-
142
- let config = getES6Config();
143
-
144
- if (process.env.SCOPE) {
145
- if (fs.existsSync("bundle.scoped.esm.js")) {
146
- config = config.concat(getES6Config("bundle.scoped.esm.js"));
147
- }
148
- }
149
-
150
- module.exports = config;