postcss-modules 6.0.1 → 8.1.0
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/.husky/pre-commit +1 -0
- package/.swcrc +11 -0
- package/CHANGELOG.md +96 -57
- package/README.md +6 -12
- package/build/FileSystemLoader.js +102 -124
- package/build/Parser.js +66 -77
- package/build/fs.js +25 -16
- package/build/index.js +11 -14
- package/build/localsConvention.js +40 -41
- package/build/pluginFactory.js +80 -92
- package/build/saveJSON.js +13 -13
- package/build/scoping.js +73 -64
- package/build/unquote.js +18 -18
- package/eslint.config.mjs +26 -0
- package/jest.config.js +5 -0
- package/package.json +68 -64
- package/.eslintrc.js +0 -19
- package/.idea/codeStyles/Project.xml +0 -58
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/postcss-modules.iml +0 -12
- package/.idea/vcs.xml +0 -6
package/build/scoping.js
CHANGED
|
@@ -1,77 +1,86 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get behaviours () {
|
|
13
|
+
return behaviours;
|
|
14
|
+
},
|
|
15
|
+
get getDefaultPlugins () {
|
|
16
|
+
return getDefaultPlugins;
|
|
17
|
+
},
|
|
18
|
+
get getDefaultScopeBehaviour () {
|
|
19
|
+
return getDefaultScopeBehaviour;
|
|
20
|
+
},
|
|
21
|
+
get getScopedNameGenerator () {
|
|
22
|
+
return getScopedNameGenerator;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const _postcssmodulesextractimports = /*#__PURE__*/ _interop_require_default(require("postcss-modules-extract-imports"));
|
|
26
|
+
const _genericnames = /*#__PURE__*/ _interop_require_default(require("generic-names"));
|
|
27
|
+
const _postcssmoduleslocalbydefault = /*#__PURE__*/ _interop_require_default(require("postcss-modules-local-by-default"));
|
|
28
|
+
const _postcssmodulesscope = /*#__PURE__*/ _interop_require_default(require("postcss-modules-scope"));
|
|
29
|
+
const _stringhash = /*#__PURE__*/ _interop_require_default(require("string-hash"));
|
|
30
|
+
const _postcssmodulesvalues = /*#__PURE__*/ _interop_require_default(require("postcss-modules-values"));
|
|
31
|
+
function _interop_require_default(obj) {
|
|
32
|
+
return obj && obj.__esModule ? obj : {
|
|
33
|
+
default: obj
|
|
34
|
+
};
|
|
35
|
+
}
|
|
25
36
|
const behaviours = {
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
LOCAL: "local",
|
|
38
|
+
GLOBAL: "global"
|
|
28
39
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
function getDefaultPlugins({ behaviour, generateScopedName, exportGlobals }) {
|
|
41
|
+
const scope = (0, _postcssmodulesscope.default)({
|
|
42
|
+
generateScopedName,
|
|
43
|
+
exportGlobals
|
|
44
|
+
});
|
|
45
|
+
const plugins = {
|
|
46
|
+
[behaviours.LOCAL]: [
|
|
47
|
+
_postcssmodulesvalues.default,
|
|
48
|
+
(0, _postcssmoduleslocalbydefault.default)({
|
|
49
|
+
mode: "local"
|
|
50
|
+
}),
|
|
51
|
+
_postcssmodulesextractimports.default,
|
|
52
|
+
scope
|
|
53
|
+
],
|
|
54
|
+
[behaviours.GLOBAL]: [
|
|
55
|
+
_postcssmodulesvalues.default,
|
|
56
|
+
(0, _postcssmoduleslocalbydefault.default)({
|
|
57
|
+
mode: "global"
|
|
58
|
+
}),
|
|
59
|
+
_postcssmodulesextractimports.default,
|
|
60
|
+
scope
|
|
61
|
+
]
|
|
62
|
+
};
|
|
63
|
+
return plugins[behaviour];
|
|
49
64
|
}
|
|
50
|
-
|
|
51
65
|
function isValidBehaviour(behaviour) {
|
|
52
|
-
|
|
66
|
+
return Object.keys(behaviours).map((key)=>behaviours[key]).indexOf(behaviour) > -1;
|
|
53
67
|
}
|
|
54
|
-
|
|
55
68
|
function getDefaultScopeBehaviour(scopeBehaviour) {
|
|
56
|
-
|
|
69
|
+
return scopeBehaviour && isValidBehaviour(scopeBehaviour) ? scopeBehaviour : behaviours.LOCAL;
|
|
57
70
|
}
|
|
58
|
-
|
|
59
71
|
function generateScopedNameDefault(name, filename, css) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
const i = css.indexOf(`.${name}`);
|
|
73
|
+
const lineNumber = css.substr(0, i).split(/[\r\n]/).length;
|
|
74
|
+
const hash = (0, _stringhash.default)(css).toString(36).substr(0, 5);
|
|
75
|
+
return `_${name}_${hash}_${lineNumber}`;
|
|
64
76
|
}
|
|
65
|
-
|
|
66
77
|
function getScopedNameGenerator(generateScopedName, hashPrefix) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
+
const scopedNameGenerator = generateScopedName || generateScopedNameDefault;
|
|
79
|
+
if (typeof scopedNameGenerator === "function") {
|
|
80
|
+
return scopedNameGenerator;
|
|
81
|
+
}
|
|
82
|
+
return (0, _genericnames.default)(scopedNameGenerator, {
|
|
83
|
+
context: process.cwd(),
|
|
84
|
+
hashPrefix: hashPrefix
|
|
85
|
+
});
|
|
86
|
+
}
|
package/build/unquote.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return unquote;
|
|
9
|
+
}
|
|
5
10
|
});
|
|
6
|
-
exports.default = unquote;
|
|
7
11
|
// copied from https://github.com/lakenen/node-unquote
|
|
8
12
|
const reg = /['"]/;
|
|
9
|
-
|
|
10
13
|
function unquote(str) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return str;
|
|
24
|
-
}
|
|
14
|
+
if (!str) {
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
if (reg.test(str.charAt(0))) {
|
|
18
|
+
str = str.substr(1);
|
|
19
|
+
}
|
|
20
|
+
if (reg.test(str.charAt(str.length - 1))) {
|
|
21
|
+
str = str.substr(0, str.length - 1);
|
|
22
|
+
}
|
|
23
|
+
return str;
|
|
24
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import jest from "eslint-plugin-jest";
|
|
3
|
+
import globals from "globals";
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
js.configs.recommended,
|
|
7
|
+
{
|
|
8
|
+
languageOptions: {
|
|
9
|
+
ecmaVersion: 2022,
|
|
10
|
+
sourceType: "module",
|
|
11
|
+
globals: {
|
|
12
|
+
...globals.node,
|
|
13
|
+
...globals.es2021,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
plugins: { jest },
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
files: ["test/**/*.js"],
|
|
20
|
+
languageOptions: {
|
|
21
|
+
globals: {
|
|
22
|
+
...jest.environments.globals.globals,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
];
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,66 +1,70 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
2
|
+
"name": "postcss-modules",
|
|
3
|
+
"version": "8.1.0",
|
|
4
|
+
"description": "PostCSS plugin to use CSS Modules everywhere",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"postcss",
|
|
9
|
+
"css",
|
|
10
|
+
"postcss-plugin",
|
|
11
|
+
"modules",
|
|
12
|
+
"css modules",
|
|
13
|
+
"components"
|
|
14
|
+
],
|
|
15
|
+
"author": "Alexander Madyankin <alexander@madyankin.name>",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/css-modules/postcss-modules.git"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"generic-names": "^4.0.0",
|
|
23
|
+
"icss-utils": "^5.1.0",
|
|
24
|
+
"lodash.camelcase": "^4.3.0",
|
|
25
|
+
"postcss-modules-extract-imports": "^3.1.0",
|
|
26
|
+
"postcss-modules-local-by-default": "^4.2.0",
|
|
27
|
+
"postcss-modules-scope": "^3.2.1",
|
|
28
|
+
"postcss-modules-values": "^4.0.0",
|
|
29
|
+
"string-hash": "^1.1.3"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"postcss": "^8.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@eslint/js": "^9.39.4",
|
|
36
|
+
"@swc/cli": "^0.8.1",
|
|
37
|
+
"@swc/core": "^1.15.43",
|
|
38
|
+
"@swc/jest": "^0.2.39",
|
|
39
|
+
"autoprefixer": "^10.5.2",
|
|
40
|
+
"eslint": "^9.39.0",
|
|
41
|
+
"eslint-plugin-import": "^2.32.0",
|
|
42
|
+
"eslint-plugin-jest": "^29.15.4",
|
|
43
|
+
"globals": "^17.7.0",
|
|
44
|
+
"husky": "^9.1.7",
|
|
45
|
+
"jest": "^30.4.2",
|
|
46
|
+
"lint-staged": "^17.0.8",
|
|
47
|
+
"postcss": "^8.5.16",
|
|
48
|
+
"prettier": "^3.9.4"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=20"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"test": "make test",
|
|
55
|
+
"prepare": "husky || true"
|
|
56
|
+
},
|
|
57
|
+
"overrides": {
|
|
58
|
+
"glob": "^12.0.0",
|
|
59
|
+
"file-type": "^22.0.0"
|
|
60
|
+
},
|
|
61
|
+
"lint-staged": {
|
|
62
|
+
"*.{json,md}": [
|
|
63
|
+
"prettier --write"
|
|
64
|
+
],
|
|
65
|
+
"*.js": [
|
|
66
|
+
"prettier --write",
|
|
67
|
+
"eslint --fix"
|
|
68
|
+
]
|
|
69
|
+
}
|
|
66
70
|
}
|
package/.eslintrc.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
extends: "eslint:recommended",
|
|
3
|
-
parserOptions: {
|
|
4
|
-
sourceType: "module",
|
|
5
|
-
babelOptions: {
|
|
6
|
-
cwd: __dirname
|
|
7
|
-
}
|
|
8
|
-
},
|
|
9
|
-
env: {
|
|
10
|
-
node: true,
|
|
11
|
-
es6: true,
|
|
12
|
-
"jest/globals": true,
|
|
13
|
-
},
|
|
14
|
-
parser: "@babel/eslint-parser",
|
|
15
|
-
plugins: ["jest"],
|
|
16
|
-
rules: {
|
|
17
|
-
"import/no-extraneous-dependencies": 0,
|
|
18
|
-
},
|
|
19
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
<component name="ProjectCodeStyleConfiguration">
|
|
2
|
-
<code_scheme name="Project" version="173">
|
|
3
|
-
<HTMLCodeStyleSettings>
|
|
4
|
-
<option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
|
|
5
|
-
<option name="HTML_ENFORCE_QUOTES" value="true" />
|
|
6
|
-
</HTMLCodeStyleSettings>
|
|
7
|
-
<JSCodeStyleSettings version="0">
|
|
8
|
-
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
9
|
-
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
|
10
|
-
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
11
|
-
<option name="ENFORCE_TRAILING_COMMA" value="Remove" />
|
|
12
|
-
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
13
|
-
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
14
|
-
</JSCodeStyleSettings>
|
|
15
|
-
<TypeScriptCodeStyleSettings version="0">
|
|
16
|
-
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
17
|
-
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
|
18
|
-
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
19
|
-
<option name="ENFORCE_TRAILING_COMMA" value="Remove" />
|
|
20
|
-
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
21
|
-
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
22
|
-
</TypeScriptCodeStyleSettings>
|
|
23
|
-
<VueCodeStyleSettings>
|
|
24
|
-
<option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
|
|
25
|
-
<option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
|
|
26
|
-
</VueCodeStyleSettings>
|
|
27
|
-
<codeStyleSettings language="HTML">
|
|
28
|
-
<option name="SOFT_MARGINS" value="80" />
|
|
29
|
-
<indentOptions>
|
|
30
|
-
<option name="INDENT_SIZE" value="2" />
|
|
31
|
-
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
32
|
-
<option name="TAB_SIZE" value="2" />
|
|
33
|
-
</indentOptions>
|
|
34
|
-
</codeStyleSettings>
|
|
35
|
-
<codeStyleSettings language="JavaScript">
|
|
36
|
-
<option name="SOFT_MARGINS" value="80" />
|
|
37
|
-
<indentOptions>
|
|
38
|
-
<option name="INDENT_SIZE" value="2" />
|
|
39
|
-
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
40
|
-
<option name="TAB_SIZE" value="2" />
|
|
41
|
-
</indentOptions>
|
|
42
|
-
</codeStyleSettings>
|
|
43
|
-
<codeStyleSettings language="TypeScript">
|
|
44
|
-
<option name="SOFT_MARGINS" value="80" />
|
|
45
|
-
<indentOptions>
|
|
46
|
-
<option name="INDENT_SIZE" value="2" />
|
|
47
|
-
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
48
|
-
<option name="TAB_SIZE" value="2" />
|
|
49
|
-
</indentOptions>
|
|
50
|
-
</codeStyleSettings>
|
|
51
|
-
<codeStyleSettings language="Vue">
|
|
52
|
-
<option name="SOFT_MARGINS" value="80" />
|
|
53
|
-
<indentOptions>
|
|
54
|
-
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
55
|
-
</indentOptions>
|
|
56
|
-
</codeStyleSettings>
|
|
57
|
-
</code_scheme>
|
|
58
|
-
</component>
|
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/postcss-modules.iml" filepath="$PROJECT_DIR$/.idea/postcss-modules.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="WEB_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager">
|
|
4
|
-
<content url="file://$MODULE_DIR$">
|
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
6
|
-
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
-
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
-
</content>
|
|
9
|
-
<orderEntry type="inheritedJdk" />
|
|
10
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
-
</component>
|
|
12
|
-
</module>
|