Skip to content

Commit d3cc5b4

Browse files
committed
feat: bump m-css
1 parent 837853e commit d3cc5b4

29 files changed

+2353
-1922
lines changed

README.md

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -122,39 +122,6 @@ as global.
122122

123123
**How to migrate:** Change to the parameterized form `:global(.token) {}`
124124

125-
#### `valueAliasing`
126-
127-
`css-modules` version of `@value`s allows for individually aliasing imported names:
128-
129-
```css
130-
@value primary as utilsPrimary from './utils.css';
131-
132-
.foo {
133-
color: utilsPrimary;
134-
}
135-
```
136-
137-
`modular-css` only (currently) allows importing by the exact name OR namespacing the entire import
138-
like: `@value * as utils from './utils.css';`
139-
140-
> Note: enabling this will also enable `icssImports` which is used to implement it.
141-
142-
**When to enable:** If you `@value` aliases, e.g.
143-
144-
```css
145-
@value primary as utilsPrimary from './utils.css';
146-
```
147-
148-
**How to migrate:** Switch to using `@value * as ns` to handle conflicts (see: https://m-css.com/guide/#namespaces)
149-
150-
```css
151-
@value * as utils from './utils.css';
152-
153-
.foo {
154-
color: utils.primary;
155-
}
156-
```
157-
158125
#### `icssExports`
159126

160127
A very niche feature of css-modules that you may not even know is possible.

lib/Utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const mapValues = require('lodash/mapValues');
21
const findLast = require('lodash/findLast');
2+
const mapValues = require('lodash/mapValues');
33

44
function getExports(file, messages, opts = {}) {
55
const lastClsMsg = findLast(messages, 'classes');
@@ -9,8 +9,8 @@ function getExports(file, messages, opts = {}) {
99
opts.exportValues ? mapValues(file.values, ({ value }) => value) : null,
1010
lastClsMsg.classes,
1111
...messages
12-
.filter(m => m.plugin && m.plugin.startsWith('modular-css-export'))
13-
.map(m => m.exports),
12+
.filter((m) => m.plugin && m.plugin.startsWith('modular-css-export'))
13+
.map((m) => m.exports),
1414
);
1515
}
1616

lib/getLocalName.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** Taken from css-loader */
22

33
const path = require('path');
4+
45
const cssesc = require('cssesc');
56
const loaderUtils = require('loader-utils');
67

lib/loader.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
const path = require('path');
2+
const { promisify } = require('util');
23

34
const Processor = require('@modular-css/processor');
4-
const { promisify } = require('util');
55
const { getOptions } = require('loader-utils');
6+
67
const getLocalName = require('./getLocalName');
78

89
const PROCESSOR = Symbol('@modular-css processor');
910
const CACHE = Symbol('loadModule cache module');
1011

1112
const compatPlugins = {
1213
scoping: require('./plugins/compat-scope-pseudos'),
13-
valueAliasing: require('./plugins/compat-value-aliasing'),
14+
// valueAliasing: require('./plugins/compat-value-aliasing'),
1415
icssImport: require('./plugins/compat-icss-import'),
1516
icssExport: require('./plugins/compat-icss-export'),
1617
};
@@ -19,7 +20,7 @@ function getLoadFilePrefix(loaderContext) {
1920
// loads a file with all loaders configured after this one
2021
const loadersRequest = loaderContext.loaders
2122
.slice(loaderContext.loaderIndex + 1)
22-
.map(x => x.request)
23+
.map((x) => x.request)
2324
.join('!');
2425

2526
return `-!${require.resolve('./stringifyLoader')}!${loadersRequest}!`;
@@ -77,11 +78,11 @@ function loader(src) {
7778
if (typeof options.compat === 'object') {
7879
const names = new Set(
7980
Object.entries(options.compat)
80-
.filter(e => e[1])
81-
.map(e => e[0]),
81+
.filter((e) => e[1])
82+
.map((e) => e[0]),
8283
);
8384

84-
compat = compat.filter(e => names.has(e[0]));
85+
compat = compat.filter((e) => names.has(e[0]));
8586
}
8687

8788
compat = compat.map(([, plugin]) => plugin);
@@ -97,11 +98,11 @@ function loader(src) {
9798
namer: (filename, localName) =>
9899
getLocalName(filename, localName, this, options),
99100
before: compat
100-
.filter(p => p.phase === 'before')
101+
.filter((p) => p.phase === 'before')
101102
.concat(options.before)
102103
.filter(Boolean),
103104
processing: []
104-
.concat(compat.filter(p => p.phase === 'processing'))
105+
.concat(compat.filter((p) => p.phase === 'processing'))
105106
.concat(require('./plugins/icss-import-export'), options.processing)
106107
.filter(Boolean),
107108
};
@@ -124,7 +125,7 @@ function loader(src) {
124125
},
125126
});
126127
},
127-
err => {
128+
(err) => {
128129
cb(err);
129130
},
130131
);

lib/plugins/compat-icss-export.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const plugin = 'css-modules-loader-compat-icss-export';
66
module.exports = (css, { messages }) => {
77
const exported = Object.create(null);
88

9-
css.walkRules(':export', rule => {
10-
rule.walkDecls(decl => {
9+
css.walkRules(':export', (rule) => {
10+
rule.walkDecls((decl) => {
1111
exported[decl.prop] = decl.value;
1212
});
1313

lib/plugins/compat-icss-import.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = (css, { opts }) => {
1313

1414
const replacements = Object.create(null);
1515
// console.log(files);
16-
css.walkRules(/^:import/, rule => {
16+
css.walkRules(/^:import/, (rule) => {
1717
const matches = importPattern.exec(rule.selector);
1818

1919
if (!matches) return;
@@ -22,7 +22,7 @@ module.exports = (css, { opts }) => {
2222

2323
const source = files[resolve(from, path)];
2424

25-
rule.walkDecls(decl => {
25+
rule.walkDecls((decl) => {
2626
const localName = decl.prop;
2727
const name = decl.value;
2828
if (!(name in source.values)) {
@@ -35,7 +35,7 @@ module.exports = (css, { opts }) => {
3535
rule.remove();
3636
});
3737

38-
css.walk(node => {
38+
css.walk((node) => {
3939
if (node.type === 'decl' && node.value) {
4040
node.value = replaceValueSymbols(node.value.toString(), replacements);
4141
} else if (node.type === 'atrule' && node.params) {

lib/plugins/compat-scope-pseudos.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ const selectorParser = require('postcss-selector-parser');
88

99
const plugin = 'css-modules-loader-compat-scope-pseudos';
1010

11-
const isSpacing = node => node.type === 'combinator' && node.value === ' ';
11+
const isSpacing = (node) => node.type === 'combinator' && node.value === ' ';
1212

13-
const isScopePseudo = node =>
13+
const isScopePseudo = (node) =>
1414
node.value === ':local' || node.value === ':global';
1515

1616
function normalizeNodeArray(nodes) {
1717
const array = [];
1818

19-
nodes.forEach(x => {
19+
nodes.forEach((x) => {
2020
if (Array.isArray(x)) {
21-
normalizeNodeArray(x).forEach(item => {
21+
normalizeNodeArray(x).forEach((item) => {
2222
array.push(item);
2323
});
2424
} else if (x) {
@@ -46,7 +46,7 @@ function localizeNode(rule) {
4646
case 'root': {
4747
let resultingGlobal;
4848

49-
newNodes = node.nodes.map(n => {
49+
newNodes = node.nodes.map((n) => {
5050
const nContext = {
5151
global: context.global,
5252
lastWasSpacing: true,
@@ -71,7 +71,7 @@ function localizeNode(rule) {
7171
break;
7272
}
7373
case 'selector': {
74-
newNodes = node.map(childNode => transform(childNode, context));
74+
newNodes = node.map((childNode) => transform(childNode, context));
7575

7676
node = node.clone();
7777
node.nodes = normalizeNodeArray(newNodes);
@@ -117,7 +117,7 @@ function localizeNode(rule) {
117117
}
118118

119119
newNodes = node
120-
.map(childNode => transform(childNode, childContext))
120+
.map((childNode) => transform(childNode, childContext))
121121
.reduce((acc, next) => acc.concat(next.nodes), []);
122122

123123
if (newNodes.length) {
@@ -139,7 +139,7 @@ function localizeNode(rule) {
139139
inside: context.inside,
140140
lastWasSpacing: true,
141141
};
142-
newNodes = node.map(childNode =>
142+
newNodes = node.map((childNode) =>
143143
transform(childNode, childContext),
144144
);
145145

@@ -211,15 +211,15 @@ function localizeNode(rule) {
211211
global: false,
212212
};
213213

214-
rootContext.selector = selectorParser(root => {
214+
rootContext.selector = selectorParser((root) => {
215215
transform(root, rootContext);
216216
}).processSync(rule, { updateSelector: false, lossless: true });
217217

218218
return rootContext;
219219
}
220220

221-
module.exports = css => {
222-
css.walkRules(rule => {
221+
module.exports = (css) => {
222+
css.walkRules((rule) => {
223223
if (
224224
rule.parent &&
225225
rule.parent.type === 'atrule' &&

lib/plugins/compat-value-aliasing.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const matchImport = /^([\w-*]+)(?:\s+as\s+([\w-]+))?/;
1111
module.exports = (css, { messages, opts }) => {
1212
const importAliases = [];
1313

14-
css.walkAtRules('value', atRule => {
14+
css.walkAtRules('value', (atRule) => {
1515
const matches = matchImports.exec(atRule.params);
1616
if (matches) {
1717
// eslint-disable-next-line prefer-const
@@ -20,7 +20,7 @@ module.exports = (css, { messages, opts }) => {
2020
const imports = aliases
2121
.replace(/^\(\s*([\s\S]+)\s*\)$/, '$1')
2222
.split(/\s*,\s*/)
23-
.map(importValue => {
23+
.map((importValue) => {
2424
const tokens = matchImport.exec(importValue);
2525
if (tokens) {
2626
const [, name, alias] = tokens;

lib/plugins/icss-import-export.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const path = require('path');
2+
23
const postcss = require('postcss');
4+
35
const { getExports } = require('../Utils');
46

57
const plugin = 'css-modules-loader-icss-import/exports';
@@ -18,7 +20,7 @@ module.exports = (css, { opts, messages }) => {
1820
const imported = graph.outgoingEdges[from];
1921
const exported = getExports(file, messages, opts);
2022

21-
imported.forEach(dep =>
23+
imported.forEach((dep) =>
2224
css.prepend(
2325
postcss.rule({
2426
selector: `:import("${path.relative(path.dirname(from), dep)}")`,

package.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-module-loader",
3-
"version": "1.0.0-beta.3",
3+
"version": "1.0.0-beta.4",
44
"main": "lib/loader.js",
55
"repository": {
66
"type": "git",
@@ -46,48 +46,48 @@
4646
},
4747
"release": {},
4848
"devDependencies": {
49-
"@4c/cli": "^1.0.5",
49+
"@4c/cli": "^2.1.8",
5050
"@4c/import-sort": "^4.3.6",
51-
"@4c/jest-preset": "^1.4.4",
51+
"@4c/jest-preset": "^1.5.0",
5252
"@4c/prettier-config": "^1.1.0",
53-
"css-loader": "^3.4.2",
53+
"css-loader": "^3.5.3",
5454
"eslint": "^6.8.0",
55-
"eslint-config-4catalyzer": "^1.0.2",
56-
"eslint-config-4catalyzer-jest": "^2.0.3",
57-
"eslint-config-prettier": "^6.10.0",
58-
"eslint-plugin-import": "^2.20.1",
59-
"eslint-plugin-jest": "^23.6.0",
60-
"eslint-plugin-prettier": "^3.1.2",
61-
"husky": "^4.2.1",
62-
"jest": "^25.1.0",
55+
"eslint-config-4catalyzer": "^1.1.1",
56+
"eslint-config-4catalyzer-jest": "^2.0.6",
57+
"eslint-config-prettier": "^6.11.0",
58+
"eslint-plugin-import": "^2.20.2",
59+
"eslint-plugin-jest": "^23.8.2",
60+
"eslint-plugin-prettier": "^3.1.3",
61+
"husky": "^4.2.5",
62+
"jest": "^25.5.1",
6363
"jest-file-snapshot": "^0.3.8",
64-
"lint-staged": "^10.0.7",
65-
"memfs": "^3.0.4",
64+
"lint-staged": "^10.2.0",
65+
"memfs": "^3.1.2",
6666
"mini-css-extract-plugin": "^0.9.0",
67-
"prettier": "^1.19.1",
68-
"sass": "^1.25.0",
67+
"prettier": "^2.0.5",
68+
"sass": "^1.26.5",
6969
"strip-ansi": "^6.0.0",
70-
"webpack-atoms": "^12.1.0",
71-
"webpack-cli": "^3.3.10",
70+
"webpack-atoms": "^13.0.1",
71+
"webpack-cli": "^3.3.11",
7272
"webpack-dev-server": "^3.10.3"
7373
},
7474
"dependencies": {
75-
"@modular-css/processor": "^25.3.1",
75+
"@modular-css/processor": "^25.6.0",
7676
"cssesc": "^3.0.0",
77-
"fs-extra": "^8.1.0",
77+
"fs-extra": "^9.0.0",
7878
"icss-utils": "^4.1.1",
79-
"loader-utils": "^1.2.3",
79+
"loader-utils": "^2.0.0",
8080
"lodash": "^4.17.15",
8181
"memory-fs": "^0.5.0",
82-
"postcss": "^7.0.26",
82+
"postcss": "^7.0.27",
8383
"postcss-selector-parser": "^6.0.2",
8484
"sass-loader": "^8.0.2",
85-
"webpack": "^4.41.5"
85+
"webpack": "^4.43.0"
8686
},
8787
"bugs": {
8888
"url": "https://github.com/4Catalyzer/css-module-loader/issues"
8989
},
9090
"readme": "ERROR: No README data found!",
9191
"homepage": "https://github.com/4Catalyzer/css-module-loader#readme",
92-
"_id": "css-module-loader@1.0.0-beta.2"
92+
"_id": "css-module-loader@1.0.0-beta.3"
9393
}

test/__file_snapshots__/compat-all-js.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"use strict";
1111
__webpack_require__.r(__webpack_exports__);
1212
// extracted by mini-css-extract-plugin
13-
/* harmony default export */ __webpack_exports__["default"] = ({"base":"base--base--1uAtd"});
13+
/* harmony default export */ __webpack_exports__["default"] = ({"base":"base--base--61APe"});
1414

1515
/***/ }),
1616

@@ -24,7 +24,7 @@ __webpack_require__.r(__webpack_exports__);
2424
"use strict";
2525
__webpack_require__.r(__webpack_exports__);
2626
// extracted by mini-css-extract-plugin
27-
/* harmony default export */ __webpack_exports__["default"] = ({"button":"base--base--1uAtd button--button--32Qrn"});
27+
/* harmony default export */ __webpack_exports__["default"] = ({"button":"base--base--61APe button--button--3RyHa"});
2828

2929
/***/ }),
3030

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.base--base--1uAtd {
1+
.base--base--61APe {
22
color: blue;
33
}
4-
.button--button--32Qrn {
4+
.button--button--3RyHa {
55
color: red;
66
}

test/__file_snapshots__/externals-js.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"use strict";
1111
__webpack_require__.r(__webpack_exports__);
1212
// extracted by mini-css-extract-plugin
13-
/* harmony default export */ __webpack_exports__["default"] = ({"toolbar":"externals--toolbar--3HGQb"});
13+
/* harmony default export */ __webpack_exports__["default"] = ({"toolbar":"externals--toolbar--3bNYz"});
1414

1515
/***/ }),
1616

0 commit comments

Comments
 (0)