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/build/scoping.js CHANGED
@@ -1,77 +1,86 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.behaviours = void 0;
7
- exports.getDefaultPlugins = getDefaultPlugins;
8
- exports.getDefaultScopeBehaviour = getDefaultScopeBehaviour;
9
- exports.getScopedNameGenerator = getScopedNameGenerator;
10
-
11
- var _postcssModulesExtractImports = _interopRequireDefault(require("postcss-modules-extract-imports"));
12
-
13
- var _genericNames = _interopRequireDefault(require("generic-names"));
14
-
15
- var _postcssModulesLocalByDefault = _interopRequireDefault(require("postcss-modules-local-by-default"));
16
-
17
- var _postcssModulesScope = _interopRequireDefault(require("postcss-modules-scope"));
18
-
19
- var _stringHash = _interopRequireDefault(require("string-hash"));
20
-
21
- var _postcssModulesValues = _interopRequireDefault(require("postcss-modules-values"));
22
-
23
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
- LOCAL: "local",
27
- GLOBAL: "global"
37
+ LOCAL: "local",
38
+ GLOBAL: "global"
28
39
  };
29
- exports.behaviours = behaviours;
30
-
31
- function getDefaultPlugins({
32
- behaviour,
33
- generateScopedName,
34
- exportGlobals
35
- }) {
36
- const scope = (0, _postcssModulesScope.default)({
37
- generateScopedName,
38
- exportGlobals
39
- });
40
- const plugins = {
41
- [behaviours.LOCAL]: [_postcssModulesValues.default, (0, _postcssModulesLocalByDefault.default)({
42
- mode: "local"
43
- }), _postcssModulesExtractImports.default, scope],
44
- [behaviours.GLOBAL]: [_postcssModulesValues.default, (0, _postcssModulesLocalByDefault.default)({
45
- mode: "global"
46
- }), _postcssModulesExtractImports.default, scope]
47
- };
48
- return plugins[behaviour];
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
- return Object.keys(behaviours).map(key => behaviours[key]).indexOf(behaviour) > -1;
66
+ return Object.keys(behaviours).map((key)=>behaviours[key]).indexOf(behaviour) > -1;
53
67
  }
54
-
55
68
  function getDefaultScopeBehaviour(scopeBehaviour) {
56
- return scopeBehaviour && isValidBehaviour(scopeBehaviour) ? scopeBehaviour : behaviours.LOCAL;
69
+ return scopeBehaviour && isValidBehaviour(scopeBehaviour) ? scopeBehaviour : behaviours.LOCAL;
57
70
  }
58
-
59
71
  function generateScopedNameDefault(name, filename, css) {
60
- const i = css.indexOf(`.${name}`);
61
- const lineNumber = css.substr(0, i).split(/[\r\n]/).length;
62
- const hash = (0, _stringHash.default)(css).toString(36).substr(0, 5);
63
- return `_${name}_${hash}_${lineNumber}`;
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
- const scopedNameGenerator = generateScopedName || generateScopedNameDefault;
68
-
69
- if (typeof scopedNameGenerator === "function") {
70
- return scopedNameGenerator;
71
- }
72
-
73
- return (0, _genericNames.default)(scopedNameGenerator, {
74
- context: process.cwd(),
75
- hashPrefix: hashPrefix
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
- value: true
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
- if (!str) {
12
- return "";
13
- }
14
-
15
- if (reg.test(str.charAt(0))) {
16
- str = str.substr(1);
17
- }
18
-
19
- if (reg.test(str.charAt(str.length - 1))) {
20
- str = str.substr(0, str.length - 1);
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
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ transform: {
3
+ "^.+\\.js$": ["@swc/jest"],
4
+ },
5
+ };
package/package.json CHANGED
@@ -1,66 +1,70 @@
1
1
  {
2
- "name": "postcss-modules",
3
- "version": "6.0.1",
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.0.5",
27
- "postcss-modules-scope": "^3.2.0",
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
- "@babel/cli": "^7.17.10",
36
- "@babel/core": "^7.18.0",
37
- "@babel/eslint-parser": "^7.17.0",
38
- "@babel/preset-env": "^7.18.0",
39
- "@babel/register": "^7.17.7",
40
- "autoprefixer": "^10.0.2",
41
- "eslint": "^7.3.1",
42
- "eslint-plugin-import": "^2.21.2",
43
- "eslint-plugin-jest": "^23.17.0",
44
- "husky": "^4.2.5",
45
- "jest": "^26.0.1",
46
- "lint-staged": "^10.2.11",
47
- "postcss": "^8.1.9",
48
- "prettier": "^2.0.5"
49
- },
50
- "scripts": {
51
- "test": "make test",
52
- "precommit": "lint-staged"
53
- },
54
- "lint-staged": {
55
- "*.{json,md}": [
56
- "prettier --write",
57
- "git add"
58
- ],
59
- "*.js": [
60
- "prettier --write",
61
- "eslint --fix",
62
- "git add"
63
- ]
64
- },
65
- "require": "@babel/register"
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>
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
- </state>
5
- </component>
@@ -1,6 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
- </profile>
6
- </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>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="" vcs="Git" />
5
- </component>
6
- </project>