postcss-modules 5.0.0 → 6.0.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/README.md CHANGED
@@ -12,26 +12,26 @@ For example, you have the following CSS:
12
12
  ```css
13
13
  /* styles.css */
14
14
  :global .page {
15
- padding: 20px;
15
+ padding: 20px;
16
16
  }
17
17
 
18
18
  .title {
19
- composes: title from "./mixins.css";
20
- color: green;
19
+ composes: title from "./mixins.css";
20
+ color: green;
21
21
  }
22
22
 
23
23
  .article {
24
- font-size: 16px;
24
+ font-size: 16px;
25
25
  }
26
26
 
27
27
  /* mixins.css */
28
28
  .title {
29
- color: black;
30
- font-size: 40px;
29
+ color: black;
30
+ font-size: 40px;
31
31
  }
32
32
 
33
33
  .title:hover {
34
- color: red;
34
+ color: red;
35
35
  }
36
36
  ```
37
37
 
@@ -39,24 +39,24 @@ After the transformation it will become like this:
39
39
 
40
40
  ```css
41
41
  ._title_116zl_1 {
42
- color: black;
43
- font-size: 40px;
42
+ color: black;
43
+ font-size: 40px;
44
44
  }
45
45
 
46
46
  ._title_116zl_1:hover {
47
- color: red;
47
+ color: red;
48
48
  }
49
49
 
50
50
  .page {
51
- padding: 20px;
51
+ padding: 20px;
52
52
  }
53
53
 
54
54
  ._title_xkpkl_5 {
55
- color: green;
55
+ color: green;
56
56
  }
57
57
 
58
58
  ._article_xkpkl_10 {
59
- font-size: 16px;
59
+ font-size: 16px;
60
60
  }
61
61
  ```
62
62
 
@@ -64,8 +64,8 @@ And the plugin will give you a JSON object for transformed classes:
64
64
 
65
65
  ```json
66
66
  {
67
- "title": "_title_xkpkl_5 _title_116zl_1",
68
- "article": "_article_xkpkl_10"
67
+ "title": "_title_xkpkl_5 _title_116zl_1",
68
+ "article": "_article_xkpkl_10"
69
69
  }
70
70
  ```
71
71
 
@@ -79,14 +79,14 @@ use the `getJSON` callback. For example, save data about classes into a correspo
79
79
 
80
80
  ```js
81
81
  postcss([
82
- require("postcss-modules")({
83
- getJSON: function (cssFileName, json, outputFileName) {
84
- var path = require("path");
85
- var cssName = path.basename(cssFileName, ".css");
86
- var jsonFileName = path.resolve("./build/" + cssName + ".json");
87
- fs.writeFileSync(jsonFileName, JSON.stringify(json));
88
- },
89
- }),
82
+ require("postcss-modules")({
83
+ getJSON: function (cssFileName, json, outputFileName) {
84
+ var path = require("path");
85
+ var cssName = path.basename(cssFileName, ".css");
86
+ var jsonFileName = path.resolve("./build/" + cssName + ".json");
87
+ fs.writeFileSync(jsonFileName, JSON.stringify(json));
88
+ },
89
+ }),
90
90
  ]);
91
91
  ```
92
92
 
@@ -99,9 +99,9 @@ this behaviour using the `scopeBehaviour` option:
99
99
 
100
100
  ```js
101
101
  postcss([
102
- require("postcss-modules")({
103
- scopeBehaviour: "global", // can be 'global' or 'local',
104
- }),
102
+ require("postcss-modules")({
103
+ scopeBehaviour: "global", // can be 'global' or 'local',
104
+ }),
105
105
  ]);
106
106
  ```
107
107
 
@@ -120,16 +120,16 @@ To generate custom classes, use the `generateScopedName` callback:
120
120
 
121
121
  ```js
122
122
  postcss([
123
- require("postcss-modules")({
124
- generateScopedName: function (name, filename, css) {
125
- var path = require("path");
126
- var i = css.indexOf("." + name);
127
- var line = css.substr(0, i).split(/[\r\n]/).length;
128
- var file = path.basename(filename, ".css");
129
-
130
- return "_" + file + "_" + line + "_" + name;
131
- },
132
- }),
123
+ require("postcss-modules")({
124
+ generateScopedName: function (name, filename, css) {
125
+ var path = require("path");
126
+ var i = css.indexOf("." + name);
127
+ var line = css.substr(0, i).split(/[\r\n]/).length;
128
+ var file = path.basename(filename, ".css");
129
+
130
+ return "_" + file + "_" + line + "_" + name;
131
+ },
132
+ }),
133
133
  ]);
134
134
  ```
135
135
 
@@ -138,9 +138,9 @@ Or just pass an interpolated string to the `generateScopedName` option
138
138
 
139
139
  ```js
140
140
  postcss([
141
- require("postcss-modules")({
142
- generateScopedName: "[name]__[local]___[hash:base64:5]",
143
- }),
141
+ require("postcss-modules")({
142
+ generateScopedName: "[name]__[local]___[hash:base64:5]",
143
+ }),
144
144
  ]);
145
145
  ```
146
146
 
@@ -148,10 +148,10 @@ It's possible to add custom hash to generate more unique classes using the `hash
148
148
 
149
149
  ```js
150
150
  postcss([
151
- require("postcss-modules")({
152
- generateScopedName: "[name]__[local]___[hash:base64:5]",
153
- hashPrefix: "prefix",
154
- }),
151
+ require("postcss-modules")({
152
+ generateScopedName: "[name]__[local]___[hash:base64:5]",
153
+ hashPrefix: "prefix",
154
+ }),
155
155
  ]);
156
156
  ```
157
157
 
@@ -161,9 +161,9 @@ If you need to export global names via the JSON object along with the local ones
161
161
 
162
162
  ```js
163
163
  postcss([
164
- require("postcss-modules")({
165
- exportGlobals: true,
166
- }),
164
+ require("postcss-modules")({
165
+ exportGlobals: true,
166
+ }),
167
167
  ]);
168
168
  ```
169
169
 
@@ -173,9 +173,9 @@ If you need, you can pass a custom loader (see [FileSystemLoader] for example):
173
173
 
174
174
  ```js
175
175
  postcss([
176
- require("postcss-modules")({
177
- Loader: CustomLoader,
178
- }),
176
+ require("postcss-modules")({
177
+ Loader: CustomLoader,
178
+ }),
179
179
  ]);
180
180
  ```
181
181
 
@@ -207,22 +207,29 @@ In lieu of a string, a custom function can generate the exported class names.
207
207
 
208
208
  ### Resolve path alias
209
209
 
210
- You can rewrite paths for `composes/from` by using `resolve` options.
210
+ You can rewrite paths for `composes/from` by using the `resolve` option.
211
211
  It's useful when you need to resolve custom path alias.
212
212
 
213
+ Parameters:
214
+
215
+ - `file` — a module we want to resolve
216
+ - `importer` — the file that imports the module we want to resolve
217
+
218
+ Return value: `string | null | Promise<string | null>`
219
+
213
220
  ```js
214
221
  postcss([
215
- require("postcss-modules")({
216
- resolve: function (file) {
217
- return file.replace(/^@/, process.cwd());
218
- },
219
- }),
222
+ require("postcss-modules")({
223
+ resolve: function (file, importer) {
224
+ return path.resolve(
225
+ path.dirname(importer),
226
+ file.replace(/^@/, process.cwd()
227
+ );
228
+ },
229
+ }),
220
230
  ]);
221
231
  ```
222
232
 
223
- `resolve` may also return a `Promise<string>`.
224
-
225
-
226
233
  ## Integration with templates
227
234
 
228
235
  The plugin only transforms CSS classes to CSS modules.
@@ -233,8 +240,8 @@ Assume you've saved project's CSS modules in `cssModules.json`:
233
240
 
234
241
  ```json
235
242
  {
236
- "title": "_title_xkpkl_5 _title_116zl_1",
237
- "article": "_article_xkpkl_10"
243
+ "title": "_title_xkpkl_5 _title_116zl_1",
244
+ "article": "_article_xkpkl_10"
238
245
  }
239
246
  ```
240
247
 
@@ -261,7 +268,7 @@ And you'll get the following HTML:
261
268
  ```html
262
269
  <h1 class="_title_xkpkl_5 _title_116zl_1">postcss-modules</h1>
263
270
  <article class="_article_xkpkl_10">
264
- A PostCSS plugin to use CSS Modules everywhere
271
+ A PostCSS plugin to use CSS Modules everywhere
265
272
  </article>
266
273
  ```
267
274
 
@@ -278,7 +285,7 @@ Here is our template `about.html`:
278
285
  ```html
279
286
  <h1 css-module="title">postcss-modules</h1>
280
287
  <article css-module="article">
281
- A PostCSS plugin to use CSS Modules everywhere
288
+ A PostCSS plugin to use CSS Modules everywhere
282
289
  </article>
283
290
  ```
284
291
 
@@ -291,20 +298,20 @@ var posthtmlCssModules = require("posthtml-css-modules");
291
298
  var template = fs.readFileSync("./about.html", "utf8");
292
299
 
293
300
  posthtml([posthtmlCssModules("./cssModules.json")])
294
- .process(template)
295
- .then(function (result) {
296
- console.log(result.html);
297
- });
301
+ .process(template)
302
+ .then(function (result) {
303
+ console.log(result.html);
304
+ });
298
305
  ```
299
306
 
300
- (for using other build systems please check [the documentation of PostHTML](https://github.com/posthtml/posthtml/blob/master/README.md))
307
+ (for using other build systems please check [the documentation of PostHTML](https://github.com/posthtml/posthtml/blob/master/readme.md))
301
308
 
302
309
  And you'll get the following HTML:
303
310
 
304
311
  ```html
305
312
  <h1 class="_title_xkpkl_5 _title_116zl_1">postcss-modules</h1>
306
313
  <article class="_article_xkpkl_10">
307
- A PostCSS plugin to use CSS Modules everywhere
314
+ A PostCSS plugin to use CSS Modules everywhere
308
315
  </article>
309
316
  ```
310
317
 
@@ -320,6 +327,6 @@ npm install --save-dev postcss postcss-modules
320
327
 
321
328
  [filesystemloader]: https://github.com/css-modules/css-modules-loader-core/blob/master/src/file-system-loader.js
322
329
 
323
-
324
330
  ## Sponsors
325
- - Dmitry Olyenyov
331
+
332
+ - Dmitry Olyenyov
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _postcss = _interopRequireDefault(require("postcss"));
9
+
10
+ var _path = _interopRequireDefault(require("path"));
11
+
12
+ var _Parser = _interopRequireDefault(require("./Parser"));
13
+
14
+ var _fs = require("./fs");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ // Initially copied from https://github.com/css-modules/css-modules-loader-core
19
+ class Core {
20
+ constructor(plugins) {
21
+ this.plugins = plugins || Core.defaultPlugins;
22
+ }
23
+
24
+ async load(sourceString, sourcePath, trace, pathFetcher) {
25
+ const parser = new _Parser.default(pathFetcher, trace);
26
+ const plugins = this.plugins.concat([parser.plugin()]);
27
+ const result = await (0, _postcss.default)(plugins).process(sourceString, {
28
+ from: sourcePath
29
+ });
30
+ return {
31
+ injectableSource: result.css,
32
+ exportTokens: parser.exportTokens
33
+ };
34
+ }
35
+
36
+ } // Sorts dependencies in the following way:
37
+ // AAA comes before AA and A
38
+ // AB comes after AA and before A
39
+ // All Bs come after all As
40
+ // This ensures that the files are always returned in the following order:
41
+ // - In the order they were required, except
42
+ // - After all their dependencies
43
+
44
+
45
+ const traceKeySorter = (a, b) => {
46
+ if (a.length < b.length) {
47
+ return a < b.substring(0, a.length) ? -1 : 1;
48
+ }
49
+
50
+ if (a.length > b.length) {
51
+ return a.substring(0, b.length) <= b ? -1 : 1;
52
+ }
53
+
54
+ return a < b ? -1 : 1;
55
+ };
56
+
57
+ class FileSystemLoader {
58
+ constructor(root, plugins, fileResolve) {
59
+ if (root === "/" && process.platform === "win32") {
60
+ const cwdDrive = process.cwd().slice(0, 3);
61
+
62
+ if (!/^[A-Za-z]:\\$/.test(cwdDrive)) {
63
+ throw new Error(`Failed to obtain root from "${process.cwd()}".`);
64
+ }
65
+
66
+ root = cwdDrive;
67
+ }
68
+
69
+ this.root = root;
70
+ this.fileResolve = fileResolve;
71
+ this.sources = {};
72
+ this.traces = {};
73
+ this.importNr = 0;
74
+ this.core = new Core(plugins);
75
+ this.tokensByFile = {};
76
+ this.fs = (0, _fs.getFileSystem)();
77
+ }
78
+
79
+ async fetch(_newPath, relativeTo, _trace) {
80
+ const newPath = _newPath.replace(/^["']|["']$/g, "");
81
+
82
+ const trace = _trace || String.fromCharCode(this.importNr++);
83
+
84
+ const useFileResolve = typeof this.fileResolve === "function";
85
+ const fileResolvedPath = useFileResolve ? await this.fileResolve(newPath, relativeTo) : await Promise.resolve();
86
+
87
+ if (fileResolvedPath && !_path.default.isAbsolute(fileResolvedPath)) {
88
+ throw new Error('The returned path from the "fileResolve" option must be absolute.');
89
+ }
90
+
91
+ const relativeDir = _path.default.dirname(relativeTo);
92
+
93
+ const rootRelativePath = fileResolvedPath || _path.default.resolve(relativeDir, newPath);
94
+
95
+ let fileRelativePath = fileResolvedPath || _path.default.resolve(_path.default.resolve(this.root, relativeDir), newPath); // if the path is not relative or absolute, try to resolve it in node_modules
96
+
97
+
98
+ if (!useFileResolve && newPath[0] !== "." && !_path.default.isAbsolute(newPath)) {
99
+ try {
100
+ fileRelativePath = require.resolve(newPath);
101
+ } catch (e) {// noop
102
+ }
103
+ }
104
+
105
+ const tokens = this.tokensByFile[fileRelativePath];
106
+ if (tokens) return tokens;
107
+ return new Promise((resolve, reject) => {
108
+ this.fs.readFile(fileRelativePath, "utf-8", async (err, source) => {
109
+ if (err) reject(err);
110
+ const {
111
+ injectableSource,
112
+ exportTokens
113
+ } = await this.core.load(source, rootRelativePath, trace, this.fetch.bind(this));
114
+ this.sources[fileRelativePath] = injectableSource;
115
+ this.traces[trace] = fileRelativePath;
116
+ this.tokensByFile[fileRelativePath] = exportTokens;
117
+ resolve(exportTokens);
118
+ });
119
+ });
120
+ }
121
+
122
+ get finalSource() {
123
+ const traces = this.traces;
124
+ const sources = this.sources;
125
+ let written = new Set();
126
+ return Object.keys(traces).sort(traceKeySorter).map(key => {
127
+ const filename = traces[key];
128
+
129
+ if (written.has(filename)) {
130
+ return null;
131
+ }
132
+
133
+ written.add(filename);
134
+ return sources[filename];
135
+ }).join("");
136
+ }
137
+
138
+ }
139
+
140
+ exports.default = FileSystemLoader;
@@ -5,11 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _icssReplaceSymbols = _interopRequireDefault(require("icss-replace-symbols"));
8
+ var _icssUtils = require("icss-utils");
9
9
 
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- // Copied from https://github.com/css-modules/css-modules-loader-core
10
+ // Initially copied from https://github.com/css-modules/css-modules-loader-core
13
11
  const importRegexp = /^:import\((.+)\)$/;
14
12
 
15
13
  class Parser {
@@ -26,8 +24,10 @@ class Parser {
26
24
  return {
27
25
  postcssPlugin: "css-modules-parser",
28
26
 
29
- OnceExit(css) {
30
- return Promise.all(parser.fetchAllImports(css)).then(() => parser.linkImportedSymbols(css)).then(() => parser.extractExports(css));
27
+ async OnceExit(css) {
28
+ await Promise.all(parser.fetchAllImports(css));
29
+ parser.linkImportedSymbols(css);
30
+ return parser.extractExports(css);
31
31
  }
32
32
 
33
33
  };
@@ -44,7 +44,7 @@ class Parser {
44
44
  }
45
45
 
46
46
  linkImportedSymbols(css) {
47
- (0, _icssReplaceSymbols.default)(css, this.translations);
47
+ (0, _icssUtils.replaceSymbols)(css, this.translations);
48
48
  }
49
49
 
50
50
  extractExports(css) {
@@ -65,17 +65,21 @@ class Parser {
65
65
  exportNode.remove();
66
66
  }
67
67
 
68
- fetchImport(importNode, relativeTo, depNr) {
69
- let file = importNode.selector.match(importRegexp)[1],
70
- depTrace = this.trace + String.fromCharCode(depNr);
71
- return this.pathFetcher(file, relativeTo, depTrace).then(exports => {
68
+ async fetchImport(importNode, relativeTo, depNr) {
69
+ const file = importNode.selector.match(importRegexp)[1];
70
+ const depTrace = this.trace + String.fromCharCode(depNr);
71
+ const exports = await this.pathFetcher(file, relativeTo, depTrace);
72
+
73
+ try {
72
74
  importNode.each(decl => {
73
75
  if (decl.type == "decl") {
74
76
  this.translations[decl.prop] = exports[decl.value];
75
77
  }
76
78
  });
77
79
  importNode.remove();
78
- }, err => console.log(err));
80
+ } catch (err) {
81
+ console.log(err);
82
+ }
79
83
  }
80
84
 
81
85
  }
package/build/fs.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getFileSystem = getFileSystem;
7
+ exports.setFileSystem = setFileSystem;
8
+ let fileSystem = {
9
+ readFile: () => {
10
+ throw Error("readFile not implemented");
11
+ },
12
+ writeFile: () => {
13
+ throw Error("writeFile not implemented");
14
+ }
15
+ };
16
+
17
+ function setFileSystem(fs) {
18
+ fileSystem.readFile = fs.readFile;
19
+ fileSystem.writeFile = fs.writeFile;
20
+ }
21
+
22
+ function getFileSystem() {
23
+ return fileSystem;
24
+ }
package/build/index.js CHANGED
@@ -1,160 +1,16 @@
1
1
  "use strict";
2
2
 
3
- var _postcss = _interopRequireDefault(require("postcss"));
3
+ var _fs = require("fs");
4
4
 
5
- var _lodash = _interopRequireDefault(require("lodash.camelcase"));
5
+ var _fs2 = require("./fs");
6
6
 
7
- var _genericNames = _interopRequireDefault(require("generic-names"));
7
+ var _pluginFactory = require("./pluginFactory");
8
8
 
9
- var _unquote = _interopRequireDefault(require("./unquote"));
9
+ (0, _fs2.setFileSystem)({
10
+ readFile: _fs.readFile,
11
+ writeFile: _fs.writeFile
12
+ });
10
13
 
11
- var _parser = _interopRequireDefault(require("./css-loader-core/parser"));
12
-
13
- var _loader = _interopRequireDefault(require("./css-loader-core/loader"));
14
-
15
- var _generateScopedName = _interopRequireDefault(require("./generateScopedName"));
16
-
17
- var _saveJSON = _interopRequireDefault(require("./saveJSON"));
18
-
19
- var _behaviours = require("./behaviours");
20
-
21
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
-
23
- const PLUGIN_NAME = "postcss-modules";
24
-
25
- function getDefaultScopeBehaviour(opts) {
26
- if (opts.scopeBehaviour && (0, _behaviours.isValidBehaviour)(opts.scopeBehaviour)) {
27
- return opts.scopeBehaviour;
28
- }
29
-
30
- return _behaviours.behaviours.LOCAL;
31
- }
32
-
33
- function getScopedNameGenerator(opts) {
34
- const scopedNameGenerator = opts.generateScopedName || _generateScopedName.default;
35
- if (typeof scopedNameGenerator === "function") return scopedNameGenerator;
36
- return (0, _genericNames.default)(scopedNameGenerator, {
37
- context: process.cwd(),
38
- hashPrefix: opts.hashPrefix
39
- });
40
- }
41
-
42
- function getLoader(opts, plugins) {
43
- const root = typeof opts.root === "undefined" ? "/" : opts.root;
44
- return typeof opts.Loader === "function" ? new opts.Loader(root, plugins) : new _loader.default(root, plugins);
45
- }
46
-
47
- function isGlobalModule(globalModules, inputFile) {
48
- return globalModules.some(regex => inputFile.match(regex));
49
- }
50
-
51
- function getDefaultPluginsList(opts, inputFile) {
52
- const globalModulesList = opts.globalModulePaths || null;
53
- const exportGlobals = opts.exportGlobals || false;
54
- const defaultBehaviour = getDefaultScopeBehaviour(opts);
55
- const generateScopedName = getScopedNameGenerator(opts);
56
-
57
- if (globalModulesList && isGlobalModule(globalModulesList, inputFile)) {
58
- return (0, _behaviours.getDefaultPlugins)({
59
- behaviour: _behaviours.behaviours.GLOBAL,
60
- generateScopedName,
61
- exportGlobals
62
- });
63
- }
64
-
65
- return (0, _behaviours.getDefaultPlugins)({
66
- behaviour: defaultBehaviour,
67
- generateScopedName,
68
- exportGlobals
69
- });
70
- }
71
-
72
- function isOurPlugin(plugin) {
73
- return plugin.postcssPlugin === PLUGIN_NAME;
74
- }
75
-
76
- function dashesCamelCase(string) {
77
- return string.replace(/-+(\w)/g, (_, firstLetter) => firstLetter.toUpperCase());
78
- }
79
-
80
- module.exports = (opts = {}) => {
81
- return {
82
- postcssPlugin: PLUGIN_NAME,
83
-
84
- async OnceExit(css, {
85
- result
86
- }) {
87
- const getJSON = opts.getJSON || _saveJSON.default;
88
- const inputFile = css.source.input.file;
89
- const pluginList = getDefaultPluginsList(opts, inputFile);
90
- const resultPluginIndex = result.processor.plugins.findIndex(plugin => isOurPlugin(plugin));
91
-
92
- if (resultPluginIndex === -1) {
93
- throw new Error('Plugin missing from options.');
94
- }
95
-
96
- const earlierPlugins = result.processor.plugins.slice(0, resultPluginIndex);
97
- const loaderPlugins = [...earlierPlugins, ...pluginList];
98
- const loader = getLoader(opts, loaderPlugins);
99
-
100
- const fetcher = (file, relativeTo, depTrace) => {
101
- const unquoteFile = (0, _unquote.default)(file);
102
- const resolvedResult = typeof opts.resolve === 'function' && opts.resolve(unquoteFile);
103
- const resolvedFile = resolvedResult instanceof Promise ? resolvedResult : Promise.resolve(resolvedResult);
104
- return resolvedFile.then(f => {
105
- return loader.fetch.call(loader, `"${f || unquoteFile}"`, relativeTo, depTrace);
106
- });
107
- };
108
-
109
- const parser = new _parser.default(fetcher);
110
- await (0, _postcss.default)([...pluginList, parser.plugin()]).process(css, {
111
- from: inputFile
112
- });
113
- const out = loader.finalSource;
114
- if (out) css.prepend(out);
115
-
116
- if (opts.localsConvention) {
117
- const isFunc = typeof opts.localsConvention === "function";
118
- parser.exportTokens = Object.entries(parser.exportTokens).reduce((tokens, [className, value]) => {
119
- if (isFunc) {
120
- tokens[opts.localsConvention(className, value, inputFile)] = value;
121
- return tokens;
122
- }
123
-
124
- switch (opts.localsConvention) {
125
- case "camelCase":
126
- tokens[className] = value;
127
- tokens[(0, _lodash.default)(className)] = value;
128
- break;
129
-
130
- case "camelCaseOnly":
131
- tokens[(0, _lodash.default)(className)] = value;
132
- break;
133
-
134
- case "dashes":
135
- tokens[className] = value;
136
- tokens[dashesCamelCase(className)] = value;
137
- break;
138
-
139
- case "dashesOnly":
140
- tokens[dashesCamelCase(className)] = value;
141
- break;
142
- }
143
-
144
- return tokens;
145
- }, {});
146
- }
147
-
148
- result.messages.push({
149
- type: "export",
150
- plugin: "postcss-modules",
151
- exportTokens: parser.exportTokens
152
- }); // getJSON may return a promise
153
-
154
- return getJSON(css.source.input.file, parser.exportTokens, result.opts.to);
155
- }
156
-
157
- };
158
- };
14
+ module.exports = (opts = {}) => (0, _pluginFactory.makePlugin)(opts);
159
15
 
160
16
  module.exports.postcss = true;