@ui5/webcomponents-tools 1.0.0-rc.8 → 1.0.2

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 (71) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/README.md +1 -1
  3. package/assets-meta.js +12 -1
  4. package/components-package/nps.js +62 -24
  5. package/components-package/postcss.themes.js +5 -2
  6. package/components-package/rollup-plugins/empty-module.js +15 -0
  7. package/components-package/rollup.js +155 -50
  8. package/components-package/wdio.js +37 -28
  9. package/components-package/wdio.sync.js +344 -0
  10. package/icons-collection/nps.js +53 -9
  11. package/lib/copy-and-watch/index.js +6 -4
  12. package/lib/copy-list/index.js +28 -0
  13. package/lib/create-icons/index.js +32 -14
  14. package/lib/create-illustrations/index.js +95 -0
  15. package/lib/create-new-component/index.js +16 -4
  16. package/lib/documentation/index.js +42 -20
  17. package/lib/esm-abs-to-rel/index.js +54 -0
  18. package/lib/generate-json-imports/i18n.js +59 -24
  19. package/lib/generate-json-imports/themes.js +44 -13
  20. package/lib/hash/config.js +10 -0
  21. package/lib/hash/generate.js +19 -0
  22. package/lib/hash/upToDate.js +31 -0
  23. package/lib/hbs2lit/src/litVisitor2.js +31 -6
  24. package/lib/hbs2lit/src/svgProcessor.js +3 -3
  25. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +5 -5
  26. package/lib/hbs2ui5/index.js +21 -5
  27. package/lib/i18n/toJSON.js +1 -1
  28. package/lib/jsdoc/config.json +1 -1
  29. package/lib/jsdoc/plugin.js +21 -1
  30. package/lib/jsdoc/template/publish.js +9 -0
  31. package/lib/polyfill-placeholder/index.js +5 -0
  32. package/lib/postcss-css-to-esm/index.js +19 -16
  33. package/lib/postcss-css-to-json/index.js +20 -11
  34. package/lib/postcss-new-files/index.js +36 -0
  35. package/lib/replace-global-core/index.js +20 -0
  36. package/lib/scoping/get-all-tags.js +44 -0
  37. package/lib/scoping/lint-src.js +31 -0
  38. package/lib/scoping/scope-test-pages.js +40 -0
  39. package/lib/serve/index.js +46 -0
  40. package/{components-package → lib/serve}/serve.json +0 -0
  41. package/package-lock.json +48 -0
  42. package/package.json +54 -54
  43. package/bin/init-ui5-package.js +0 -3
  44. package/lib/init-package/index.js +0 -114
  45. package/lib/init-package/resources/.eslintignore +0 -3
  46. package/lib/init-package/resources/bundle.es5.js +0 -25
  47. package/lib/init-package/resources/bundle.esm.js +0 -34
  48. package/lib/init-package/resources/config/.eslintrc.js +0 -1
  49. package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
  50. package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
  51. package/lib/init-package/resources/config/rollup.config.js +0 -1
  52. package/lib/init-package/resources/config/wdio.conf.js +0 -1
  53. package/lib/init-package/resources/package-scripts.js +0 -11
  54. package/lib/init-package/resources/src/Assets.js +0 -5
  55. package/lib/init-package/resources/src/Demo.hbs +0 -1
  56. package/lib/init-package/resources/src/Demo.js +0 -56
  57. package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
  58. package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
  59. package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
  60. package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
  61. package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
  62. package/lib/init-package/resources/src/themes/Demo.css +0 -11
  63. package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
  64. package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
  65. package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  66. package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
  67. package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  68. package/lib/init-package/resources/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
  69. package/lib/init-package/resources/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
  70. package/lib/init-package/resources/test/pages/index.html +0 -51
  71. package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
package/CHANGELOG.md CHANGED
@@ -3,6 +3,100 @@
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.0.2](https://github.com/SAP/ui5-webcomponents/compare/v1.0.1...v1.0.2) (2021-11-29)
7
+
8
+ **Note:** Version bump only for package @ui5/webcomponents-tools
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.0.1](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0...v1.0.1) (2021-11-10)
15
+
16
+ **Note:** Version bump only for package @ui5/webcomponents-tools
17
+
18
+
19
+
20
+
21
+
22
+ # [1.0.0](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.16...v1.0.0) (2021-11-10)
23
+
24
+
25
+ **Note:** Version bump only for package @ui5/webcomponents-tools
26
+
27
+
28
+ # [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)
29
+
30
+
31
+
32
+ ### Features
33
+
34
+ * **tools:** create an npm init script ([#4090](https://github.com/SAP/ui5-webcomponents/issues/4090)) ([5608e04](https://github.com/SAP/ui5-webcomponents/commit/5608e04))
35
+
36
+
37
+
38
+ # [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)
39
+
40
+
41
+ ### Bug Fixes
42
+
43
+ * **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)
44
+
45
+
46
+
47
+
48
+
49
+
50
+ # [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)
51
+
52
+
53
+
54
+
55
+ # [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)
56
+
57
+
58
+ **Note:** Version bump only for package @ui5/webcomponents-tools
59
+
60
+
61
+
62
+
63
+
64
+ # [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)
65
+
66
+ **Note:** Version bump only for package @ui5/webcomponents-tools
67
+
68
+
69
+
70
+
71
+ # [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)
72
+
73
+
74
+ ### Bug Fixes
75
+
76
+ * 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))
77
+
78
+
79
+
80
+
81
+
82
+ # [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)
83
+
84
+
85
+
86
+ # [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)
87
+
88
+
89
+ ### Features
90
+
91
+ * **framework:** dynamic custom elements scoping ([#2091](https://github.com/SAP/ui5-webcomponents/issues/2091)) ([3588542](https://github.com/SAP/ui5-webcomponents/commit/3588542))
92
+ * **framework:** make assets path configurable ([#2214](https://github.com/SAP/ui5-webcomponents/issues/2214)) ([16c46da](https://github.com/SAP/ui5-webcomponents/commit/16c46da))
93
+ * **tools:** ES5 build supports dynamic imports (inlined) ([#2063](https://github.com/SAP/ui5-webcomponents/issues/2063)) ([3fe5cac](https://github.com/SAP/ui5-webcomponents/commit/3fe5cac))
94
+ * **tools:** process HBS files in nested directories ([#2067](https://github.com/SAP/ui5-webcomponents/issues/2067)) ([13f1d2a](https://github.com/SAP/ui5-webcomponents/commit/13f1d2a)), closes [#2065](https://github.com/SAP/ui5-webcomponents/issues/2065)
95
+
96
+
97
+
98
+
99
+
6
100
  # [1.0.0-rc.8](https://github.com/SAP/ui5-webcomponents/compare/v1.0.0-rc.7...v1.0.0-rc.8) (2020-07-30)
7
101
 
8
102
 
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,9 @@ 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_exp"
12
14
  ]
13
15
  },
14
16
  "languages": {
@@ -18,17 +20,25 @@ const assetsMeta = {
18
20
  "bg",
19
21
  "ca",
20
22
  "cs",
23
+ "cy",
21
24
  "da",
22
25
  "de",
23
26
  "el",
24
27
  "en",
28
+ "en_GB",
29
+ "en_US_sappsd",
30
+ "en_US_saprigi",
31
+ "en_US_saptrc",
25
32
  "es",
33
+ "es_MX",
26
34
  "et",
27
35
  "fi",
28
36
  "fr",
37
+ "fr_CA",
29
38
  "hi",
30
39
  "hr",
31
40
  "hu",
41
+ "in",
32
42
  "it",
33
43
  "iw",
34
44
  "ja",
@@ -40,6 +50,7 @@ const assetsMeta = {
40
50
  "nl",
41
51
  "no",
42
52
  "pl",
53
+ "pt_PT",
43
54
  "pt",
44
55
  "ro",
45
56
  "ru",
@@ -1,25 +1,36 @@
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
5
  const polyfillDir = path.dirname(require.resolve("@webcomponents/webcomponentsjs"));
6
- const polyfillPath = path.join(polyfillDir, "/**/*.*");
6
+ const polyfillPath = path.join(polyfillDir, "{*.js,*.map,*.md,bundles/**/*.*}");
7
+ const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
7
8
 
8
9
  const getScripts = (options) => {
9
10
 
10
- const port = options.port;
11
+ const port = options.port || 8080; // preferred port
12
+ const portStep = options.portStep || 1; // step to check for available ports, if preferred port is already used
13
+ let illustrations = options.illustrationsData || [];
14
+
15
+ illustrations = illustrations.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath}`);
16
+
17
+ let illustrationsScript = illustrations.join(" && ");
11
18
 
12
19
  const scripts = {
13
- clean: "rimraf dist",
20
+ clean: "rimraf dist && rimraf .port",
14
21
  lint: "eslint . --config config/.eslintrc.js",
15
- prepare: "nps clean build.templates build.styles build.i18n build.jsonImports copy build.samples",
22
+ lintfix: "eslint . --config config/.eslintrc.js --fix",
23
+ prepare: {
24
+ default: "nps clean build.templates build.styles build.i18n build.jsonImports copy build.samples build.illustrations",
25
+ es5: "nps clean build.templates build.styles build.i18n build.jsonImports copy.es5 build.samples build.illustrations"
26
+ },
16
27
  build: {
17
- default: "nps lint prepare build.bundle",
28
+ default: "nps lint prepare.es5 build.bundle",
18
29
  templates: `mkdirp dist/generated/templates && node "${LIB}/hbs2ui5/index.js" -d src/ -o dist/generated/templates`,
19
30
  styles: {
20
31
  default: "nps build.styles.themes build.styles.components",
21
32
  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/",
33
+ components: "postcss src/themes/*.css --config config/postcss.components --base src --dir dist/css/", // When updating this, also update the new files script
23
34
  },
24
35
  i18n: {
25
36
  default: "nps build.i18n.defaultsjs build.i18n.json",
@@ -36,40 +47,67 @@ const getScripts = (options) => {
36
47
  default: "nps build.samples.api build.samples.docs",
37
48
  api: `jsdoc -c "${LIB}/jsdoc/config.json"`,
38
49
  docs: `node "${LIB}/documentation/index.js" dist/api.json`,
39
- }
50
+ },
51
+ illustrations: illustrationsScript
40
52
  },
41
53
  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/`,
54
+ default: "nps copy.src copy.props copy.test copy.webcomponents-polyfill-placeholder",
55
+ es5: "nps copy.src copy.props copy.test copy.webcomponents-polyfill",
56
+ src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
57
+ props: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.properties" dist/`,
58
+ test: `node "${LIB}/copy-and-watch/index.js" --silent "test/**/*.*" dist/test-resources`,
59
+ "webcomponents-polyfill": `node "${LIB}/copy-and-watch/index.js" --silent "${polyfillPath}" dist/webcomponentsjs/`,
60
+ "webcomponents-polyfill-placeholder": `node "${LIB}/polyfill-placeholder/index.js"`
46
61
  },
47
62
  watch: {
48
- default: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.bundle" "nps watch.styles"',
63
+ default: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.bundle" "nps watch.styles" "nps watch.i18n"',
64
+ es5: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.bundle.es5" "nps watch.styles" "nps watch.i18n"',
49
65
  src: 'nps "copy.src --watch --safe --skip-initial-copy"',
66
+ props: 'nps "copy.props --watch --safe --skip-initial-copy"',
50
67
  test: 'nps "copy.test --watch --safe --skip-initial-copy"',
51
- bundle: "rollup --config config/rollup.config.js -w --environment ES5_BUILD,DEV",
68
+ bundle: {
69
+ default: 'rollup --config config/rollup.config.js -w --environment DEV,DEPLOY_PUBLIC_PATH:/resources/',
70
+ es5: 'rollup --config config/rollup.config.js -w --environment ES5_BUILD,DEV,DEPLOY_PUBLIC_PATH:/resources/'
71
+ },
52
72
  styles: {
53
73
  default: 'concurrently "nps watch.styles.themes" "nps watch.styles.components"',
54
74
  themes: 'nps "build.styles.themes -w"',
55
- components: 'nps "build.styles.components -w"',
75
+ components: {
76
+ default: 'concurrently "nps watch.styles.components.existingFiles" "nps watch.styles.components.newFiles"',
77
+ existingFiles: `nps "build.styles.components -w"`,
78
+ newFiles: `node "${LIB}/postcss-new-files/index.js" --srcFiles="src/themes/*.css"`,
79
+ },
56
80
  },
57
- templates: "chokidar \"src/**/*.hbs\" -c \"nps build.templates\"",
58
- samples: "chokidar \"test/**/*.sample.html\" -c \"nps build.samples\"",
81
+ templates: 'chokidar "src/**/*.hbs" -c "nps build.templates"',
82
+ samples: 'chokidar "test/**/*.sample.html" -c "nps build.samples"',
83
+ i18n: 'chokidar "src/i18n/messagebundle.properties" -c "nps build.i18n.defaultsjs"'
59
84
  },
60
- dev: 'concurrently "nps serve" "nps watch"',
61
- 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`,
85
+ dev: {
86
+ default: 'concurrently "nps serve" "nps watch"',
87
+ es5: 'concurrently "nps serve" "nps watch.es5"'
66
88
  },
89
+ start: "nps prepare dev",
90
+ serve: `node "${LIB}/serve/index.js" --dir="dist/" --port=${port} --portStep=${portStep} --packageName="${packageName}"`,
67
91
  test: {
68
92
  // --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
93
  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",
94
+ run: "cross-env WDIO_LOG_LEVEL=error wdio config/wdio.conf.js",
71
95
  spec: "wdio run config/wdio.conf.js",
72
96
  },
97
+ startWithScope: "nps scope.prepare scope.dev",
98
+ scope: {
99
+ prepare: "nps scope.lint prepare scope.testPages",
100
+ lint: `node "${LIB}/scoping/lint-src.js"`,
101
+ testPages: {
102
+ default: "nps scope.testPages.clean scope.testPages.copy scope.testPages.replace",
103
+ clean: "rimraf dist/test-resources/pages/scoped",
104
+ copy: `node "${LIB}/copy-and-watch/index.js" --silent "dist/test-resources/pages/**/*" dist/test-resources/scoped`,
105
+ replace: `node "${LIB}/scoping/scope-test-pages.js" dist/test-resources/scoped demo`,
106
+ },
107
+ dev: 'concurrently "nps serve" "nps scope.watch"',
108
+ watch: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.props" "nps scope.bundle" "nps watch.styles"',
109
+ bundle: 'rollup --config config/rollup.config.js -w --environment ES5_BUILD,DEV,SCOPE'
110
+ }
73
111
  };
74
112
 
75
113
  return scripts;
@@ -3,6 +3,9 @@ const combineSelectors = require('postcss-combine-duplicated-selectors');
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,27 @@
1
- const babel = require("rollup-plugin-babel");
2
1
  const process = require("process");
3
- const resolve = require("rollup-plugin-node-resolve");
4
- const url = require("rollup-plugin-url");
5
- const { terser } = require("rollup-plugin-terser");
6
- const notify = require('rollup-plugin-notify');
7
- const filesize = require('rollup-plugin-filesize');
8
- const livereload = require('rollup-plugin-livereload');
9
- const os = require("os");
10
2
  const fs = require("fs");
11
-
12
- const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
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 commonjs = require("@rollup/plugin-commonjs");
11
+ const colors = require("colors/safe");
12
+ const filesize = require("rollup-plugin-filesize");
13
+ const livereload = require("rollup-plugin-livereload");
14
+ const emptyModulePlugin = require("./rollup-plugins/empty-module.js");
15
+
16
+ const packageFile = JSON.parse(fs.readFileSync("./package.json"));
17
+ const packageName = packageFile.name;
13
18
  const DEPLOY_PUBLIC_PATH = process.env.DEPLOY_PUBLIC_PATH || "";
14
19
 
20
+ const warningsToSkip = [{
21
+ warningCode: "THIS_IS_UNDEFINED",
22
+ filePath: /.+zxing.+/,
23
+ }];
24
+
15
25
  function ui5DevImportCheckerPlugin() {
16
26
  return {
17
27
  name: "ui5-dev-import-checker-plugin",
@@ -20,51 +30,129 @@ function ui5DevImportCheckerPlugin() {
20
30
  if (re.test(code)) {
21
31
  throw new Error(`illegal import in ${file}`);
22
32
  }
23
- }
33
+ },
34
+ };
35
+ }
36
+
37
+ function onwarn(warning, warn) {
38
+ // Skip warning for known false positives that will otherwise polute the log
39
+ let skip = warningsToSkip.find(warningToSkip => {
40
+ let loc, file;
41
+ return warning.code === warningToSkip.warningCode
42
+ && (loc = warning.loc)
43
+ && (file = loc.file)
44
+ && file.match(warningToSkip.filePath);
45
+ });
46
+ if (skip) {
47
+ return;
48
+ }
49
+
50
+ // warn everything else
51
+ warn( warning );
52
+ }
53
+
54
+ const reportedForPackages = new Set(); // sometimes writeBundle is called more than once per bundle -> suppress extra messages
55
+ function ui5DevReadyMessagePlugin() {
56
+ return {
57
+ name: "ui5-dev-message-ready-plugin",
58
+ writeBundle: (assets, bundle) => {
59
+ if (reportedForPackages.has(packageName)) {
60
+ return;
61
+ }
62
+ console.log(colors.blue(`${colors.bold(packageName)} successfully built!`));
63
+
64
+ if (fs.existsSync(".port")) {
65
+ const port = `${fs.readFileSync(".port")}`;
66
+ if (port) {
67
+ console.log(colors.blue(`Navigate to: ${colors.bold(`http://localhost:${port}/test-resources/pages/`)}`));
68
+ }
69
+ }
70
+ reportedForPackages.add(packageName);
71
+ },
24
72
  };
25
73
  }
26
74
 
27
75
  const getPlugins = ({ transpile }) => {
28
76
  const plugins = [];
29
- let publicPath = DEPLOY_PUBLIC_PATH || "/resources/";
30
77
 
31
- if (!process.env.DEV) {
32
- plugins.push(filesize({
33
- render : function (options, bundle, { minSize, gzipSize, brotliSize, bundleSize }){
34
- return gzipSize;
35
- }
78
+ if (process.env.DEV) {
79
+ plugins.push(replace({
80
+ values: {
81
+ 'const DEV_MODE = false': 'const DEV_MODE = true',
82
+ },
83
+ preventAssignment: false,
84
+ }));
85
+ }
86
+
87
+ if (process.env.DEV && !process.env.ENABLE_CLDR) {
88
+ // Empty the CLDR assets file for better performance during development
89
+ plugins.push(emptyModulePlugin({
90
+ emptyModules: [
91
+ "localization/dist/Assets.js",
92
+ ],
36
93
  }));
37
94
  }
38
95
 
96
+ if (!process.env.DEV) {
97
+ plugins.push(filesize(
98
+ {
99
+ reporter(options, bundle, {
100
+ minSize, gzipSize, brotliSize, bundleSize,
101
+ fileName,
102
+ // "showBeforeSizes: release"
103
+ lastVersion,
104
+ // "showBeforeSizes: "release" or "showBeforeSizes": "build"
105
+ bundleSizeBefore, brotliSizeBefore, minSizeBefore, gzipSizeBefore,
106
+ }) {
107
+ // If a promise is returned, it will be awaited before rendering.
108
+ return `${fileName.padEnd(35)} ${minSize} / gzipped: ${gzipSize}`;
109
+ },
110
+ },
111
+
112
+ ));
113
+ }
114
+
115
+ const publicPath = DEPLOY_PUBLIC_PATH;
116
+
39
117
  plugins.push(ui5DevImportCheckerPlugin());
40
118
 
41
- plugins.push(url({
42
- limit: 0,
43
- include: [
44
- /.*assets\/.*\.json/
45
- ],
46
- emitFiles: true,
47
- fileName: "[name].[hash][extname]",
48
- publicPath,
49
- }));
119
+ if (!transpile) {
120
+ plugins.push(json({
121
+ include: [
122
+ /.*assets\/.*\.json/,
123
+ ],
124
+ namedExports: false,
125
+ }));
126
+ }
50
127
 
128
+ if (transpile) {
129
+ plugins.push(url({
130
+ limit: 0,
131
+ include: [
132
+ /.*assets\/.*\.json/,
133
+ ],
134
+ emitFiles: true,
135
+ fileName: "[name].[hash][extname]",
136
+ publicPath,
137
+ }));
138
+ }
51
139
 
52
140
  if (transpile) {
141
+ plugins.push(commonjs());
53
142
  plugins.push(babel({
54
143
  presets: ["@babel/preset-env"],
55
- exclude: "node_modules/**",
56
- sourcemap: true,
144
+ exclude: /node_modules\/(?!(lit-html|@ui5\/webcomponents))/, // exclude all node_modules/ except lit-html and all starting with @ui5/webcomponents
145
+ sourcemap: false,
146
+ babelHelpers: "bundled",
57
147
  }));
58
148
  }
59
149
 
60
- plugins.push(resolve());
150
+ plugins.push(nodeResolve());
61
151
 
62
152
  if (!process.env.DEV) {
63
- plugins.push(terser());
64
- }
65
-
66
- if (process.env.DEV) {
67
- plugins.push(notify());
153
+ plugins.push(terser({
154
+ numWorkers: 1,
155
+ }));
68
156
  }
69
157
 
70
158
  const es6DevMain = process.env.DEV && !transpile && packageName === "@ui5/webcomponents";
@@ -74,61 +162,78 @@ const getPlugins = ({ transpile }) => {
74
162
  "dist/resources/bundle.esm.js",
75
163
  "dist/**/*.html",
76
164
  "dist/**/*.json",
77
- ]
165
+ ],
78
166
  }));
79
167
  }
80
168
 
169
+ if (process.env.DEV) {
170
+ plugins.push(ui5DevReadyMessagePlugin());
171
+ }
172
+
81
173
  return plugins;
82
174
  };
83
175
 
84
- const getES6Config = () => {
176
+ const getES6Config = (input = "bundle.esm.js") => {
85
177
  return [{
86
- input: "bundle.esm.js",
178
+ input,
87
179
  output: {
88
180
  dir: "dist/resources",
89
181
  format: "esm",
90
- sourcemap: true
182
+ sourcemap: true,
91
183
  },
92
- moduleContext: (id) => {
93
- if (id.includes("url-search-params-polyfill")) {
184
+ moduleContext: id => {
185
+ if (typeof id === "string" && id.includes("url-search-params-polyfill")) {
94
186
  // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
95
187
  return "window";
96
188
  }
97
189
  },
98
190
  watch: {
99
- clearScreen: false
191
+ clearScreen: false,
100
192
  },
101
- plugins: getPlugins({transpile: false}),
193
+ plugins: getPlugins({ transpile: false }),
194
+ onwarn: onwarn,
102
195
  }];
103
196
  };
104
197
 
105
- const getES5Config = () => {
106
- return [ {
107
- input: "bundle.es5.js",
198
+ const getES5Config = (input = "bundle.es5.js") => {
199
+ return [{
200
+ input,
108
201
  output: {
109
202
  dir: "dist/resources",
110
203
  format: "iife",
204
+ inlineDynamicImports: true,
111
205
  name: "sap-ui-webcomponents-bundle",
112
206
  extend: "true", // Whether or not to extend the global variable defined by the name option in umd or iife formats.
113
- sourcemap: true
207
+ sourcemap: true,
114
208
  },
115
- moduleContext: (id) => {
209
+ moduleContext: id => {
116
210
  if (id.includes("url-search-params-polyfill")) {
117
211
  // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
118
212
  return "window";
119
213
  }
120
214
  },
121
215
  watch: {
122
- clearScreen: false
216
+ clearScreen: false,
123
217
  },
124
- plugins: getPlugins({transpile: true}),
218
+ plugins: getPlugins({ transpile: true }),
219
+ onwarn: onwarn,
125
220
  }];
126
221
  };
127
222
 
128
223
  let config = getES6Config();
129
224
 
130
- if (process.env.ES5_BUILD) {
225
+ if (process.env.ES5_BUILD && fs.existsSync("bundle.es5.js")) {
131
226
  config = config.concat(getES5Config());
132
227
  }
133
228
 
229
+ if (process.env.SCOPE) {
230
+ if (fs.existsSync("bundle.scoped.esm.js")) {
231
+ config = config.concat(getES6Config("bundle.scoped.esm.js"));
232
+
233
+ if (fs.existsSync("bundle.scoped.es5.js") && process.env.ES5_BUILD) {
234
+ config = config.concat(getES5Config("bundle.scoped.es5.js"));
235
+ }
236
+ }
237
+ }
238
+
134
239
  module.exports = config;