Skip to content

Commit 0b71a9f

Browse files
committed
Update dependencies, especially postcss
1 parent eb008aa commit 0b71a9f

File tree

8 files changed

+55
-48
lines changed

8 files changed

+55
-48
lines changed

package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
"url": "http://gajus.com"
66
},
77
"dependencies": {
8-
"@babel/plugin-syntax-jsx": "^7.0.0",
9-
"@babel/types": "^7.0.0",
8+
"@babel/plugin-syntax-jsx": "^7.13.13",
9+
"@babel/types": "^7.18.10",
1010
"ajv": "^6.5.3",
1111
"ajv-keywords": "^3.2.0",
1212
"generic-names": "^2.0.1",
13-
"postcss": "^7.0.2",
14-
"postcss-modules": "^1.3.2",
15-
"postcss-modules-extract-imports": "^1.2.0",
16-
"postcss-modules-local-by-default": "^1.2.0",
13+
"postcss": "^8.4.16",
14+
"postcss-modules": "^4.3.1",
15+
"postcss-modules-extract-imports": "^3.0.0",
16+
"postcss-modules-local-by-default": "^4.0.0",
1717
"postcss-modules-parser": "^1.1.1",
18-
"postcss-modules-scope": "^1.1.0",
19-
"postcss-modules-values": "^1.3.0"
18+
"postcss-modules-scope": "^3.0.0",
19+
"postcss-modules-values": "^4.0.0"
2020
},
2121
"description": "Transforms styleName to className using compile time CSS module resolution.",
2222
"devDependencies": {
@@ -28,17 +28,17 @@
2828
"@babel/preset-env": "^7.0.0",
2929
"@babel/register": "^7.0.0",
3030
"babel-core": "^7.0.0-bridge.0",
31-
"babel-jest": "^23.6.0",
32-
"babel-plugin-module-resolver": "^3.2.0",
33-
"babel-plugin-tester": "^5.5.1",
31+
"babel-jest": "^28.1.3",
32+
"babel-plugin-module-resolver": "^4.1.0",
33+
"babel-plugin-tester": "^10.1.0",
3434
"eslint": "^5.5.0",
3535
"eslint-config-canonical": "^12.0.0",
3636
"flow-bin": "^0.80.0",
3737
"husky": "^1.0.0-rc.13",
38-
"jest": "^23.5.0",
39-
"postcss-less": "^2.0.0",
40-
"postcss-nested": "^3.0.0",
41-
"postcss-scss": "^2.0.0",
38+
"jest": "^28.1.3",
39+
"postcss-less": "^6.0.0",
40+
"postcss-nested": "^5.0.6",
41+
"postcss-scss": "^4.0.4",
4242
"semantic-release": "^15.9.12"
4343
},
4444
"engines": {

src/conditionalClassMerge.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import {
44
binaryExpression,
5+
cloneNode,
56
conditionalExpression,
67
stringLiteral
78
} from '@babel/types';
@@ -12,18 +13,17 @@ export default (
1213
classNameExpression: any,
1314
styleNameExpression: any,
1415
): any => {
15-
// classNameExpression ? (classNameExpression + ' ') : '' + styleNameExpression
1616
return binaryExpression(
1717
'+',
1818
conditionalExpression(
19-
classNameExpression,
19+
cloneNode(classNameExpression),
2020
binaryExpression(
2121
'+',
22-
classNameExpression,
22+
cloneNode(classNameExpression),
2323
stringLiteral(' ')
2424
),
2525
stringLiteral('')
2626
),
27-
styleNameExpression
27+
cloneNode(styleNameExpression)
2828
);
2929
};

src/createObjectExpression.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
// @flow
22

3-
import BabelTypes, {
4-
ObjectExpression
3+
import {
4+
booleanLiteral,
5+
isAnyTypeAnnotation,
6+
ObjectExpression,
7+
objectExpression,
8+
objectProperty,
9+
stringLiteral
510
} from '@babel/types';
611

712
type InputObjectType = {
@@ -11,7 +16,7 @@ type InputObjectType = {
1116
/**
1217
* Creates an AST representation of an InputObjectType shape object.
1318
*/
14-
const createObjectExpression = (t: BabelTypes, object: InputObjectType): ObjectExpression => {
19+
const createObjectExpression = (object: InputObjectType): ObjectExpression => {
1520
const properties = [];
1621

1722
for (const name of Object.keys(object)) {
@@ -20,14 +25,14 @@ const createObjectExpression = (t: BabelTypes, object: InputObjectType): ObjectE
2025
let newValue;
2126

2227
// eslint-disable-next-line no-empty
23-
if (t.isAnyTypeAnnotation(value)) {
28+
if (isAnyTypeAnnotation(value)) {
2429

2530
} else if (typeof value === 'string') {
26-
newValue = t.stringLiteral(value);
31+
newValue = stringLiteral(value);
2732
} else if (typeof value === 'object') {
28-
newValue = createObjectExpression(t, value);
33+
newValue = createObjectExpression(value);
2934
} else if (typeof value === 'boolean') {
30-
newValue = t.booleanLiteral(value);
35+
newValue = booleanLiteral(value);
3136
} else if (typeof value === 'undefined') {
3237
// eslint-disable-next-line no-continue
3338
continue;
@@ -36,14 +41,14 @@ const createObjectExpression = (t: BabelTypes, object: InputObjectType): ObjectE
3641
}
3742

3843
properties.push(
39-
t.objectProperty(
40-
t.stringLiteral(name),
44+
objectProperty(
45+
stringLiteral(name),
4146
newValue
4247
)
4348
);
4449
}
4550

46-
return t.objectExpression(properties);
51+
return objectExpression(properties);
4752
};
4853

4954
export default createObjectExpression;

src/createSpreadMapper.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
Expression,
55
memberExpression,
66
binaryExpression,
7+
cloneNode,
78
conditionalExpression,
89
stringLiteral,
910
logicalExpression,
@@ -45,14 +46,14 @@ const createSpreadMapper = (path: *, stats: *): { [destinationName: string]: Exp
4546
'+',
4647
result[destinationName],
4748
conditionalExpression(
48-
spread.argument,
49+
cloneNode(spread.argument),
4950
binaryExpression(
5051
'+',
5152
stringLiteral(' '),
5253
logicalExpression(
5354
'||',
5455
memberExpression(
55-
spread.argument,
56+
cloneNode(spread.argument),
5657
identifier(destinationName),
5758
),
5859
stringLiteral('')
@@ -63,11 +64,11 @@ const createSpreadMapper = (path: *, stats: *): { [destinationName: string]: Exp
6364
);
6465
} else {
6566
result[destinationName] = conditionalExpression(
66-
spread.argument,
67+
cloneNode(spread.argument),
6768
logicalExpression(
6869
'||',
6970
memberExpression(
70-
spread.argument,
71+
cloneNode(spread.argument),
7172
identifier(destinationName),
7273
),
7374
stringLiteral('')

src/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default ({
6767
[
6868
t.variableDeclarator(
6969
filenameMap[filename].styleModuleImportMapIdentifier,
70-
createObjectExpression(t, filenameMap[filename].styleModuleImportMap)
70+
createObjectExpression(filenameMap[filename].styleModuleImportMap)
7171
)
7272
]
7373
)
@@ -245,7 +245,6 @@ export default ({
245245
setupFileForRuntimeResolution(path, filename);
246246
}
247247
replaceJsxExpressionContainer(
248-
t,
249248
path,
250249
attribute,
251250
destinationName,

src/replaceJsxExpressionContainer.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
// @flow
22

3-
import BabelTypes, {
3+
import {
44
binaryExpression,
5+
callExpression,
6+
cloneNode,
57
Identifier,
68
isJSXExpressionContainer,
79
isStringLiteral,
810
jSXAttribute,
911
JSXAttribute,
1012
jSXExpressionContainer,
11-
jSXIdentifier
13+
jSXIdentifier,
14+
stringLiteral
1215
} from '@babel/types';
1316
import type {
1417
GetClassNameOptionsType
@@ -18,7 +21,6 @@ import createObjectExpression from './createObjectExpression';
1821
import optionsDefaults from './schemas/optionsDefaults';
1922

2023
export default (
21-
t: BabelTypes,
2224
// eslint-disable-next-line flowtype/no-weak-types
2325
path: Object,
2426
sourceAttribute: JSXAttribute,
@@ -41,18 +43,18 @@ export default (
4143

4244
const args = [
4345
expressionContainerValue.expression,
44-
styleModuleImportMapIdentifier
46+
cloneNode(styleModuleImportMapIdentifier)
4547
];
4648

4749
// Only provide options argument if the options are something other than default
4850
// This helps save a few bits in the generated user code
4951
if (options.handleMissingStyleName !== optionsDefaults.handleMissingStyleName ||
5052
options.autoResolveMultipleImports !== optionsDefaults.autoResolveMultipleImports) {
51-
args.push(createObjectExpression(t, options));
53+
args.push(createObjectExpression(options));
5254
}
5355

54-
const styleNameExpression = t.callExpression(
55-
t.clone(importedHelperIndentifier),
56+
const styleNameExpression = callExpression(
57+
cloneNode(importedHelperIndentifier),
5658
args
5759
);
5860

@@ -63,7 +65,7 @@ export default (
6365
jSXExpressionContainer(
6466
binaryExpression(
6567
'+',
66-
t.stringLiteral(destinationAttribute.value.value + ' '),
68+
stringLiteral(destinationAttribute.value.value + ' '),
6769
styleNameExpression
6870
)
6971
)

src/requireCssModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export default (cssSourceFilePath: string, options: OptionsType): StyleModuleMap
124124
Values,
125125
LocalByDefault,
126126
ExtractImports,
127-
new Scope({
127+
Scope({
128128
generateScopedName
129129
}),
130130
new Parser({
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.a {
22
background-color: #ffffff;
3-
4-
&_modified {
5-
background-color: #000000;
6-
}
3+
}
4+
5+
.a_modified {
6+
background-color: #000000;
77
}

0 commit comments

Comments
 (0)