postcss-modules 1.0.0 → 1.3.2

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.
@@ -0,0 +1,3 @@
1
+ {
2
+ "javascript.format.enable": true
3
+ }
package/CHANGELOG.md CHANGED
@@ -1,67 +1,106 @@
1
+ # Changelog
2
+
3
+ ## 1.3.1
4
+
5
+ - Move dev tools to devDependecies by Anton Khlynovskiy (ubzey) <https://github.com/css-modules/postcss-modules/pull/85>
6
+
7
+ ## 1.3.0
8
+
9
+ - Updated dependecies
10
+ - Added prettier to format code
11
+
12
+ ## 1.2.0
13
+
14
+ - Added option to transform classes to camelCase by Igor Ribeiro (@igor-ribeiro) <https://github.com/css-modules/postcss-modules/pull/82>
15
+
16
+ ## 1.1.0
17
+
18
+ - Added ability to transmit outputFileName into getJSON by @lutien <https://github.com/css-modules/postcss-modules/pull/72>
19
+
1
20
  ## 1.0.0
2
- * Dropped support for Node < 6
3
- * Updated dependencies
21
+
22
+ - Dropped support for Node < 6
23
+ - Updated dependencies
4
24
 
5
25
  ## 0.8.0
6
- * Updated PostCSS to 6 by Alexey Litvinov (@sullenor) https://github.com/css-modules/postcss-modules/pull/65
26
+
27
+ - Updated PostCSS to 6 by Alexey Litvinov (@sullenor) <https://github.com/css-modules/postcss-modules/pull/65>
7
28
 
8
29
  ## 0.7.1
9
- * Allowed empty string as opts.root by Sharon Rolel (@Mosho1) https://github.com/css-modules/postcss-modules/pull/56
30
+
31
+ - Allowed empty string as opts.root by Sharon Rolel (@Mosho1) <https://github.com/css-modules/postcss-modules/pull/56>
10
32
 
11
33
  ## 0.7.0
12
- * Allow async getJSON by Philipp A. (@flying-sheep) https://github.com/css-modules/postcss-modules/pull/59
34
+
35
+ - Allow async getJSON by Philipp A. (@flying-sheep) <https://github.com/css-modules/postcss-modules/pull/59>
13
36
 
14
37
  ## 0.6.4
15
- * Added the `root` option to pass the root path by Sharon Rolel (@Mosho1) (https://github.com/css-modules/postcss-modules/pull/55)
38
+
39
+ - Added the `root` option to pass the root path by Sharon Rolel (@Mosho1) (<https://github.com/css-modules/postcss-modules/pull/55>)
16
40
 
17
41
  ## 0.6.3
18
- * Fixed regression in `isValidBehaviour` function (https://github.com/css-modules/postcss-modules/issues/53)
42
+
43
+ - Fixed regression in `isValidBehaviour` function (<https://github.com/css-modules/postcss-modules/issues/53>)
19
44
 
20
45
  ## 0.6.2
21
- * Refactored `getDefaultPluginsList` function
46
+
47
+ - Refactored `getDefaultPluginsList` function
22
48
 
23
49
  ## 0.6.1
24
- * Fixed `generateScopedName` bug with multiple postcss-modules instances (https://github.com/css-modules/postcss-modules/issues/37)
50
+
51
+ - Fixed `generateScopedName` bug with multiple postcss-modules instances (<https://github.com/css-modules/postcss-modules/issues/37>)
25
52
 
26
53
  ## 0.6.0
27
- * Added `globalModulePaths` option (Thanks to @pospi).
28
- * Refactored all the things.
54
+
55
+ - Added `globalModulePaths` option (Thanks to @pospi).
56
+ - Refactored all the things.
29
57
 
30
58
  ## 0.5.2
31
- * Updated dependencies
59
+
60
+ - Updated dependencies
32
61
 
33
62
  ## 0.5.1
34
- * Fixed sorting for composed dependencies by Josh Johnston (@joshwnj) (https://github.com/css-modules/postcss-modules/issues/38)
63
+
64
+ - Fixed sorting for composed dependencies by Josh Johnston (@joshwnj) (<https://github.com/css-modules/postcss-modules/issues/38>)
35
65
 
36
66
  ## 0.5.0
37
- * Added `scopeBehaviour` option (https://github.com/css-modules/postcss-modules/issues/22)
38
- * Added ability to pass a string to `generateScopedName` (https://github.com/css-modules/postcss-modules/issues/21)
39
- * Updated dependencies
67
+
68
+ - Added `scopeBehaviour` option (<https://github.com/css-modules/postcss-modules/issues/22>)
69
+ - Added ability to pass a string to `generateScopedName` (<https://github.com/css-modules/postcss-modules/issues/21>)
70
+ - Updated dependencies
40
71
 
41
72
  ## 0.4.1
42
- * Fixed processing errors capturing by Boris Serdiuk (@just-boris)
73
+
74
+ - Fixed processing errors capturing by Boris Serdiuk (@just-boris)
43
75
 
44
76
  ## 0.4.0
45
- * Added support for custom loaders by Björn Brauer (@ZauberNerd)
77
+
78
+ - Added support for custom loaders by Björn Brauer (@ZauberNerd)
46
79
 
47
80
  ## 0.3.0
48
- * Fixed processing for imported CSS
49
- * Added default callback for saving exported JSON
81
+
82
+ - Fixed processing for imported CSS
83
+ - Added default callback for saving exported JSON
50
84
 
51
85
  ## 0.2.0
52
- * Fixed JSON export with shallow imports (https://github.com/outpunk/postcss-modules/issues/12)
53
- * Fixed lookup paths (https://github.com/outpunk/postcss-modules/issues/13)
54
- * Fixed imports overriding (https://github.com/outpunk/postcss-modules/issues/15)
55
- * Global refactoring under the hood
86
+
87
+ - Fixed JSON export with shallow imports (<https://github.com/outpunk/postcss-modules/issues/12>)
88
+ - Fixed lookup paths (<https://github.com/outpunk/postcss-modules/issues/13>)
89
+ - Fixed imports overriding (<https://github.com/outpunk/postcss-modules/issues/15>)
90
+ - Global refactoring under the hood
56
91
 
57
92
  ## 0.1.3
58
- Fixed failing on comments by @dfreeman (https://github.com/outpunk/postcss-modules/pull/14)
93
+
94
+ Fixed failing on comments by @dfreeman (<https://github.com/outpunk/postcss-modules/pull/14>)
59
95
 
60
96
  ## 0.1.2
61
- Fixed module export for ES5 (https://github.com/outpunk/postcss-modules/issues/9)
97
+
98
+ Fixed module export for ES5 (<https://github.com/outpunk/postcss-modules/issues/9>)
62
99
 
63
100
  ## 0.1.1
101
+
64
102
  Call getExports only for top level css
65
103
 
66
104
  ## 0.1.0
105
+
67
106
  Initial version
package/README.md CHANGED
@@ -85,7 +85,7 @@ use the `getJSON` callback. For example, save data about classes into a correspo
85
85
  ```js
86
86
  postcss([
87
87
  require('postcss-modules')({
88
- getJSON: function(cssFileName, json) {
88
+ getJSON: function(cssFileName, json, outputFileName) {
89
89
  var path = require('path');
90
90
  var cssName = path.basename(cssFileName, '.css');
91
91
  var jsonFileName = path.resolve('./build/' + cssName + '.json');
@@ -170,6 +170,25 @@ postcss([
170
170
  ]);
171
171
  ```
172
172
 
173
+ ### Camel cased classes
174
+
175
+ If you need, you can pass the options `{ camelCase: true }` to transform classes:
176
+
177
+ CSS:
178
+ ```css
179
+ .post-title {
180
+ color: red;
181
+ }
182
+ ```
183
+
184
+ JSON:
185
+ ```json
186
+ {
187
+ "post-title": "._post-title_116zl_1",
188
+ "postTitle": "._post-title_116zl_1"
189
+ }
190
+ ```
191
+
173
192
 
174
193
  ## Integration with templates
175
194
  The plugin only transforms CSS classes to CSS modules.
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
@@ -7,15 +7,15 @@ exports.behaviours = undefined;
7
7
  exports.getDefaultPlugins = getDefaultPlugins;
8
8
  exports.isValidBehaviour = isValidBehaviour;
9
9
 
10
- var _cssModulesLoaderCore = require('css-modules-loader-core');
10
+ var _cssModulesLoaderCore = require("css-modules-loader-core");
11
11
 
12
12
  var _cssModulesLoaderCore2 = _interopRequireDefault(_cssModulesLoaderCore);
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
16
  const behaviours = exports.behaviours = {
17
- LOCAL: 'local',
18
- GLOBAL: 'global'
17
+ LOCAL: "local",
18
+ GLOBAL: "global"
19
19
  };
20
20
 
21
21
  function getDefaultPlugins(behaviour, generateScopedName) {
@@ -1,11 +1,11 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = generateScopedName;
7
7
 
8
- var _stringHash = require('string-hash');
8
+ var _stringHash = require("string-hash");
9
9
 
10
10
  var _stringHash2 = _interopRequireDefault(_stringHash);
11
11
 
package/build/index.js CHANGED
@@ -1,36 +1,40 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _postcss = require('postcss');
3
+ var _postcss = require("postcss");
4
4
 
5
5
  var _postcss2 = _interopRequireDefault(_postcss);
6
6
 
7
- var _parser = require('css-modules-loader-core/lib/parser');
7
+ var _lodash = require("lodash.camelcase");
8
+
9
+ var _lodash2 = _interopRequireDefault(_lodash);
10
+
11
+ var _parser = require("css-modules-loader-core/lib/parser");
8
12
 
9
13
  var _parser2 = _interopRequireDefault(_parser);
10
14
 
11
- var _fileSystemLoader = require('css-modules-loader-core/lib/file-system-loader');
15
+ var _fileSystemLoader = require("css-modules-loader-core/lib/file-system-loader");
12
16
 
13
17
  var _fileSystemLoader2 = _interopRequireDefault(_fileSystemLoader);
14
18
 
15
- var _genericNames = require('generic-names');
19
+ var _genericNames = require("generic-names");
16
20
 
17
21
  var _genericNames2 = _interopRequireDefault(_genericNames);
18
22
 
19
- var _generateScopedName = require('./generateScopedName');
23
+ var _generateScopedName = require("./generateScopedName");
20
24
 
21
25
  var _generateScopedName2 = _interopRequireDefault(_generateScopedName);
22
26
 
23
- var _saveJSON = require('./saveJSON');
27
+ var _saveJSON = require("./saveJSON");
24
28
 
25
29
  var _saveJSON2 = _interopRequireDefault(_saveJSON);
26
30
 
27
- var _behaviours = require('./behaviours');
31
+ var _behaviours = require("./behaviours");
28
32
 
29
33
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
34
 
31
35
  function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
32
36
 
33
- const PLUGIN_NAME = 'postcss-modules';
37
+ const PLUGIN_NAME = "postcss-modules";
34
38
 
35
39
  function getDefaultScopeBehaviour(opts) {
36
40
  if (opts.scopeBehaviour && (0, _behaviours.isValidBehaviour)(opts.scopeBehaviour)) {
@@ -43,13 +47,13 @@ function getDefaultScopeBehaviour(opts) {
43
47
  function getScopedNameGenerator(opts) {
44
48
  const scopedNameGenerator = opts.generateScopedName || _generateScopedName2.default;
45
49
 
46
- if (typeof scopedNameGenerator === 'function') return scopedNameGenerator;
50
+ if (typeof scopedNameGenerator === "function") return scopedNameGenerator;
47
51
  return (0, _genericNames2.default)(scopedNameGenerator, { context: process.cwd() });
48
52
  }
49
53
 
50
54
  function getLoader(opts, plugins) {
51
- const root = typeof opts.root === 'undefined' ? '/' : opts.root;
52
- return typeof opts.Loader === 'function' ? new opts.Loader(root, plugins) : new _fileSystemLoader2.default(root, plugins);
55
+ const root = typeof opts.root === "undefined" ? "/" : opts.root;
56
+ return typeof opts.Loader === "function" ? new opts.Loader(root, plugins) : new _fileSystemLoader2.default(root, plugins);
53
57
  }
54
58
 
55
59
  function isGlobalModule(globalModules, inputFile) {
@@ -84,13 +88,22 @@ module.exports = _postcss2.default.plugin(PLUGIN_NAME, (opts = {}) => {
84
88
  const loader = getLoader(opts, plugins);
85
89
  const parser = new _parser2.default(loader.fetch.bind(loader));
86
90
 
87
- yield (0, _postcss2.default)([...plugins, parser.plugin]).process(css, { from: inputFile });
91
+ yield (0, _postcss2.default)([...plugins, parser.plugin]).process(css, {
92
+ from: inputFile
93
+ });
88
94
 
89
95
  const out = loader.finalSource;
90
96
  if (out) css.prepend(out);
91
97
 
98
+ if (opts.camelCase) {
99
+ Object.keys(parser.exportTokens).forEach(function (token) {
100
+ const camelCaseToken = (0, _lodash2.default)(token);
101
+ parser.exportTokens[camelCaseToken] = parser.exportTokens[token];
102
+ });
103
+ }
104
+
92
105
  // getJSON may return a promise
93
- return getJSON(css.source.input.file, parser.exportTokens);
106
+ return getJSON(css.source.input.file, parser.exportTokens, result.opts.to);
94
107
  });
95
108
 
96
109
  return function (_x, _x2) {
package/build/saveJSON.js CHANGED
@@ -1,11 +1,11 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = saveJSON;
7
7
 
8
- var _fs = require('fs');
8
+ var _fs = require("fs");
9
9
 
10
10
  function saveJSON(cssFile, json) {
11
11
  return new Promise((resolve, reject) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss-modules",
3
- "version": "1.0.0",
3
+ "version": "1.3.2",
4
4
  "description": "PostCSS plugin to use CSS Modules everywhere",
5
5
  "main": "build/index.js",
6
6
  "keywords": [
@@ -19,28 +19,42 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "css-modules-loader-core": "^1.1.0",
22
- "generic-names": "^1.0.2",
23
- "postcss": "^6.0.1",
22
+ "generic-names": "^1.0.3",
23
+ "lodash.camelcase": "^4.3.0",
24
+ "postcss": "^7.0.1",
24
25
  "string-hash": "^1.1.1"
25
26
  },
26
27
  "devDependencies": {
27
- "autoprefixer": "^6.6.0",
28
- "ava": "^0.22.0",
29
- "babel": "^6.5.2",
30
- "babel-cli": "^6.18.0",
31
- "babel-core": "^6.21.0",
32
- "babel-eslint": "^8.0.1",
33
- "babel-preset-env": "^1.6.0",
34
- "eslint": "^4.8.0",
35
- "eslint-config-airbnb-base": "^12.0.2",
36
- "eslint-plugin-import": "^2.2.0"
28
+ "autoprefixer": "6.7.7",
29
+ "ava": "^0.25.0",
30
+ "babel-cli": "^6.26.0",
31
+ "babel-core": "^6.26.3",
32
+ "babel-eslint": "^8.2.6",
33
+ "babel-preset-env": "^1.7.0",
34
+ "eslint": "^5.1.0",
35
+ "eslint-plugin-import": "^2.13.0",
36
+ "husky": "0.14.3",
37
+ "lint-staged": "7.2.0",
38
+ "prettier": "1.13.7"
37
39
  },
38
40
  "scripts": {
39
41
  "pretest": "$(npm bin)/eslint src test",
40
42
  "test": "$(npm bin)/babel-node $(npm bin)/ava",
41
43
  "transpile": "$(npm bin)/babel src -d build",
42
44
  "prepublish": "npm run transpile",
43
- "postpublish": "rm -rf build && git push --follow-tags"
45
+ "postpublish": "rm -rf build && git push --follow-tags",
46
+ "precommit": "lint-staged"
47
+ },
48
+ "lint-staged": {
49
+ "*.{json,md}": [
50
+ "prettier --write",
51
+ "git add"
52
+ ],
53
+ "*.js": [
54
+ "prettier --write",
55
+ "eslint --fix",
56
+ "git add"
57
+ ]
44
58
  },
45
59
  "require": "babel-core/register"
46
60
  }