Skip to content

Commit 3d3de14

Browse files
author
Ruijin Ma
committed
update to latest version
2 parents 7a71156 + b611446 commit 3d3de14

18 files changed

+182
-75
lines changed

.babelrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"stage-0",
5+
"react"
6+
],
7+
"plugins": [
8+
"add-module-exports",
9+
"lodash",
10+
"transform-class-properties",
11+
["transform-es2015-classes", { "loose": true }],
12+
"transform-proto-to-assign"
13+
]
14+
}

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "canonical"
3+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ coverage
77
!.npmignore
88
!.babelrc
99
!.travis.yml
10+
!.eslintrc

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
language: node_js
22
node_js:
3+
- 6
34
- 5
4-
- 4
55
notifications:
66
email: false
77
sudo: false
8+
script:
9+
- npm run test
10+
- npm run lint

README.md

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Rendering the component will produce a markup similar to:
6161
```js
6262
<div class="table__table___32osj">
6363
<div class="table__row___2w27N">
64-
<div class="table__cell___2w27N">A0</div>
64+
<div class="table__cell___1oVw5">A0</div>
6565
<div class="table__cell___1oVw5">B0</div>
6666
</div>
6767
</div>
@@ -182,22 +182,48 @@ Setup:
182182
* Install [`style-loader`](https://www.npmjs.com/package/style-loader).
183183
* Install [`css-loader`](https://www.npmjs.com/package/css-loader).
184184
* Use [`extract-text-webpack-plugin`](https://www.npmjs.com/package/extract-text-webpack-plugin) to extract chunks of CSS into a single stylesheet.
185+
185186
* Setup `/\.css$/` loader:
186187

187-
```js
188-
{
189-
test: /\.css$/,
190-
loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]')
191-
}
192-
```
188+
* ExtractTextPlugin v1x:
189+
190+
```js
191+
{
192+
test: /\.css$/,
193+
loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]')
194+
}
195+
```
196+
197+
* ExtractTextPlugin v2x:
198+
199+
```js
200+
{
201+
test: /\.css$/,
202+
loader: ExtractTextPlugin.extract({
203+
notExtractLoader: 'style-loader',
204+
loader: 'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]!resolve-url!postcss',
205+
}),
206+
}
207+
```
193208

194209
* Setup `extract-text-webpack-plugin` plugin:
195210

196-
```js
197-
new ExtractTextPlugin('app.css', {
198-
allChunks: true
199-
})
200-
```
211+
* ExtractTextPlugin v1x:
212+
213+
```js
214+
new ExtractTextPlugin('app.css', {
215+
allChunks: true
216+
})
217+
```
218+
219+
* ExtractTextPlugin v2x:
220+
221+
```js
222+
new ExtractTextPlugin({
223+
filename: 'app.css',
224+
allChunks: true
225+
})
226+
```
201227

202228
Refer to [webpack-demo](https://github.com/css-modules/webpack-demo) or [react-css-modules-examples](https://github.com/gajus/react-css-modules-examples) for an example of a complete setup.
203229

package.json

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,40 @@
1212
"css",
1313
"modules"
1414
],
15-
"version": "3.7.6",
15+
"version": "3.7.10",
1616
"author": {
1717
"name": "Gajus Kuizinas",
1818
"email": "gajus@gajus.com",
1919
"url": "http://gajus.com"
2020
},
2121
"license": "BSD-3-Clause",
2222
"dependencies": {
23-
"es6-map": "^0.1.3",
2423
"hoist-non-react-statics": "^1.0.5",
2524
"lodash": "^4.6.1",
2625
"object-unfreeze": "^1.0.2"
2726
},
2827
"devDependencies": {
28+
"babel-cli": "^6.10.1",
29+
"babel-plugin-add-module-exports": "^0.2.1",
30+
"babel-plugin-lodash": "^3.2.5",
31+
"babel-plugin-transform-proto-to-assign": "^6.9.0",
32+
"babel-preset-es2015": "^6.9.0",
33+
"babel-preset-react": "^6.11.1",
34+
"babel-preset-stage-0": "^6.5.0",
35+
"babel-register": "^6.9.0",
2936
"chai": "^3.5.0",
37+
"eslint": "^3.0.0",
38+
"eslint-config-canonical": "^1.7.12",
3039
"jsdom": "^8.1.0",
31-
"pragmatist": "^3.0.21",
40+
"mocha": "^2.5.3",
3241
"react": "^15.0.0-rc.1",
3342
"react-addons-shallow-compare": "^15.0.0-rc.1",
3443
"react-addons-test-utils": "^15.0.0-rc.1",
3544
"react-dom": "^15.0.0-rc.1"
3645
},
3746
"scripts": {
38-
"pragmatist": "node ./node_modules/.bin/pragmatist --es5",
39-
"lint": "npm run pragmatist lint",
40-
"test": "npm run pragmatist test --type-annotations",
41-
"build": "npm run pragmatist build",
42-
"watch": "npm run pragmatist watch",
43-
"watch-lint": "npm run pragmatist watch-lint",
44-
"watch-test": "npm run pragmatist watch-test --type-annotations",
45-
"watch-build": "npm run pragmatist watch-build"
47+
"lint": "eslint ./src ./tests",
48+
"test": "mocha --compilers js:babel-register ./tests/**/*.js",
49+
"build": "babel ./src --out-dir ./dist"
4650
}
4751
}

src/extendReactClass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* eslint-disable react/prop-types */
22

3-
import linkClass from './linkClass';
43
import React from 'react';
54
import _ from 'lodash';
65
import hoistNonReactStatics from 'hoist-non-react-statics';
6+
import linkClass from './linkClass';
77
import mergeStyles from './mergeStyles';
88

99
/**

src/generateAppendClassName.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Map from 'es6-map';
1+
import Map from './simple-map';
22

33
const stylesIndex = new Map();
44

@@ -15,7 +15,8 @@ export default (styles, styleNames: Array<string>, errorWhenNotFound: boolean):
1515
return styleNameIndex;
1616
}
1717
} else {
18-
stylesIndexMap = stylesIndex.set(styles, new Map());
18+
stylesIndexMap = new Map();
19+
stylesIndex.set(styles, new Map());
1920
}
2021

2122
appendClassName = '';

src/index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import _ from 'lodash';
22
import extendReactClass from './extendReactClass';
33
import wrapStatelessFunction from './wrapStatelessFunction';
4+
import makeConfiguration from './makeConfiguration';
45

56
/**
67
* @see https://github.com/gajus/react-css-modules#options
78
*/
8-
type OptionsType = {};
9+
type TypeOptions = {};
910

1011
/**
1112
* Determines if the given object has the signature of a class that inherits React.Component.
@@ -17,13 +18,15 @@ const isReactComponent = (maybeReactComponent: any): boolean => {
1718
/**
1819
* When used as a function.
1920
*/
20-
const functionConstructor = (Component: Function, defaultStyles: Object, options: OptionsType): Function => {
21+
const functionConstructor = (Component: Function, defaultStyles: Object, options: TypeOptions): Function => {
2122
let decoratedClass;
2223

24+
const configuration = makeConfiguration(options);
25+
2326
if (isReactComponent(Component)) {
24-
decoratedClass = extendReactClass(Component, defaultStyles, options);
27+
decoratedClass = extendReactClass(Component, defaultStyles, configuration);
2528
} else {
26-
decoratedClass = wrapStatelessFunction(Component, defaultStyles, options);
29+
decoratedClass = wrapStatelessFunction(Component, defaultStyles, configuration);
2730
}
2831

2932
if (Component.displayName) {
@@ -38,7 +41,7 @@ const functionConstructor = (Component: Function, defaultStyles: Object, options
3841
/**
3942
* When used as a ES7 decorator.
4043
*/
41-
const decoratorConstructor = (defaultStyles: Object, options: OptionsType): Function => {
44+
const decoratorConstructor = (defaultStyles: Object, options: TypeOptions): Function => {
4245
return (Component: Function) => {
4346
return functionConstructor(Component, defaultStyles, options);
4447
};

src/isIterable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from 'lodash';
22

3-
const ITERATOR_SYMBOL = _.isFunction(Symbol) && Symbol.iterator;
3+
const ITERATOR_SYMBOL = typeof Symbol !== 'undefined' && _.isFunction(Symbol) && Symbol.iterator;
44
const OLD_ITERATOR_SYMBOL = '@@iterator';
55

66
/**

0 commit comments

Comments
 (0)