postcss-modules 8.3.0 → 8.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 +8 -1
- package/build/pluginFactory.js +5 -0
- package/build/scoping.js +8 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 8.
|
|
3
|
+
## 8.3.1
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- `hashPrefix` is now applied when no custom `generateScopedName` is set. Previously the option was only honoured by `generic-names`, so the built-in default generator silently ignored it. [#160](https://github.com/madyankin/postcss-modules/issues/160)
|
|
8
|
+
- Empty rules left behind after `:global { ... }` unwrapping (e.g. a Sass block containing only a multi-line comment) are now removed instead of emitted as orphaned `{ ... }` blocks. [#136](https://github.com/madyankin/postcss-modules/issues/136)
|
|
9
|
+
|
|
10
|
+
## 8.3.0
|
|
4
11
|
|
|
5
12
|
### Added
|
|
6
13
|
|
package/build/pluginFactory.js
CHANGED
|
@@ -77,6 +77,11 @@ function makePlugin(opts) {
|
|
|
77
77
|
]).process(css, {
|
|
78
78
|
from: inputFile
|
|
79
79
|
});
|
|
80
|
+
// Remove rules whose selector was reduced to whitespace after
|
|
81
|
+
// `:global { ... }` unwrapping — see #136.
|
|
82
|
+
css.walkRules((rule)=>{
|
|
83
|
+
if (rule.selector.trim() === "") rule.remove();
|
|
84
|
+
});
|
|
80
85
|
const out = loader.finalSource;
|
|
81
86
|
if (out) css.prepend(out);
|
|
82
87
|
if (opts.localsConvention) {
|
package/build/scoping.js
CHANGED
|
@@ -68,14 +68,16 @@ function isValidBehaviour(behaviour) {
|
|
|
68
68
|
function getDefaultScopeBehaviour(scopeBehaviour) {
|
|
69
69
|
return scopeBehaviour && isValidBehaviour(scopeBehaviour) ? scopeBehaviour : behaviours.LOCAL;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
function makeDefaultScopedNameGenerator(hashPrefix) {
|
|
72
|
+
return function generateScopedNameDefault(name, filename, css) {
|
|
73
|
+
const i = css.indexOf(`.${name}`);
|
|
74
|
+
const lineNumber = css.substr(0, i).split(/[\r\n]/).length;
|
|
75
|
+
const hash = (0, _stringhash.default)(`${hashPrefix || ""}${css}`).toString(36).substr(0, 5);
|
|
76
|
+
return `_${name}_${hash}_${lineNumber}`;
|
|
77
|
+
};
|
|
76
78
|
}
|
|
77
79
|
function getScopedNameGenerator(generateScopedName, hashPrefix) {
|
|
78
|
-
const scopedNameGenerator = generateScopedName ||
|
|
80
|
+
const scopedNameGenerator = generateScopedName || makeDefaultScopedNameGenerator(hashPrefix);
|
|
79
81
|
if (typeof scopedNameGenerator === "function") {
|
|
80
82
|
return scopedNameGenerator;
|
|
81
83
|
}
|