@ui5/webcomponents-tools 0.0.0-aeb93167c → 0.0.0-b93c2a321

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 (73) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/README.md +1 -1
  3. package/assets-meta.js +16 -1
  4. package/components-package/nps.js +37 -28
  5. package/components-package/postcss.themes.js +6 -3
  6. package/components-package/rollup-plugins/empty-module.js +15 -0
  7. package/components-package/rollup.js +108 -74
  8. package/components-package/wdio.js +53 -28
  9. package/components-package/wdio.sync.js +360 -0
  10. package/icons-collection/nps.js +52 -8
  11. package/lib/copy-and-watch/index.js +30 -4
  12. package/lib/copy-list/index.js +28 -0
  13. package/lib/create-icons/index.js +28 -8
  14. package/lib/create-illustrations/index.js +150 -0
  15. package/lib/create-new-component/index.js +12 -4
  16. package/lib/documentation/index.js +42 -20
  17. package/lib/documentation/templates/api-properties-section.js +3 -1
  18. package/lib/documentation/templates/template.js +2 -1
  19. package/lib/esm-abs-to-rel/index.js +54 -0
  20. package/lib/generate-json-imports/i18n.js +56 -18
  21. package/lib/generate-json-imports/themes.js +44 -13
  22. package/lib/hash/config.js +10 -0
  23. package/lib/hash/generate.js +19 -0
  24. package/lib/hash/upToDate.js +31 -0
  25. package/lib/hbs2lit/src/compiler.js +10 -1
  26. package/lib/hbs2lit/src/litVisitor2.js +31 -6
  27. package/lib/hbs2lit/src/svgProcessor.js +3 -3
  28. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +4 -11
  29. package/lib/i18n/toJSON.js +1 -1
  30. package/lib/jsdoc/config.json +1 -1
  31. package/lib/jsdoc/plugin.js +30 -1
  32. package/lib/jsdoc/template/publish.js +22 -2
  33. package/lib/postcss-combine-duplicated-selectors/index.js +178 -0
  34. package/lib/postcss-css-to-esm/index.js +19 -16
  35. package/lib/postcss-css-to-json/index.js +20 -11
  36. package/lib/postcss-new-files/index.js +36 -0
  37. package/lib/postcss-p/postcss-p.mjs +11 -0
  38. package/lib/replace-global-core/index.js +20 -0
  39. package/lib/scoping/lint-src.js +1 -1
  40. package/lib/scoping/missing-dependencies.js +65 -0
  41. package/lib/scoping/report-tags-usage.js +28 -0
  42. package/lib/serve/index.js +46 -0
  43. package/{components-package → lib/serve}/serve.json +0 -0
  44. package/package.json +46 -52
  45. package/bin/init-ui5-package.js +0 -3
  46. package/lib/init-package/index.js +0 -123
  47. package/lib/init-package/resources/.eslintignore +0 -3
  48. package/lib/init-package/resources/bundle.es5.js +0 -25
  49. package/lib/init-package/resources/bundle.esm.js +0 -34
  50. package/lib/init-package/resources/config/.eslintrc.js +0 -1
  51. package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
  52. package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
  53. package/lib/init-package/resources/config/rollup.config.js +0 -1
  54. package/lib/init-package/resources/config/wdio.conf.js +0 -1
  55. package/lib/init-package/resources/package-scripts.js +0 -11
  56. package/lib/init-package/resources/src/Assets.js +0 -5
  57. package/lib/init-package/resources/src/MyFirstComponent.hbs +0 -1
  58. package/lib/init-package/resources/src/MyFirstComponent.js +0 -56
  59. package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
  60. package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
  61. package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
  62. package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
  63. package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
  64. package/lib/init-package/resources/src/themes/MyFirstComponent.css +0 -11
  65. package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
  66. package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
  67. package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  68. package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
  69. package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  70. package/lib/init-package/resources/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
  71. package/lib/init-package/resources/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
  72. package/lib/init-package/resources/test/pages/index.html +0 -56
  73. package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
package/CHANGELOG.md CHANGED
@@ -3,6 +3,153 @@
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
+ ## [1.2.3](https://github.com/SAP/ui5-webcomponents/compare/v1.2.2...v1.2.3) (2022-03-23)
7
+
8
+ **Note:** Version bump only for package @ui5/webcomponents-tools
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.2.2](https://github.com/SAP/ui5-webcomponents/compare/v1.2.1...v1.2.2) (2022-03-22)
15
+
16
+
17
+ **Note:** Version bump only for package @ui5/webcomponents-tools
18
+
19
+
20
+
21
+
22
+
23
+ ## [1.2.1](https://github.com/SAP/ui5-webcomponents/compare/v1.2.0...v1.2.1) (2022-03-02)
24
+
25
+ **Note:** Version bump only for package @ui5/webcomponents-tools
26
+
27
+
28
+
29
+
30
+
31
+ # [1.2.0](https://github.com/SAP/ui5-webcomponents/compare/v1.1.2...v1.2.0) (2022-02-28)
32
+
33
+
34
+ ### Bug Fixes
35
+
36
+ * correct scoping issues with several components ([#4820](https://github.com/SAP/ui5-webcomponents/issues/4820)) ([621dc20](https://github.com/SAP/ui5-webcomponents/commit/621dc20))
37
+ * display methods in child components API ([#4792](https://github.com/SAP/ui5-webcomponents/issues/4792)) ([1929d08](https://github.com/SAP/ui5-webcomponents/commit/1929d08))
38
+
39
+
40
+ ### Features
41
+
42
+ * **jsdoc:** remove attr name for Object props ([#4680](https://github.com/SAP/ui5-webcomponents/issues/4680)) ([1741bd6](https://github.com/SAP/ui5-webcomponents/commit/1741bd6)), closes [#4674](https://github.com/SAP/ui5-webcomponents/issues/4674)
43
+
44
+
45
+
46
+
47
+
48
+ ## [1.1.2](https://github.com/SAP/ui5-webcomponents/compare/v1.1.1...v1.1.2) (2022-01-26)
49
+
50
+ **Note:** Version bump only for package @ui5/webcomponents-tools
51
+
52
+
53
+
54
+
55
+
56
+ ## [1.1.1](https://github.com/SAP/ui5-webcomponents/compare/v1.1.0...v1.1.1) (2022-01-24)
57
+
58
+ **Note:** Version bump only for package @ui5/webcomponents-tools
59
+
60
+
61
+
62
+
63
+
64
+ # [1.1.0](https://github.com/SAP/ui5-webcomponents/compare/v1.0.2...v1.1.0) (2022-01-21)
65
+
66
+
67
+ **Note:** Version bump only for package @ui5/webcomponents-tools
68
+
69
+
70
+
71
+
72
+
73
+ ## [1.0.2](https://github.com/SAP/ui5-webcomponents/compare/v1.0.1...v1.0.2) (2021-11-29)
74
+
75
+ **Note:** Version bump only for package @ui5/webcomponents-tools
76
+
77
+
78
+
79
+
80
+
81
+ ## [1.0.1](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0...v1.0.1) (2021-11-10)
82
+
83
+ **Note:** Version bump only for package @ui5/webcomponents-tools
84
+
85
+
86
+
87
+
88
+
89
+ # [1.0.0](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.16...v1.0.0) (2021-11-10)
90
+
91
+
92
+ **Note:** Version bump only for package @ui5/webcomponents-tools
93
+
94
+
95
+ # [1.0.0-rc.16](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.15...v1.0.0-rc.16) (2021-11-09)
96
+
97
+
98
+
99
+ ### Features
100
+
101
+ * **tools:** create an npm init script ([#4090](https://github.com/SAP/ui5-webcomponents/issues/4090)) ([5608e04](https://github.com/SAP/ui5-webcomponents/commit/5608e04))
102
+
103
+
104
+
105
+ # [1.0.0-rc.15](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.14...v1.0.0-rc.15) (2021-07-23)
106
+
107
+
108
+ ### Bug Fixes
109
+
110
+ * **tools:** fix build error on MacOS 11 from rollup-plugin-terser ([#3347](https://github.com/SAP/ui5-webcomponents/issues/3347)) ([59892c4](https://github.com/SAP/ui5-webcomponents/commit/59892c4)), closes [#2515](https://github.com/SAP/ui5-webcomponents/issues/2515)
111
+
112
+
113
+
114
+
115
+
116
+
117
+ # [1.0.0-rc.14](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.13...v1.0.0-rc.14) (2021-04-01)
118
+
119
+
120
+
121
+
122
+ # [1.0.0-rc.13](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.12...v1.0.0-rc.13) (2021-03-26)
123
+
124
+
125
+ **Note:** Version bump only for package @ui5/webcomponents-tools
126
+
127
+
128
+
129
+
130
+
131
+ # [1.0.0-rc.12](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.11...v1.0.0-rc.12) (2021-02-18)
132
+
133
+ **Note:** Version bump only for package @ui5/webcomponents-tools
134
+
135
+
136
+
137
+
138
+ # [1.0.0-rc.11](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.10...v1.0.0-rc.11) (2020-12-21)
139
+
140
+
141
+ ### Bug Fixes
142
+
143
+ * build error on MacOS 11 from rollup-plugin-terser ([#2515](https://github.com/SAP/ui5-webcomponents/issues/2515)) ([0629fac](https://github.com/SAP/ui5-webcomponents/commit/0629fac))
144
+
145
+
146
+
147
+
148
+
149
+ # [1.0.0-rc.10](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.9...v1.0.0-rc.10) (2020-11-12)
150
+
151
+
152
+
6
153
  # [1.0.0-rc.9](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.8...v1.0.0-rc.9) (2020-10-08)
7
154
 
8
155
 
package/README.md CHANGED
@@ -17,7 +17,7 @@ used by other UI5 Web Components packages, such as `main` and `fiori`.
17
17
  We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/master/SUPPORT.md#-content) on how to report an issue, or chat with us in the `#webcomponents` channel of the [OpenUI5 Community Slack](https://join-ui5-slack.herokuapp.com/).
18
18
 
19
19
  ## Contribute
20
- Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/master/CONTRIBUTING.md).
20
+ Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/master/docs/6-contributing/02-conventions-and-guidelines.md).
21
21
 
22
22
  ## License
23
23
  Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
package/assets-meta.js CHANGED
@@ -8,7 +8,12 @@ const assetsMeta = {
8
8
  "sap_belize_hcb",
9
9
  "sap_belize_hcw",
10
10
  "sap_fiori_3_hcb",
11
- "sap_fiori_3_hcw"
11
+ "sap_fiori_3_hcw",
12
+ "sap_horizon",
13
+ "sap_horizon_dark",
14
+ "sap_horizon_hcb",
15
+ "sap_horizon_hcw",
16
+ "sap_horizon_exp"
12
17
  ]
13
18
  },
14
19
  "languages": {
@@ -18,17 +23,25 @@ const assetsMeta = {
18
23
  "bg",
19
24
  "ca",
20
25
  "cs",
26
+ "cy",
21
27
  "da",
22
28
  "de",
23
29
  "el",
24
30
  "en",
31
+ "en_GB",
32
+ "en_US_sappsd",
33
+ "en_US_saprigi",
34
+ "en_US_saptrc",
25
35
  "es",
36
+ "es_MX",
26
37
  "et",
27
38
  "fi",
28
39
  "fr",
40
+ "fr_CA",
29
41
  "hi",
30
42
  "hr",
31
43
  "hu",
44
+ "in",
32
45
  "it",
33
46
  "iw",
34
47
  "ja",
@@ -40,6 +53,7 @@ const assetsMeta = {
40
53
  "nl",
41
54
  "no",
42
55
  "pl",
56
+ "pt_PT",
43
57
  "pt",
44
58
  "ro",
45
59
  "ru",
@@ -122,6 +136,7 @@ const assetsMeta = {
122
136
  "sk",
123
137
  "sl",
124
138
  "sr",
139
+ "sr_Latn",
125
140
  "sv",
126
141
  "th",
127
142
  "tr",
@@ -1,25 +1,31 @@
1
1
  const path = require("path");
2
+ const fs = require("fs");
2
3
 
3
4
  const LIB = path.join(__dirname, `../lib/`);
4
- const serveConfig = path.join(__dirname, `serve.json`);
5
- const polyfillDir = path.dirname(require.resolve("@webcomponents/webcomponentsjs"));
6
- const polyfillPath = path.join(polyfillDir, "/**/*.*");
5
+ const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
7
6
 
8
7
  const getScripts = (options) => {
9
8
 
10
- const port = options.port;
9
+ const port = options.port || 8080; // preferred port
10
+ const portStep = options.portStep || 1; // step to check for available ports, if preferred port is already used
11
+ let illustrations = options.illustrationsData || [];
12
+
13
+ illustrations = illustrations.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath}`);
14
+
15
+ let illustrationsScript = illustrations.join(" && ");
11
16
 
12
17
  const scripts = {
13
- clean: "rimraf dist",
18
+ clean: "rimraf dist && rimraf .port",
14
19
  lint: "eslint . --config config/.eslintrc.js",
15
- prepare: "nps clean build.templates build.styles build.i18n build.jsonImports copy build.samples",
20
+ lintfix: "eslint . --config config/.eslintrc.js --fix",
21
+ prepare: "nps clean build.templates build.styles build.i18n build.jsonImports copy build.samples build.illustrations",
16
22
  build: {
17
23
  default: "nps lint prepare build.bundle",
18
24
  templates: `mkdirp dist/generated/templates && node "${LIB}/hbs2ui5/index.js" -d src/ -o dist/generated/templates`,
19
25
  styles: {
20
26
  default: "nps build.styles.themes build.styles.components",
21
- themes: "postcss src/**/parameters-bundle.css --config config/postcss.themes --base src --dir dist/css/",
22
- components: "postcss src/themes/*.css --config config/postcss.components --base src --dir dist/css/",
27
+ themes: `node "${LIB}/postcss-p/postcss-p.mjs"`,
28
+ components: "postcss src/themes/*.css --config config/postcss.components --base src --dir dist/css/", // When updating this, also update the new files script
23
29
  },
24
30
  i18n: {
25
31
  default: "nps build.i18n.defaultsjs build.i18n.json",
@@ -31,43 +37,46 @@ const getScripts = (options) => {
31
37
  themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes dist/generated/json-imports`,
32
38
  i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n dist/generated/json-imports`,
33
39
  },
34
- bundle: "rollup --config config/rollup.config.js --environment ES5_BUILD",
40
+ bundle: "rollup --config config/rollup.config.js",
35
41
  samples: {
36
42
  default: "nps build.samples.api build.samples.docs",
37
43
  api: `jsdoc -c "${LIB}/jsdoc/config.json"`,
38
44
  docs: `node "${LIB}/documentation/index.js" dist/api.json`,
39
- }
45
+ },
46
+ illustrations: illustrationsScript
40
47
  },
41
48
  copy: {
42
- default: "nps copy.src copy.test copy.webcomponents-polyfill",
43
- src: `node "${LIB}/copy-and-watch/index.js" "src/**/*.js" dist/`,
44
- test: `node "${LIB}/copy-and-watch/index.js" "test/**/*.*" dist/test-resources`,
45
- "webcomponents-polyfill": `node "${LIB}/copy-and-watch/index.js" "${polyfillPath}" dist/webcomponentsjs/`,
49
+ default: "nps copy.src copy.props copy.test",
50
+ src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
51
+ props: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.properties" dist/`,
52
+ test: `node "${LIB}/copy-and-watch/index.js" --silent "test/**/*.*" dist/test-resources`,
46
53
  },
47
54
  watch: {
48
- default: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.bundle" "nps watch.styles"',
55
+ default: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.bundle" "nps watch.styles" "nps watch.i18n"',
49
56
  src: 'nps "copy.src --watch --safe --skip-initial-copy"',
57
+ props: 'nps "copy.props --watch --safe --skip-initial-copy"',
50
58
  test: 'nps "copy.test --watch --safe --skip-initial-copy"',
51
- bundle: "rollup --config config/rollup.config.js -w --environment ES5_BUILD,DEV,DEPLOY_PUBLIC_PATH:/resources/",
59
+ bundle: 'rollup --config config/rollup.config.js -w --environment DEV,DEPLOY_PUBLIC_PATH:/resources/',
52
60
  styles: {
53
61
  default: 'concurrently "nps watch.styles.themes" "nps watch.styles.components"',
54
62
  themes: 'nps "build.styles.themes -w"',
55
- components: 'nps "build.styles.components -w"',
63
+ components: {
64
+ default: 'concurrently "nps watch.styles.components.existingFiles" "nps watch.styles.components.newFiles"',
65
+ existingFiles: `nps "build.styles.components -w"`,
66
+ newFiles: `node "${LIB}/postcss-new-files/index.js" --srcFiles="src/themes/*.css"`,
67
+ },
56
68
  },
57
- templates: "chokidar \"src/**/*.hbs\" -c \"nps build.templates\"",
58
- samples: "chokidar \"test/**/*.sample.html\" -c \"nps build.samples\"",
69
+ templates: 'chokidar "src/**/*.hbs" -c "nps build.templates"',
70
+ samples: 'chokidar "test/**/*.sample.html" -c "nps build.samples"',
71
+ i18n: 'chokidar "src/i18n/messagebundle.properties" -c "nps build.i18n.defaultsjs"'
59
72
  },
60
73
  dev: 'concurrently "nps serve" "nps watch"',
61
74
  start: "nps prepare dev",
62
- serve: {
63
- default: "nps serve.prepare serve.run",
64
- prepare: `node "${LIB}/copy-and-watch/index.js" "${serveConfig}" dist/`,
65
- run: `serve --no-clipboard -l ${port} dist`,
66
- },
75
+ serve: `node "${LIB}/serve/index.js" --dir="dist/" --port=${port} --portStep=${portStep} --packageName="${packageName}"`,
67
76
  test: {
68
77
  // --success first - report the exit code of the test run (first command to finish), as serve is always terminated and has a non-0 exit code
69
78
  default: 'concurrently "nps serve" "nps test.run" --kill-others --success first',
70
- run: "cross-env WDIO_LOG_LEVEL=error FORCE_COLOR=0 wdio config/wdio.conf.js",
79
+ run: "cross-env WDIO_LOG_LEVEL=error wdio config/wdio.conf.js",
71
80
  spec: "wdio run config/wdio.conf.js",
72
81
  },
73
82
  startWithScope: "nps scope.prepare scope.dev",
@@ -77,12 +86,12 @@ const getScripts = (options) => {
77
86
  testPages: {
78
87
  default: "nps scope.testPages.clean scope.testPages.copy scope.testPages.replace",
79
88
  clean: "rimraf dist/test-resources/pages/scoped",
80
- copy: `node "${LIB}/copy-and-watch/index.js" "dist/test-resources/pages/**/*" dist/test-resources/scoped`,
89
+ copy: `node "${LIB}/copy-and-watch/index.js" --silent "dist/test-resources/pages/**/*" dist/test-resources/scoped`,
81
90
  replace: `node "${LIB}/scoping/scope-test-pages.js" dist/test-resources/scoped demo`,
82
91
  },
83
92
  dev: 'concurrently "nps serve" "nps scope.watch"',
84
- watch: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps scope.bundle" "nps watch.styles"',
85
- bundle: "rollup --config config/rollup.config.js -w --environment ES5_BUILD,DEV,SCOPE"
93
+ watch: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.props" "nps scope.bundle" "nps watch.styles"',
94
+ bundle: 'rollup --config config/rollup.config.js -w --environment DEV,SCOPE'
86
95
  }
87
96
  };
88
97
 
@@ -1,8 +1,11 @@
1
1
  const postcssImport = require('postcss-import');
2
- const combineSelectors = require('postcss-combine-duplicated-selectors');
2
+ const combineSelectors = require('../lib/postcss-combine-duplicated-selectors/index.js');
3
3
  const postcssCSStoJSON = require('../lib/postcss-css-to-json/index.js');
4
4
  const postcssCSStoESM = require('../lib/postcss-css-to-esm/index.js');
5
5
  const cssnano = require('cssnano');
6
+ const fs = require("fs");
7
+
8
+ const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
6
9
 
7
10
  module.exports = {
8
11
  plugins: [
@@ -17,7 +20,7 @@ module.exports = {
17
20
  },
18
21
  ]
19
22
  },),
20
- postcssCSStoJSON({toReplace: 'src'}),
21
- postcssCSStoESM({toReplace: 'src'}),
23
+ postcssCSStoJSON({toReplace: 'src', packageName}),
24
+ postcssCSStoESM({toReplace: 'src', packageName}),
22
25
  ]
23
26
  };
@@ -0,0 +1,15 @@
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,17 +1,24 @@
1
1
  const process = require("process");
2
2
  const fs = require("fs");
3
3
  const os = require("os");
4
- const { babel } = require("@rollup/plugin-babel");
5
4
  const { nodeResolve } = require("@rollup/plugin-node-resolve");
6
- const url = require("@rollup/plugin-url");
7
5
  const { terser } = require("rollup-plugin-terser");
8
- const notify = require('rollup-plugin-notify');
9
- const filesize = require('rollup-plugin-filesize');
10
- const livereload = require('rollup-plugin-livereload');
11
-
12
- const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
6
+ const json = require("@rollup/plugin-json");
7
+ const replace = require("@rollup/plugin-replace");
8
+ const colors = require("cli-color");
9
+ const filesize = require("rollup-plugin-filesize");
10
+ const livereload = require("rollup-plugin-livereload");
11
+ const emptyModulePlugin = require("./rollup-plugins/empty-module.js");
12
+
13
+ const packageFile = JSON.parse(fs.readFileSync("./package.json"));
14
+ const packageName = packageFile.name;
13
15
  const DEPLOY_PUBLIC_PATH = process.env.DEPLOY_PUBLIC_PATH || "";
14
16
 
17
+ const warningsToSkip = [{
18
+ warningCode: "THIS_IS_UNDEFINED",
19
+ filePath: /.+zxing.+/,
20
+ }];
21
+
15
22
  function ui5DevImportCheckerPlugin() {
16
23
  return {
17
24
  name: "ui5-dev-import-checker-plugin",
@@ -20,64 +27,122 @@ function ui5DevImportCheckerPlugin() {
20
27
  if (re.test(code)) {
21
28
  throw new Error(`illegal import in ${file}`);
22
29
  }
23
- }
30
+ },
24
31
  };
25
32
  }
26
33
 
27
- const getPlugins = ({ transpile }) => {
28
- const plugins = [];
29
- let publicPath = DEPLOY_PUBLIC_PATH;
34
+ function onwarn(warning, warn) {
35
+ // Skip warning for known false positives that will otherwise polute the log
36
+ let skip = warningsToSkip.find(warningToSkip => {
37
+ let loc, file;
38
+ return warning.code === warningToSkip.warningCode
39
+ && (loc = warning.loc)
40
+ && (file = loc.file)
41
+ && file.match(warningToSkip.filePath);
42
+ });
43
+ if (skip) {
44
+ return;
45
+ }
30
46
 
31
- if (!process.env.DEV) {
32
- plugins.push(filesize({
33
- render : function (options, bundle, { minSize, gzipSize, brotliSize, bundleSize }){
34
- return gzipSize;
47
+ // warn everything else
48
+ warn( warning );
49
+ }
50
+
51
+ const reportedForPackages = new Set(); // sometimes writeBundle is called more than once per bundle -> suppress extra messages
52
+ function ui5DevReadyMessagePlugin() {
53
+ return {
54
+ name: "ui5-dev-message-ready-plugin",
55
+ writeBundle: (assets, bundle) => {
56
+ if (reportedForPackages.has(packageName)) {
57
+ return;
58
+ }
59
+ console.log(colors.blue(`${colors.bold(packageName)} successfully built!`));
60
+
61
+ if (fs.existsSync(".port")) {
62
+ const port = `${fs.readFileSync(".port")}`;
63
+ if (port) {
64
+ console.log(colors.blue(`Navigate to: ${colors.bold(`http://localhost:${port}/test-resources/pages/`)}`));
65
+ }
35
66
  }
67
+ reportedForPackages.add(packageName);
68
+ },
69
+ };
70
+ }
71
+
72
+ const getPlugins = () => {
73
+ const plugins = [];
74
+
75
+ if (process.env.DEV) {
76
+ plugins.push(replace({
77
+ values: {
78
+ 'const DEV_MODE = false': 'const DEV_MODE = true',
79
+ },
80
+ preventAssignment: false,
81
+ }));
82
+ }
83
+
84
+ if (process.env.DEV && !process.env.ENABLE_CLDR) {
85
+ // Empty the CLDR assets file for better performance during development
86
+ plugins.push(emptyModulePlugin({
87
+ emptyModules: [
88
+ "localization/dist/Assets.js",
89
+ ],
36
90
  }));
37
91
  }
38
92
 
93
+ if (!process.env.DEV) {
94
+ plugins.push(filesize(
95
+ {
96
+ reporter(options, bundle, {
97
+ minSize, gzipSize, brotliSize, bundleSize,
98
+ fileName,
99
+ // "showBeforeSizes: release"
100
+ lastVersion,
101
+ // "showBeforeSizes: "release" or "showBeforeSizes": "build"
102
+ bundleSizeBefore, brotliSizeBefore, minSizeBefore, gzipSizeBefore,
103
+ }) {
104
+ // If a promise is returned, it will be awaited before rendering.
105
+ return `${fileName.padEnd(35)} ${minSize} / gzipped: ${gzipSize}`;
106
+ },
107
+ },
108
+
109
+ ));
110
+ }
111
+
112
+ const publicPath = DEPLOY_PUBLIC_PATH;
113
+
39
114
  plugins.push(ui5DevImportCheckerPlugin());
40
115
 
41
- plugins.push(url({
42
- limit: 0,
116
+ plugins.push(json({
43
117
  include: [
44
- /.*assets\/.*\.json/
118
+ /.*assets\/.*\.json/,
45
119
  ],
46
- emitFiles: true,
47
- fileName: "[name].[hash][extname]",
48
- publicPath,
120
+ namedExports: false,
49
121
  }));
50
122
 
51
-
52
- if (transpile) {
53
- plugins.push(babel({
54
- presets: ["@babel/preset-env"],
55
- exclude: /node_modules\/(?!(lit-html|@ui5\/webcomponents))/, //exclude all node_modules/ except lit-html and all starting with @ui5/webcomponents
56
- sourcemap: true,
57
- }));
58
- }
59
-
60
123
  plugins.push(nodeResolve());
61
124
 
62
125
  if (!process.env.DEV) {
63
- plugins.push(terser());
64
- }
65
-
66
- if (process.env.DEV) {
67
- plugins.push(notify());
126
+ plugins.push(terser({
127
+ numWorkers: 1,
128
+ }));
68
129
  }
69
130
 
70
- const es6DevMain = process.env.DEV && !transpile && packageName === "@ui5/webcomponents";
131
+ const es6DevMain = process.env.DEV && packageName === "@ui5/webcomponents";
71
132
  if (es6DevMain && os.platform() !== "win32") {
72
133
  plugins.push(livereload({
73
134
  watch: [
74
135
  "dist/resources/bundle.esm.js",
75
136
  "dist/**/*.html",
76
137
  "dist/**/*.json",
77
- ]
138
+ ],
78
139
  }));
79
140
  }
80
141
 
142
+ if (process.env.DEV) {
143
+ plugins.push(ui5DevReadyMessagePlugin());
144
+ }
145
+
81
146
  return plugins;
82
147
  };
83
148
 
@@ -87,58 +152,27 @@ const getES6Config = (input = "bundle.esm.js") => {
87
152
  output: {
88
153
  dir: "dist/resources",
89
154
  format: "esm",
90
- sourcemap: true
91
- },
92
- moduleContext: (id) => {
93
- if (id.includes("url-search-params-polyfill")) {
94
- // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
95
- return "window";
96
- }
97
- },
98
- watch: {
99
- clearScreen: false
100
- },
101
- plugins: getPlugins({transpile: false}),
102
- }];
103
- };
104
-
105
- const getES5Config = (input = "bundle.es5.js") => {
106
- return [ {
107
- input,
108
- output: {
109
- dir: "dist/resources",
110
- format: "iife",
111
- inlineDynamicImports: true,
112
- name: "sap-ui-webcomponents-bundle",
113
- extend: "true", // Whether or not to extend the global variable defined by the name option in umd or iife formats.
114
- sourcemap: true
155
+ sourcemap: true,
115
156
  },
116
- moduleContext: (id) => {
117
- if (id.includes("url-search-params-polyfill")) {
157
+ moduleContext: id => {
158
+ if (typeof id === "string" && id.includes("url-search-params-polyfill")) {
118
159
  // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
119
160
  return "window";
120
161
  }
121
162
  },
122
163
  watch: {
123
- clearScreen: false
164
+ clearScreen: false,
124
165
  },
125
- plugins: getPlugins({transpile: true}),
166
+ plugins: getPlugins(),
167
+ onwarn: onwarn,
126
168
  }];
127
169
  };
128
170
 
129
171
  let config = getES6Config();
130
172
 
131
- if (process.env.ES5_BUILD) {
132
- config = config.concat(getES5Config());
133
- }
134
-
135
173
  if (process.env.SCOPE) {
136
174
  if (fs.existsSync("bundle.scoped.esm.js")) {
137
175
  config = config.concat(getES6Config("bundle.scoped.esm.js"));
138
-
139
- if (fs.existsSync("bundle.scoped.es5.js") && process.env.ES5_BUILD) {
140
- config = config.concat(getES5Config("bundle.scoped.es5.js"));
141
- }
142
176
  }
143
177
  }
144
178