postcss-merge-rules 5.0.3 → 5.0.4
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/dist/index.js +3 -3
- package/dist/lib/ensureCompatibility.js +8 -8
- package/package.json +11 -10
package/dist/index.js
CHANGED
|
@@ -64,7 +64,7 @@ function sameDeclarationsAndOrder(a, b) {
|
|
|
64
64
|
* @param {postcss.Rule} ruleA
|
|
65
65
|
* @param {postcss.Rule} ruleB
|
|
66
66
|
* @param {string[]=} browsers
|
|
67
|
-
* @param {
|
|
67
|
+
* @param {Map<string, boolean>=} compatibilityCache
|
|
68
68
|
* @return {boolean}
|
|
69
69
|
*/
|
|
70
70
|
|
|
@@ -325,7 +325,7 @@ function partialMerge(first, second) {
|
|
|
325
325
|
}
|
|
326
326
|
/**
|
|
327
327
|
* @param {string[]} browsers
|
|
328
|
-
* @param {
|
|
328
|
+
* @param {Map<string, boolean>} compatibilityCache
|
|
329
329
|
* @return {function(postcss.Rule)}
|
|
330
330
|
*/
|
|
331
331
|
|
|
@@ -391,7 +391,7 @@ function pluginCreator() {
|
|
|
391
391
|
path: __dirname,
|
|
392
392
|
env: resultOpts.env
|
|
393
393
|
});
|
|
394
|
-
const compatibilityCache =
|
|
394
|
+
const compatibilityCache = new Map();
|
|
395
395
|
return {
|
|
396
396
|
OnceExit(css) {
|
|
397
397
|
css.walkRules(selectorMerger(browsers, compatibilityCache));
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.sameVendor = sameVendor;
|
|
7
|
-
exports.noVendor = noVendor;
|
|
8
6
|
exports.ensureCompatibility = ensureCompatibility;
|
|
7
|
+
exports.noVendor = noVendor;
|
|
9
8
|
exports.pseudoElements = void 0;
|
|
9
|
+
exports.sameVendor = sameVendor;
|
|
10
10
|
|
|
11
11
|
var _caniuseApi = require("caniuse-api");
|
|
12
12
|
|
|
@@ -116,18 +116,18 @@ function isHostPseudoClass(selector) {
|
|
|
116
116
|
return selector.includes(':host');
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
const isSupportedCache =
|
|
119
|
+
const isSupportedCache = new Map(); // Move to util in future
|
|
120
120
|
|
|
121
121
|
function isSupportedCached(feature, browsers) {
|
|
122
122
|
const key = JSON.stringify({
|
|
123
123
|
feature,
|
|
124
124
|
browsers
|
|
125
125
|
});
|
|
126
|
-
let result = isSupportedCache
|
|
126
|
+
let result = isSupportedCache.get(key);
|
|
127
127
|
|
|
128
128
|
if (!result) {
|
|
129
129
|
result = (0, _caniuseApi.isSupported)(feature, browsers);
|
|
130
|
-
isSupportedCache
|
|
130
|
+
isSupportedCache.set(key, result);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
return result;
|
|
@@ -149,8 +149,8 @@ function ensureCompatibility(selectors, browsers, compatibilityCache) {
|
|
|
149
149
|
return true;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
if (compatibilityCache && selector
|
|
153
|
-
return compatibilityCache
|
|
152
|
+
if (compatibilityCache && compatibilityCache.has(selector)) {
|
|
153
|
+
return compatibilityCache.get(selector);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
let compatible = true;
|
|
@@ -216,7 +216,7 @@ function ensureCompatibility(selectors, browsers, compatibilityCache) {
|
|
|
216
216
|
}).processSync(selector);
|
|
217
217
|
|
|
218
218
|
if (compatibilityCache) {
|
|
219
|
-
compatibilityCache
|
|
219
|
+
compatibilityCache.set(selector, compatible);
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
return compatible;
|
package/package.json
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-merge-rules",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"description": "Merge CSS rules with PostCSS.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"LICENSE-MIT",
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"prebuild": "rimraf dist",
|
|
12
|
-
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
|
|
13
|
-
"prepare": "yarn build"
|
|
14
|
-
},
|
|
15
10
|
"keywords": [
|
|
16
11
|
"css",
|
|
17
12
|
"optimise",
|
|
@@ -29,7 +24,7 @@
|
|
|
29
24
|
"dependencies": {
|
|
30
25
|
"browserslist": "^4.16.6",
|
|
31
26
|
"caniuse-api": "^3.0.0",
|
|
32
|
-
"cssnano-utils": "^
|
|
27
|
+
"cssnano-utils": "^3.0.0",
|
|
33
28
|
"postcss-selector-parser": "^6.0.5"
|
|
34
29
|
},
|
|
35
30
|
"bugs": {
|
|
@@ -39,9 +34,15 @@
|
|
|
39
34
|
"node": "^10 || ^12 || >=14.0"
|
|
40
35
|
},
|
|
41
36
|
"devDependencies": {
|
|
42
|
-
"postcss": "^8.2.15"
|
|
37
|
+
"postcss": "^8.2.15",
|
|
38
|
+
"postcss-discard-comments": "^5.0.1"
|
|
43
39
|
},
|
|
44
40
|
"peerDependencies": {
|
|
45
41
|
"postcss": "^8.2.15"
|
|
46
|
-
}
|
|
47
|
-
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"prebuild": "rimraf dist",
|
|
45
|
+
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\""
|
|
46
|
+
},
|
|
47
|
+
"readme": "# [postcss][postcss]-merge-rules\n\n> Merge CSS rules with PostCSS.\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-merge-rules) do:\n\n```\nnpm install postcss-merge-rules --save\n```\n\n## Examples\n\nThis module will attempt to merge *adjacent* CSS rules:\n\n### By declarations\n\n#### Input\n\n```css\na {\n color: blue;\n font-weight: bold\n}\n\np {\n color: blue;\n font-weight: bold\n}\n```\n\n#### Output\n\n```css\na,p {\n color: blue;\n font-weight: bold\n}\n```\n\n### By selectors\n\n#### Input\n\n```css\na {\n color: blue\n}\n\na {\n font-weight: bold\n}\n```\n\n#### Output\n\n```css\na {\n color: blue;\n font-weight: bold\n}\n```\n\n### By partial declarations\n\n#### Input\n\n```css\na {\n font-weight: bold\n}\n\np {\n color: blue;\n font-weight: bold\n}\n```\n\n#### Output\n\n```css\na,p {\n font-weight: bold\n}\n\np {\n color: blue\n}\n```\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n\n## License\n\nMIT © [Ben Briggs](http://beneb.info)\n\n[postcss]: https://github.com/postcss/postcss\n"
|
|
48
|
+
}
|