@ui5/webcomponents-tools 1.2.3 → 1.3.1
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.
- package/CHANGELOG.md +27 -0
- package/components-package/nps.js +8 -23
- package/components-package/postcss.themes.js +1 -1
- package/components-package/rollup.js +9 -98
- package/lib/copy-and-watch/index.js +24 -0
- package/lib/hbs2lit/src/compiler.js +10 -1
- package/lib/postcss-combine-duplicated-selectors/index.js +178 -0
- package/lib/postcss-p/postcss-p.mjs +11 -0
- package/package.json +5 -11
- package/lib/polyfill-placeholder/index.js +0 -5
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,33 @@
|
|
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.3.1](https://github.com/SAP/ui5-webcomponents/compare/v1.3.0...v1.3.1) (2022-04-27)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
# [1.3.0](https://github.com/SAP/ui5-webcomponents/compare/v1.2.4...v1.3.0) (2022-04-19)
|
15
|
+
|
16
|
+
|
17
|
+
### Bug Fixes
|
18
|
+
|
19
|
+
* **localization:** fix js error if "sh" locale set ([#4905](https://github.com/SAP/ui5-webcomponents/issues/4905)) ([979bca2](https://github.com/SAP/ui5-webcomponents/commit/979bca2)), closes [#4904](https://github.com/SAP/ui5-webcomponents/issues/4904)
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
## [1.2.4](https://github.com/SAP/ui5-webcomponents/compare/v1.2.3...v1.2.4) (2022-03-30)
|
26
|
+
|
27
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
6
33
|
## [1.2.3](https://github.com/SAP/ui5-webcomponents/compare/v1.2.2...v1.2.3) (2022-03-23)
|
7
34
|
|
8
35
|
**Note:** Version bump only for package @ui5/webcomponents-tools
|
@@ -2,8 +2,6 @@ const path = require("path");
|
|
2
2
|
const fs = require("fs");
|
3
3
|
|
4
4
|
const LIB = path.join(__dirname, `../lib/`);
|
5
|
-
const polyfillDir = path.dirname(require.resolve("@webcomponents/webcomponentsjs"));
|
6
|
-
const polyfillPath = path.join(polyfillDir, "{*.js,*.map,*.md,bundles/**/*.*}");
|
7
5
|
const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
|
8
6
|
|
9
7
|
const getScripts = (options) => {
|
@@ -20,16 +18,13 @@ const getScripts = (options) => {
|
|
20
18
|
clean: "rimraf dist && rimraf .port",
|
21
19
|
lint: "eslint . --config config/.eslintrc.js",
|
22
20
|
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
|
-
},
|
21
|
+
prepare: "nps clean build.templates build.styles build.i18n build.jsonImports copy build.samples build.illustrations",
|
27
22
|
build: {
|
28
|
-
default: "nps lint prepare
|
23
|
+
default: "nps lint prepare build.bundle",
|
29
24
|
templates: `mkdirp dist/generated/templates && node "${LIB}/hbs2ui5/index.js" -d src/ -o dist/generated/templates`,
|
30
25
|
styles: {
|
31
26
|
default: "nps build.styles.themes build.styles.components",
|
32
|
-
themes: "postcss
|
27
|
+
themes: `node "${LIB}/postcss-p/postcss-p.mjs"`,
|
33
28
|
components: "postcss src/themes/*.css --config config/postcss.components --base src --dir dist/css/", // When updating this, also update the new files script
|
34
29
|
},
|
35
30
|
i18n: {
|
@@ -42,7 +37,7 @@ const getScripts = (options) => {
|
|
42
37
|
themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes dist/generated/json-imports`,
|
43
38
|
i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n dist/generated/json-imports`,
|
44
39
|
},
|
45
|
-
bundle: "rollup --config config/rollup.config.js
|
40
|
+
bundle: "rollup --config config/rollup.config.js",
|
46
41
|
samples: {
|
47
42
|
default: "nps build.samples.api build.samples.docs",
|
48
43
|
api: `jsdoc -c "${LIB}/jsdoc/config.json"`,
|
@@ -51,24 +46,17 @@ const getScripts = (options) => {
|
|
51
46
|
illustrations: illustrationsScript
|
52
47
|
},
|
53
48
|
copy: {
|
54
|
-
default: "nps copy.src copy.props copy.test
|
55
|
-
es5: "nps copy.src copy.props copy.test copy.webcomponents-polyfill",
|
49
|
+
default: "nps copy.src copy.props copy.test",
|
56
50
|
src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
57
51
|
props: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.properties" dist/`,
|
58
52
|
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"`
|
61
53
|
},
|
62
54
|
watch: {
|
63
55
|
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"',
|
65
56
|
src: 'nps "copy.src --watch --safe --skip-initial-copy"',
|
66
57
|
props: 'nps "copy.props --watch --safe --skip-initial-copy"',
|
67
58
|
test: 'nps "copy.test --watch --safe --skip-initial-copy"',
|
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
|
-
},
|
59
|
+
bundle: 'rollup --config config/rollup.config.js -w --environment DEV',
|
72
60
|
styles: {
|
73
61
|
default: 'concurrently "nps watch.styles.themes" "nps watch.styles.components"',
|
74
62
|
themes: 'nps "build.styles.themes -w"',
|
@@ -82,10 +70,7 @@ const getScripts = (options) => {
|
|
82
70
|
samples: 'chokidar "test/**/*.sample.html" -c "nps build.samples"',
|
83
71
|
i18n: 'chokidar "src/i18n/messagebundle.properties" -c "nps build.i18n.defaultsjs"'
|
84
72
|
},
|
85
|
-
dev:
|
86
|
-
default: 'concurrently "nps serve" "nps watch"',
|
87
|
-
es5: 'concurrently "nps serve" "nps watch.es5"'
|
88
|
-
},
|
73
|
+
dev: 'concurrently "nps serve" "nps watch"',
|
89
74
|
start: "nps prepare dev",
|
90
75
|
serve: `node "${LIB}/serve/index.js" --dir="dist/" --port=${port} --portStep=${portStep} --packageName="${packageName}"`,
|
91
76
|
test: {
|
@@ -106,7 +91,7 @@ const getScripts = (options) => {
|
|
106
91
|
},
|
107
92
|
dev: 'concurrently "nps serve" "nps scope.watch"',
|
108
93
|
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
|
94
|
+
bundle: 'rollup --config config/rollup.config.js -w --environment DEV,SCOPE'
|
110
95
|
}
|
111
96
|
};
|
112
97
|
|
@@ -1,5 +1,5 @@
|
|
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');
|
@@ -1,21 +1,16 @@
|
|
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
6
|
const json = require("@rollup/plugin-json");
|
9
7
|
const replace = require("@rollup/plugin-replace");
|
10
|
-
const commonjs = require("@rollup/plugin-commonjs");
|
11
8
|
const colors = require("cli-color");
|
12
|
-
const filesize = require("rollup-plugin-filesize");
|
13
9
|
const livereload = require("rollup-plugin-livereload");
|
14
10
|
const emptyModulePlugin = require("./rollup-plugins/empty-module.js");
|
15
11
|
|
16
12
|
const packageFile = JSON.parse(fs.readFileSync("./package.json"));
|
17
13
|
const packageName = packageFile.name;
|
18
|
-
const DEPLOY_PUBLIC_PATH = process.env.DEPLOY_PUBLIC_PATH || "";
|
19
14
|
|
20
15
|
const warningsToSkip = [{
|
21
16
|
warningCode: "THIS_IS_UNDEFINED",
|
@@ -72,7 +67,7 @@ function ui5DevReadyMessagePlugin() {
|
|
72
67
|
};
|
73
68
|
}
|
74
69
|
|
75
|
-
const getPlugins = (
|
70
|
+
const getPlugins = () => {
|
76
71
|
const plugins = [];
|
77
72
|
|
78
73
|
if (process.env.DEV) {
|
@@ -93,59 +88,14 @@ const getPlugins = ({ transpile }) => {
|
|
93
88
|
}));
|
94
89
|
}
|
95
90
|
|
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
|
-
|
117
91
|
plugins.push(ui5DevImportCheckerPlugin());
|
118
92
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
}));
|
126
|
-
}
|
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
|
-
}
|
139
|
-
|
140
|
-
if (transpile) {
|
141
|
-
plugins.push(commonjs());
|
142
|
-
plugins.push(babel({
|
143
|
-
presets: ["@babel/preset-env"],
|
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",
|
147
|
-
}));
|
148
|
-
}
|
93
|
+
plugins.push(json({
|
94
|
+
include: [
|
95
|
+
/.*assets\/.*\.json/,
|
96
|
+
],
|
97
|
+
namedExports: false,
|
98
|
+
}));
|
149
99
|
|
150
100
|
plugins.push(nodeResolve());
|
151
101
|
|
@@ -155,7 +105,7 @@ const getPlugins = ({ transpile }) => {
|
|
155
105
|
}));
|
156
106
|
}
|
157
107
|
|
158
|
-
const es6DevMain = process.env.DEV &&
|
108
|
+
const es6DevMain = process.env.DEV && packageName === "@ui5/webcomponents";
|
159
109
|
if (es6DevMain && os.platform() !== "win32") {
|
160
110
|
plugins.push(livereload({
|
161
111
|
watch: [
|
@@ -181,58 +131,19 @@ const getES6Config = (input = "bundle.esm.js") => {
|
|
181
131
|
format: "esm",
|
182
132
|
sourcemap: true,
|
183
133
|
},
|
184
|
-
moduleContext: id => {
|
185
|
-
if (typeof id === "string" && id.includes("url-search-params-polyfill")) {
|
186
|
-
// suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
|
187
|
-
return "window";
|
188
|
-
}
|
189
|
-
},
|
190
|
-
watch: {
|
191
|
-
clearScreen: false,
|
192
|
-
},
|
193
|
-
plugins: getPlugins({ transpile: false }),
|
194
|
-
onwarn: onwarn,
|
195
|
-
}];
|
196
|
-
};
|
197
|
-
|
198
|
-
const getES5Config = (input = "bundle.es5.js") => {
|
199
|
-
return [{
|
200
|
-
input,
|
201
|
-
output: {
|
202
|
-
dir: "dist/resources",
|
203
|
-
format: "iife",
|
204
|
-
inlineDynamicImports: true,
|
205
|
-
name: "sap-ui-webcomponents-bundle",
|
206
|
-
extend: "true", // Whether or not to extend the global variable defined by the name option in umd or iife formats.
|
207
|
-
sourcemap: true,
|
208
|
-
},
|
209
|
-
moduleContext: id => {
|
210
|
-
if (id.includes("url-search-params-polyfill")) {
|
211
|
-
// suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
|
212
|
-
return "window";
|
213
|
-
}
|
214
|
-
},
|
215
134
|
watch: {
|
216
135
|
clearScreen: false,
|
217
136
|
},
|
218
|
-
plugins: getPlugins(
|
137
|
+
plugins: getPlugins(),
|
219
138
|
onwarn: onwarn,
|
220
139
|
}];
|
221
140
|
};
|
222
141
|
|
223
142
|
let config = getES6Config();
|
224
143
|
|
225
|
-
if (process.env.ES5_BUILD && fs.existsSync("bundle.es5.js")) {
|
226
|
-
config = config.concat(getES5Config());
|
227
|
-
}
|
228
|
-
|
229
144
|
if (process.env.SCOPE) {
|
230
145
|
if (fs.existsSync("bundle.scoped.esm.js")) {
|
231
146
|
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
147
|
}
|
237
148
|
}
|
238
149
|
|
@@ -1,3 +1,27 @@
|
|
1
|
+
/*
|
2
|
+
MIT License
|
3
|
+
|
4
|
+
Copyright (c) 2017
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
23
|
+
*/
|
24
|
+
|
1
25
|
const fs = require('fs');
|
2
26
|
const path = require('path');
|
3
27
|
const chokidar = require('chokidar');
|
@@ -30,7 +30,16 @@ const hbs2lit = (file) => {
|
|
30
30
|
lv.accept(ast);
|
31
31
|
|
32
32
|
for (let key in lv.blocks) {
|
33
|
-
|
33
|
+
let block = lv.blocks[key];
|
34
|
+
|
35
|
+
if (block.match(/scopeTag/)) {
|
36
|
+
const matches = block.match(/^(.*?)( => )(.*?);$/);
|
37
|
+
const scopedCode = matches[3];
|
38
|
+
const normalCode = scopedCode.replace(/\${scopeTag\("/g, "").replace(/", tags, suffix\)}/g, "");
|
39
|
+
block = `${matches[1]}${matches[2]}suffix ? ${scopedCode} : ${normalCode};`;
|
40
|
+
}
|
41
|
+
|
42
|
+
result += block + "\n";
|
34
43
|
}
|
35
44
|
|
36
45
|
result = svgProcessor.process(result);
|
@@ -0,0 +1,178 @@
|
|
1
|
+
/*
|
2
|
+
The MIT License (MIT)
|
3
|
+
|
4
|
+
Copyright (c) 2016 Christian Murphy
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
23
|
+
*/
|
24
|
+
|
25
|
+
const parser = require('postcss-selector-parser');
|
26
|
+
const name = "postcss-combine-duplicated-selectors";
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Ensure that attributes with different quotes match.
|
30
|
+
* @param {Object} selector - postcss selector node
|
31
|
+
*/
|
32
|
+
function normalizeAttributes(selector) {
|
33
|
+
selector.walkAttributes((node) => {
|
34
|
+
if (node.value) {
|
35
|
+
// remove quotes
|
36
|
+
node.value = node.value.replace(/'|\\'|"|\\"/g, '');
|
37
|
+
}
|
38
|
+
});
|
39
|
+
}
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Sort class and id groups alphabetically
|
43
|
+
* @param {Object} selector - postcss selector node
|
44
|
+
*/
|
45
|
+
function sortGroups(selector) {
|
46
|
+
selector.each((subSelector) => {
|
47
|
+
subSelector.nodes.sort((a, b) => {
|
48
|
+
// different types cannot be sorted
|
49
|
+
if (a.type !== b.type) {
|
50
|
+
return 0;
|
51
|
+
}
|
52
|
+
|
53
|
+
// sort alphabetically
|
54
|
+
return a.value < b.value ? -1 : 1;
|
55
|
+
});
|
56
|
+
});
|
57
|
+
|
58
|
+
selector.sort((a, b) => (a.nodes.join('') < b.nodes.join('') ? -1 : 1));
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Remove duplicated properties
|
63
|
+
* @param {Object} selector - postcss selector node
|
64
|
+
* @param {Boolean} exact
|
65
|
+
*/
|
66
|
+
function removeDupProperties(selector, exact) {
|
67
|
+
if (!exact) { // Remove duplicated properties, regardless of value
|
68
|
+
const retainedProps = new Set();
|
69
|
+
|
70
|
+
for (let actIndex = selector.nodes.length - 1; actIndex >= 1; actIndex--) {
|
71
|
+
const prop = selector.nodes[actIndex].prop;
|
72
|
+
if (prop !== undefined) {
|
73
|
+
if (!retainedProps.has(prop)) {
|
74
|
+
retainedProps.add(prop); // Mark the prop as retained, all other occurrences must be removed
|
75
|
+
} else {
|
76
|
+
selector.nodes[actIndex].remove(); // This occurrence of the prop must be removed
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
} else {
|
81
|
+
// Remove duplicated properties from bottom to top ()
|
82
|
+
for (let actIndex = selector.nodes.length - 1; actIndex >= 1; actIndex--) {
|
83
|
+
for (let befIndex = actIndex - 1; befIndex >= 0; befIndex--) {
|
84
|
+
if (
|
85
|
+
selector.nodes[actIndex].prop === selector.nodes[befIndex].prop &&
|
86
|
+
selector.nodes[actIndex].value === selector.nodes[befIndex].value
|
87
|
+
) {
|
88
|
+
selector.nodes[befIndex].remove();
|
89
|
+
actIndex--;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
const uniformStyle = parser((selector) => {
|
97
|
+
normalizeAttributes(selector);
|
98
|
+
sortGroups(selector);
|
99
|
+
});
|
100
|
+
|
101
|
+
const defaultOptions = {
|
102
|
+
removeDuplicatedProperties: false,
|
103
|
+
};
|
104
|
+
|
105
|
+
module.exports = (options) => {
|
106
|
+
options = Object.assign({}, defaultOptions, options);
|
107
|
+
return {
|
108
|
+
postcssPlugin: name,
|
109
|
+
prepare() {
|
110
|
+
// Create a map to store maps
|
111
|
+
const mapTable = new Map();
|
112
|
+
// root map to store root selectors
|
113
|
+
mapTable.set('root', new Map());
|
114
|
+
|
115
|
+
return {
|
116
|
+
Rule: (rule) => {
|
117
|
+
let map;
|
118
|
+
// Check selector parent for any at rule
|
119
|
+
if (rule.parent.type === 'atrule') {
|
120
|
+
// Use name and query params as the key
|
121
|
+
const query =
|
122
|
+
rule.parent.name.toLowerCase() +
|
123
|
+
rule.parent.params.replace(/\s+/g, '');
|
124
|
+
|
125
|
+
// See if this query key is already in the map table
|
126
|
+
map = mapTable.has(query) ? // If it is use it
|
127
|
+
mapTable.get(query) : // if not set it and get it
|
128
|
+
mapTable.set(query, new Map()).get(query);
|
129
|
+
} else {
|
130
|
+
// Otherwise we are dealing with a selector in the root
|
131
|
+
map = mapTable.get('root');
|
132
|
+
}
|
133
|
+
|
134
|
+
// create a uniform selector
|
135
|
+
const selector = uniformStyle.processSync(rule.selector, {
|
136
|
+
lossless: false,
|
137
|
+
});
|
138
|
+
|
139
|
+
if (map.has(selector)) {
|
140
|
+
// store original rule as destination
|
141
|
+
const destination = map.get(selector);
|
142
|
+
|
143
|
+
// check if node has already been processed
|
144
|
+
if (destination === rule) return;
|
145
|
+
|
146
|
+
// move declarations to original rule
|
147
|
+
while (rule.nodes.length > 0) {
|
148
|
+
destination.append(rule.nodes[0]);
|
149
|
+
}
|
150
|
+
// remove duplicated rule
|
151
|
+
rule.remove();
|
152
|
+
|
153
|
+
if (
|
154
|
+
options.removeDuplicatedProperties ||
|
155
|
+
options.removeDuplicatedValues
|
156
|
+
) {
|
157
|
+
removeDupProperties(
|
158
|
+
destination,
|
159
|
+
options.removeDuplicatedValues,
|
160
|
+
);
|
161
|
+
}
|
162
|
+
} else {
|
163
|
+
if (
|
164
|
+
options.removeDuplicatedProperties ||
|
165
|
+
options.removeDuplicatedValues
|
166
|
+
) {
|
167
|
+
removeDupProperties(rule, options.removeDuplicatedValues);
|
168
|
+
}
|
169
|
+
// add new selector to symbol table
|
170
|
+
map.set(selector, rule);
|
171
|
+
}
|
172
|
+
},
|
173
|
+
};
|
174
|
+
},
|
175
|
+
};
|
176
|
+
};
|
177
|
+
|
178
|
+
module.exports.postcss = true;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import 'zx/globals';
|
2
|
+
|
3
|
+
const inputFiles = await globby("src/**/parameters-bundle.css");
|
4
|
+
|
5
|
+
const restArgs = process.argv.slice(2);
|
6
|
+
|
7
|
+
// run all postcss processes in parallel as passing the glob directly to postcss makes them processed sequentially.
|
8
|
+
// and the amount of imports give a big speed up when run in parallel
|
9
|
+
await Promise.all(inputFiles.map(file => {
|
10
|
+
return $`postcss ${file} --config config/postcss.themes --base src --dir dist/css/ ${restArgs}`;
|
11
|
+
}));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-tools",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.3.1",
|
4
4
|
"description": "UI5 Web Components: webcomponents.tools",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -21,21 +21,15 @@
|
|
21
21
|
"directory": "packages/tools"
|
22
22
|
},
|
23
23
|
"dependencies": {
|
24
|
-
"@babel/core": "^7.13.10",
|
25
|
-
"@babel/preset-env": "^7.13.10",
|
26
24
|
"@openui5/sap.ui.core": "1.95.0",
|
27
|
-
"@rollup/plugin-babel": "^5.3.0",
|
28
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
29
25
|
"@rollup/plugin-json": "^4.1.0",
|
30
26
|
"@rollup/plugin-node-resolve": "^13.0.5",
|
31
27
|
"@rollup/plugin-replace": "^3.0.0",
|
32
|
-
"@rollup/plugin-url": "^6.0.0",
|
33
28
|
"@wdio/cli": "^7.12.2",
|
34
29
|
"@wdio/dot-reporter": "^7.10.1",
|
35
30
|
"@wdio/local-runner": "^7.12.2",
|
36
31
|
"@wdio/mocha-framework": "^7.12.2",
|
37
32
|
"@wdio/spec-reporter": "^7.10.1",
|
38
|
-
"@webcomponents/webcomponentsjs": "^2.5.0",
|
39
33
|
"chai": "^4.3.4",
|
40
34
|
"child_process": "^1.0.2",
|
41
35
|
"chokidar": "^3.5.1",
|
@@ -62,21 +56,21 @@
|
|
62
56
|
"nps": "^5.10.0",
|
63
57
|
"postcss": "^8.4.5",
|
64
58
|
"postcss-cli": "^9.1.0",
|
65
|
-
"postcss-combine-duplicated-selectors": "^10.0.3",
|
66
59
|
"postcss-import": "^14.0.2",
|
60
|
+
"postcss-selector-parser": "^6.0.10",
|
67
61
|
"properties-reader": "^2.2.0",
|
68
62
|
"recursive-readdir": "^2.2.2",
|
69
63
|
"resolve": "^1.20.0",
|
70
64
|
"rimraf": "^3.0.2",
|
71
65
|
"rollup": "^2.41.4",
|
72
|
-
"rollup-plugin-filesize": "^9.1.1",
|
73
66
|
"rollup-plugin-livereload": "^2.0.0",
|
74
67
|
"rollup-plugin-terser": "^7.0.2",
|
75
68
|
"serve": "^12.0.0",
|
76
69
|
"slash": "3.0.0",
|
77
|
-
"wdio-chromedriver-service": "^7.0.0"
|
70
|
+
"wdio-chromedriver-service": "^7.0.0",
|
71
|
+
"zx": "^4.3.0"
|
78
72
|
},
|
79
73
|
"peerDependencies": {
|
80
74
|
"chromedriver": "*"
|
81
75
|
}
|
82
|
-
}
|
76
|
+
}
|