@ui5/webcomponents-tools 0.0.0-b053ad005 → 0.0.0-b132dd7b9

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 (82) hide show
  1. package/CHANGELOG.md +1899 -0
  2. package/README.md +6 -9
  3. package/assets-meta.js +13 -8
  4. package/bin/dev.js +1 -5
  5. package/components-package/eslint.js +66 -2
  6. package/components-package/nps.js +130 -72
  7. package/components-package/postcss.components.js +1 -21
  8. package/components-package/postcss.themes.js +1 -26
  9. package/components-package/vite.config.js +9 -0
  10. package/components-package/wdio.js +77 -15
  11. package/icons-collection/nps.js +13 -14
  12. package/lib/amd-to-es6/index.js +102 -0
  13. package/lib/amd-to-es6/no-remaining-require.js +33 -0
  14. package/lib/cem/custom-elements-manifest.config.mjs +530 -0
  15. package/lib/cem/event.mjs +168 -0
  16. package/lib/cem/schema-internal.json +1422 -0
  17. package/lib/cem/schema.json +1098 -0
  18. package/lib/cem/types-internal.d.ts +808 -0
  19. package/lib/cem/types.d.ts +736 -0
  20. package/lib/cem/utils.mjs +423 -0
  21. package/lib/cem/validate.js +67 -0
  22. package/lib/copy-and-watch/index.js +24 -1
  23. package/lib/copy-list/index.js +17 -17
  24. package/lib/create-icons/index.js +127 -72
  25. package/lib/create-illustrations/index.js +153 -66
  26. package/lib/create-new-component/Component.js +74 -0
  27. package/lib/create-new-component/ComponentTemplate.js +12 -0
  28. package/lib/create-new-component/index.js +60 -101
  29. package/lib/css-processors/css-processor-components.mjs +78 -0
  30. package/lib/css-processors/css-processor-themes.mjs +74 -0
  31. package/lib/css-processors/scope-variables.mjs +49 -0
  32. package/lib/css-processors/shared.mjs +56 -0
  33. package/lib/dev-server/custom-hot-update-plugin.js +39 -0
  34. package/lib/dev-server/dev-server.mjs +66 -0
  35. package/lib/dev-server/virtual-index-html-plugin.js +56 -0
  36. package/lib/generate-js-imports/illustrations.js +86 -0
  37. package/lib/generate-json-imports/i18n.js +58 -67
  38. package/lib/generate-json-imports/themes.js +36 -46
  39. package/lib/hbs2lit/src/compiler.js +24 -4
  40. package/lib/hbs2lit/src/includesReplacer.js +5 -5
  41. package/lib/hbs2lit/src/litVisitor2.js +85 -22
  42. package/lib/hbs2lit/src/svgProcessor.js +12 -5
  43. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +39 -6
  44. package/lib/hbs2ui5/index.js +57 -24
  45. package/lib/i18n/defaults.js +66 -57
  46. package/lib/i18n/toJSON.js +12 -11
  47. package/lib/postcss-combine-duplicated-selectors/index.js +185 -0
  48. package/lib/remove-dev-mode/remove-dev-mode.mjs +37 -0
  49. package/lib/scoping/get-all-tags.js +11 -11
  50. package/lib/scoping/lint-src.js +8 -7
  51. package/lib/scoping/missing-dependencies.js +65 -0
  52. package/lib/scoping/report-tags-usage.js +28 -0
  53. package/lib/scoping/scope-test-pages.js +2 -1
  54. package/lib/test-runner/test-runner.js +71 -0
  55. package/package.json +36 -32
  56. package/tsconfig.json +18 -0
  57. package/components-package/rollup-plugins/empty-module.js +0 -15
  58. package/components-package/rollup.js +0 -237
  59. package/components-package/wdio.sync.js +0 -344
  60. package/lib/documentation/index.js +0 -165
  61. package/lib/documentation/templates/api-component-since.js +0 -3
  62. package/lib/documentation/templates/api-css-variables-section.js +0 -24
  63. package/lib/documentation/templates/api-events-section.js +0 -35
  64. package/lib/documentation/templates/api-methods-section.js +0 -26
  65. package/lib/documentation/templates/api-properties-section.js +0 -40
  66. package/lib/documentation/templates/api-slots-section.js +0 -28
  67. package/lib/documentation/templates/template.js +0 -38
  68. package/lib/esm-abs-to-rel/index.js +0 -54
  69. package/lib/hash/config.js +0 -10
  70. package/lib/hash/generate.js +0 -19
  71. package/lib/hash/upToDate.js +0 -31
  72. package/lib/jsdoc/config.json +0 -29
  73. package/lib/jsdoc/plugin.js +0 -2427
  74. package/lib/jsdoc/template/publish.js +0 -4101
  75. package/lib/polyfill-placeholder/index.js +0 -5
  76. package/lib/postcss-css-to-esm/index.js +0 -45
  77. package/lib/postcss-css-to-json/index.js +0 -36
  78. package/lib/postcss-new-files/index.js +0 -36
  79. package/lib/replace-global-core/index.js +0 -20
  80. package/lib/serve/index.js +0 -46
  81. package/lib/serve/serve.json +0 -3
  82. package/package-lock.json +0 -48
@@ -0,0 +1,65 @@
1
+ const fs = require("fs");
2
+ const glob = require("glob");
3
+ const path = require("path");
4
+ const process = require("process");
5
+
6
+ const projectPath = process.argv[2];
7
+
8
+ // gather all tags from all files
9
+ const tagsToFiles = new Map();
10
+ const filesToTags = new Map();
11
+
12
+ let files = [
13
+ ...glob.sync(path.join("packages/main/src/**/*.js")),
14
+ ...glob.sync(path.join("packages/fiori/src/**/*.js")),
15
+ ];
16
+ files.forEach(file => {
17
+ let matches = file.match(/([a-zA-Z0-9_]+)\.js$/);
18
+ const name = matches[1];
19
+
20
+ const content = `${fs.readFileSync(file)}`;
21
+ matches = content.match(/tag: "(.*?)",/);
22
+ if (matches) {
23
+ const tag = matches[1];
24
+ tagsToFiles.set(tag, name);
25
+ filesToTags.set(name, tag);
26
+ }
27
+ });
28
+
29
+ // Process the package
30
+ files = glob.sync(path.join(projectPath, "src/**/*.js"));
31
+ tagsToFiles.forEach((file, tag) => {
32
+ const sourcePath = path.join(projectPath, "src/", `${file}.js`);
33
+ if (!fs.existsSync(sourcePath)) {
34
+ return;
35
+ }
36
+ const sourceContent = `${fs.readFileSync(sourcePath)}`.split("\n").join(" ");
37
+
38
+ const hbsPath = path.join(projectPath, "src/", `${file}.hbs`);
39
+ const hbsContent = fs.existsSync(hbsPath) ? `${fs.readFileSync(hbsPath)}` : "";
40
+
41
+ const hbsPopoverPath = path.join(projectPath, "src/", `${file}Popover.hbs`);
42
+ const hbsPopoverContent = fs.existsSync(hbsPopoverPath) ? `${fs.readFileSync(hbsPopoverPath)}` : "";
43
+
44
+ // deps
45
+ let deps = [];
46
+ let matches = sourceContent.match(/static get dependencies\(\) \{\s+return \[(.*?)\]/);
47
+ if (matches) {
48
+ deps = matches[1].split(",").map(x => x.trim()).filter(x => !!x);
49
+ }
50
+
51
+ // tags
52
+ matches = [
53
+ ...hbsContent.matchAll(/<ui5-[a-z0-9-]+/g),
54
+ ...hbsPopoverContent.matchAll(/<ui5-[a-z0-9-]+/g),
55
+ ];
56
+ if (matches) {
57
+ matches.forEach(match => {
58
+ const tagUsed = match[0].substr(1);
59
+ const dep = tagsToFiles.get(tagUsed);
60
+ if (!deps.includes(dep)) {
61
+ console.log(`${file} used ${tagUsed}`);
62
+ }
63
+ });
64
+ }
65
+ });
@@ -0,0 +1,28 @@
1
+ const fs = require("fs");
2
+ const glob = require("glob");
3
+ const path = require("path");
4
+ const process = require("process");
5
+
6
+ // gather all tags from all files
7
+ const tags = new Set();
8
+ const files = glob.sync(path.join(process.argv[2], "src/**/*.js"));
9
+ files.forEach(file => {
10
+ const content = `${fs.readFileSync(file)}`;
11
+ const matches = content.match(/tag: "(.*?)",/);
12
+ if (matches) {
13
+ tags.add(matches[1]);
14
+ }
15
+ });
16
+
17
+ // report all usages of any tag within any file, which is not the tag definition and is not hasAttribute
18
+ files.forEach(file => {
19
+ const content = `${fs.readFileSync(file)}`;
20
+ const lines = content.split("\n");
21
+ lines.forEach(line => {
22
+ tags.forEach(tag => {
23
+ if (line.includes(`"${tag}"`) && !line.includes(`tag: "${tag}",`) && !line.includes(`hasAttribute("${tag}")`)) {
24
+ console.log(`${file}: ${line.trim()}`);
25
+ }
26
+ });
27
+ });
28
+ });
@@ -18,6 +18,7 @@ const replaceTagsHTML = content => {
18
18
 
19
19
  // Replace tags in any content
20
20
  const replaceTagsAny = content => {
21
+ console.log(tags.length);
21
22
  tags.forEach(tag => {
22
23
  content = content.replace(new RegExp(`(^|[^\-_A-Za-z0-9])(${tag})([^\-_A-Za-z0-9]|$)`, "g"), `$1$2-${suffix}$3`);
23
24
  });
@@ -27,7 +28,7 @@ const replaceTagsAny = content => {
27
28
  // Replace bundle names and HTML tag names in test pages
28
29
  glob.sync(path.join(root, "/**/*.html")).forEach(file => {
29
30
  let content = String(fs.readFileSync(file));
30
- content = content.replace(/bundle\.(.*?)\.js/g, `bundle.scoped.$1.js`);
31
+ content = content.replace("%VITE_BUNDLE_PATH%", "%VITE_BUNDLE_PATH_SCOPED%");
31
32
  content = replaceTagsHTML(content);
32
33
  fs.writeFileSync(file, content);
33
34
  });
@@ -0,0 +1,71 @@
1
+ const child_process = require("child_process");
2
+ const { readFileSync } = require("fs");
3
+ const path = require("path");
4
+ const fs = require("fs");
5
+
6
+ // search for dev-server port
7
+ // start in current folder
8
+ // traversing upwards in case of mono repo tests and dev-server running in root folder of repository
9
+ let devServerFolder = process.cwd();
10
+ let devServerPort;
11
+ while (true) {
12
+ try {
13
+ devServerPort = readFileSync(path.join(devServerFolder, ".dev-server-port")).toString();
14
+ break; // found
15
+ } catch (e) {
16
+ // file not found
17
+ if (devServerFolder === path.dirname(devServerFolder)) {
18
+ break; // reached root folder "/"
19
+ }
20
+ devServerFolder = path.dirname(devServerFolder);
21
+ }
22
+ }
23
+
24
+ // check if we are in a monorepo and extract path from package.json
25
+ let packageRepositoryPath = "";
26
+ const pkg = require(path.join(process.cwd(), "package.json"));
27
+ packageRepositoryPath = pkg.repository ? pkg.repository.directory : "";
28
+
29
+ // construct base url
30
+ // use devServerPort if a dev server is running, otherwise let the baseUrl in the wdio config be used
31
+ // if a dev server is running in the root of a mono repo, append tha package path like this
32
+ // http://localhost:${devServerPort}/packages/main/
33
+ let baseUrl = "";
34
+ if (devServerPort) {
35
+ console.log(`Found port ${devServerPort} from '${path.join(devServerFolder, ".dev-server-port")}'`);
36
+ const devServerInRoot = !devServerFolder.includes(packageRepositoryPath);
37
+ if (devServerInRoot) {
38
+ baseUrl = `--base-url http://localhost:${devServerPort}/${packageRepositoryPath}/`;
39
+ } else {
40
+ baseUrl = `--base-url http://localhost:${devServerPort}/`;
41
+ }
42
+ }
43
+
44
+ if (!baseUrl) {
45
+ console.log("No dev server running, running tests served from `dist`, make sure it is up to date");
46
+ }
47
+
48
+ // add single spec parameter if passed
49
+ let spec = "";
50
+ if (process.argv.length === 3) {
51
+ const specFile = process.argv[2];
52
+ spec = `--spec ${specFile}`;
53
+ }
54
+
55
+ // more parameters - pass them to wdio
56
+ let restParams = "";
57
+ if (process.argv.length > 3) {
58
+ restParams = process.argv.slice(2).join(" ");
59
+ }
60
+
61
+ let wdioConfig = "";
62
+ if (fs.existsSync("config/wdio.conf.cjs")) {
63
+ wdioConfig = "config/wdio.conf.cjs";
64
+ } else if (fs.existsSync("config/wdio.conf.js")) {
65
+ wdioConfig = "config/wdio.conf.js";
66
+ }
67
+
68
+ // run wdio with calculated parameters
69
+ const cmd = `yarn cross-env WDIO_LOG_LEVEL=error wdio ${wdioConfig} ${spec} ${baseUrl} ${restParams}`;
70
+ console.log(`executing: ${cmd}`);
71
+ child_process.execSync(cmd, {stdio: 'inherit'});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-tools",
3
- "version": "0.0.0-b053ad005",
3
+ "version": "0.0.0-b132dd7b9",
4
4
  "description": "UI5 Web Components: webcomponents.tools",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -21,61 +21,65 @@
21
21
  "directory": "packages/tools"
22
22
  },
23
23
  "dependencies": {
24
- "@babel/core": "^7.13.10",
25
- "@babel/preset-env": "^7.13.10",
26
- "@openui5/sap.ui.core": "1.95.0",
27
- "@rollup/plugin-babel": "^5.3.0",
28
- "@rollup/plugin-json": "^4.1.0",
29
- "@rollup/plugin-node-resolve": "^13.0.5",
30
- "@rollup/plugin-replace": "^3.0.0",
31
- "@rollup/plugin-url": "^6.0.0",
32
- "@wdio/cli": "^7.12.2",
33
- "@wdio/dot-reporter": "^7.10.1",
34
- "@wdio/local-runner": "^7.12.2",
35
- "@wdio/mocha-framework": "^7.12.2",
36
- "@wdio/spec-reporter": "^7.10.1",
37
- "@webcomponents/webcomponentsjs": "^2.5.0",
24
+ "@custom-elements-manifest/analyzer": "^0.10.4",
25
+ "@typescript-eslint/eslint-plugin": "^6.9.0",
26
+ "@typescript-eslint/parser": "^6.9.0",
27
+ "@wdio/cli": "^7.19.7",
28
+ "@wdio/dot-reporter": "^7.19.7",
29
+ "@wdio/local-runner": "^7.19.7",
30
+ "@wdio/mocha-framework": "^7.19.7",
31
+ "@wdio/spec-reporter": "^7.19.7",
32
+ "@wdio/static-server-service": "^7.19.5",
33
+ "ajv": "^8.12.0",
34
+ "cem-plugin-vs-code-custom-data-generator": "^1.4.2",
38
35
  "chai": "^4.3.4",
39
36
  "child_process": "^1.0.2",
40
- "chokidar": "^3.5.1",
37
+ "chokidar": "^3.6.0",
41
38
  "chokidar-cli": "^3.0.0",
42
- "colors": "^1.4.0",
43
39
  "command-line-args": "^5.1.1",
40
+ "comment-parser": "^1.4.0",
44
41
  "concurrently": "^6.0.0",
45
42
  "cross-env": "^7.0.3",
46
- "cssnano": "^4.1.11",
43
+ "custom-element-jet-brains-integration": "^1.4.4",
47
44
  "escodegen": "^2.0.0",
48
45
  "eslint": "^7.22.0",
49
46
  "eslint-config-airbnb-base": "^14.2.1",
50
- "eslint-plugin-import": "^2.22.1",
47
+ "eslint-plugin-import": "^2.31.0",
48
+ "eslint-plugin-jsx-no-leaked-values": "^0.1.24",
51
49
  "esprima": "^4.0.1",
52
- "folder-hash": "^4.0.1",
53
50
  "getopts": "^2.3.0",
54
51
  "glob": "^7.1.6",
55
52
  "glob-parent": "^6.0.2",
53
+ "globby": "^13.1.1",
56
54
  "handlebars": "^4.7.7",
57
55
  "is-port-reachable": "^3.1.0",
58
- "jsdoc": "^3.6.6",
59
56
  "json-beautify": "^1.1.1",
60
57
  "mkdirp": "^1.0.4",
61
58
  "nps": "^5.10.0",
62
- "postcss": "^8.2.10",
63
- "postcss-cli": "^9.0.1",
64
- "postcss-combine-duplicated-selectors": "^10.0.3",
65
- "postcss-import": "^14.0.0",
59
+ "postcss": "^8.4.5",
60
+ "postcss-cli": "^9.1.0",
61
+ "postcss-selector-parser": "^6.0.10",
62
+ "prompts": "^2.4.2",
66
63
  "properties-reader": "^2.2.0",
67
64
  "recursive-readdir": "^2.2.2",
68
65
  "resolve": "^1.20.0",
69
66
  "rimraf": "^3.0.2",
70
- "rollup": "^2.41.4",
71
- "rollup-plugin-filesize": "^9.1.1",
72
- "rollup-plugin-livereload": "^2.0.0",
73
- "rollup-plugin-terser": "^7.0.2",
74
- "serve": "^12.0.0",
75
67
  "slash": "3.0.0",
76
- "wdio-chromedriver-service": "^7.0.0"
68
+ "vite": "^5.4.8",
69
+ "vite-plugin-istanbul": "^6.0.2",
70
+ "wdio-chromedriver-service": "^7.3.2"
77
71
  },
78
72
  "peerDependencies": {
79
- "chromedriver": "*"
73
+ "chromedriver": "*",
74
+ "typescript": "^5.6.2"
75
+ },
76
+ "peerDependenciesMeta": {
77
+ "typescript": {
78
+ "optional": true
79
+ }
80
+ },
81
+ "devDependencies": {
82
+ "esbuild": "^0.25.0",
83
+ "yargs": "^17.5.1"
80
84
  }
81
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
+ }
@@ -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,237 +0,0 @@
1
- const process = require("process");
2
- const fs = require("fs");
3
- const os = require("os");
4
- const { babel } = require("@rollup/plugin-babel");
5
- const { nodeResolve } = require("@rollup/plugin-node-resolve");
6
- const url = require("@rollup/plugin-url");
7
- const { terser } = require("rollup-plugin-terser");
8
- const json = require("@rollup/plugin-json");
9
- const replace = require("@rollup/plugin-replace");
10
- const colors = require("colors/safe");
11
- const filesize = require("rollup-plugin-filesize");
12
- const livereload = require("rollup-plugin-livereload");
13
- const emptyModulePlugin = require("./rollup-plugins/empty-module.js");
14
-
15
- const packageFile = JSON.parse(fs.readFileSync("./package.json"));
16
- const packageName = packageFile.name;
17
- const DEPLOY_PUBLIC_PATH = process.env.DEPLOY_PUBLIC_PATH || "";
18
-
19
- const warningsToSkip = [{
20
- warningCode: "THIS_IS_UNDEFINED",
21
- filePath: /.+zxing.+/,
22
- }];
23
-
24
- function ui5DevImportCheckerPlugin() {
25
- return {
26
- name: "ui5-dev-import-checker-plugin",
27
- transform(code, file) {
28
- const re = new RegExp(`^import.*"${packageName}/`);
29
- if (re.test(code)) {
30
- throw new Error(`illegal import in ${file}`);
31
- }
32
- },
33
- };
34
- }
35
-
36
- function onwarn(warning, warn) {
37
- // Skip warning for known false positives that will otherwise polute the log
38
- let skip = warningsToSkip.find(warningToSkip => {
39
- let loc, file;
40
- return warning.code === warningToSkip.warningCode
41
- && (loc = warning.loc)
42
- && (file = loc.file)
43
- && file.match(warningToSkip.filePath);
44
- });
45
- if (skip) {
46
- return;
47
- }
48
-
49
- // warn everything else
50
- warn( warning );
51
- }
52
-
53
- const reportedForPackages = new Set(); // sometimes writeBundle is called more than once per bundle -> suppress extra messages
54
- function ui5DevReadyMessagePlugin() {
55
- return {
56
- name: "ui5-dev-message-ready-plugin",
57
- writeBundle: (assets, bundle) => {
58
- if (reportedForPackages.has(packageName)) {
59
- return;
60
- }
61
- console.log(colors.blue(`${colors.bold(packageName)} successfully built!`));
62
-
63
- if (fs.existsSync(".port")) {
64
- const port = `${fs.readFileSync(".port")}`;
65
- if (port) {
66
- console.log(colors.blue(`Navigate to: ${colors.bold(`http://localhost:${port}/test-resources/pages/`)}`));
67
- }
68
- }
69
- reportedForPackages.add(packageName);
70
- },
71
- };
72
- }
73
-
74
- const getPlugins = ({ transpile }) => {
75
- const plugins = [];
76
-
77
- if (process.env.DEV) {
78
- plugins.push(replace({
79
- values: {
80
- 'const DEV_MODE = false': 'const DEV_MODE = true',
81
- },
82
- preventAssignment: false,
83
- }));
84
- }
85
-
86
- if (process.env.DEV && !process.env.ENABLE_CLDR) {
87
- // Empty the CLDR assets file for better performance during development
88
- plugins.push(emptyModulePlugin({
89
- emptyModules: [
90
- "localization/dist/Assets.js",
91
- ],
92
- }));
93
- }
94
-
95
- if (!process.env.DEV) {
96
- plugins.push(filesize(
97
- {
98
- reporter(options, bundle, {
99
- minSize, gzipSize, brotliSize, bundleSize,
100
- fileName,
101
- // "showBeforeSizes: release"
102
- lastVersion,
103
- // "showBeforeSizes: "release" or "showBeforeSizes": "build"
104
- bundleSizeBefore, brotliSizeBefore, minSizeBefore, gzipSizeBefore,
105
- }) {
106
- // If a promise is returned, it will be awaited before rendering.
107
- return `${fileName.padEnd(35)} ${minSize} / gzipped: ${gzipSize}`;
108
- },
109
- },
110
-
111
- ));
112
- }
113
-
114
- const publicPath = DEPLOY_PUBLIC_PATH;
115
-
116
- plugins.push(ui5DevImportCheckerPlugin());
117
-
118
- if (!transpile) {
119
- plugins.push(json({
120
- include: [
121
- /.*assets\/.*\.json/,
122
- ],
123
- namedExports: false,
124
- }));
125
- }
126
-
127
- if (transpile) {
128
- plugins.push(url({
129
- limit: 0,
130
- include: [
131
- /.*assets\/.*\.json/,
132
- ],
133
- emitFiles: true,
134
- fileName: "[name].[hash][extname]",
135
- publicPath,
136
- }));
137
- }
138
-
139
- if (transpile) {
140
- plugins.push(babel({
141
- presets: ["@babel/preset-env"],
142
- exclude: /node_modules\/(?!(lit-html|@ui5\/webcomponents))/, // exclude all node_modules/ except lit-html and all starting with @ui5/webcomponents
143
- sourcemap: true,
144
- babelHelpers: "bundled",
145
- }));
146
- }
147
-
148
- plugins.push(nodeResolve());
149
-
150
- if (!process.env.DEV) {
151
- plugins.push(terser({
152
- numWorkers: 1,
153
- }));
154
- }
155
-
156
- const es6DevMain = process.env.DEV && !transpile && packageName === "@ui5/webcomponents";
157
- if (es6DevMain && os.platform() !== "win32") {
158
- plugins.push(livereload({
159
- watch: [
160
- "dist/resources/bundle.esm.js",
161
- "dist/**/*.html",
162
- "dist/**/*.json",
163
- ],
164
- }));
165
- }
166
-
167
- if (process.env.DEV) {
168
- plugins.push(ui5DevReadyMessagePlugin());
169
- }
170
-
171
- return plugins;
172
- };
173
-
174
- const getES6Config = (input = "bundle.esm.js") => {
175
- return [{
176
- input,
177
- output: {
178
- dir: "dist/resources",
179
- format: "esm",
180
- sourcemap: true,
181
- },
182
- moduleContext: id => {
183
- if (typeof id === "string" && id.includes("url-search-params-polyfill")) {
184
- // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
185
- return "window";
186
- }
187
- },
188
- watch: {
189
- clearScreen: false,
190
- },
191
- plugins: getPlugins({ transpile: false }),
192
- onwarn: onwarn,
193
- }];
194
- };
195
-
196
- const getES5Config = (input = "bundle.es5.js") => {
197
- return [{
198
- input,
199
- output: {
200
- dir: "dist/resources",
201
- format: "iife",
202
- inlineDynamicImports: true,
203
- name: "sap-ui-webcomponents-bundle",
204
- extend: "true", // Whether or not to extend the global variable defined by the name option in umd or iife formats.
205
- sourcemap: true,
206
- },
207
- moduleContext: id => {
208
- if (id.includes("url-search-params-polyfill")) {
209
- // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
210
- return "window";
211
- }
212
- },
213
- watch: {
214
- clearScreen: false,
215
- },
216
- plugins: getPlugins({ transpile: true }),
217
- onwarn: onwarn,
218
- }];
219
- };
220
-
221
- let config = getES6Config();
222
-
223
- if (process.env.ES5_BUILD && fs.existsSync("bundle.es5.js")) {
224
- config = config.concat(getES5Config());
225
- }
226
-
227
- if (process.env.SCOPE) {
228
- if (fs.existsSync("bundle.scoped.esm.js")) {
229
- config = config.concat(getES6Config("bundle.scoped.esm.js"));
230
-
231
- if (fs.existsSync("bundle.scoped.es5.js") && process.env.ES5_BUILD) {
232
- config = config.concat(getES5Config("bundle.scoped.es5.js"));
233
- }
234
- }
235
- }
236
-
237
- module.exports = config;