chore:更换到主分支

This commit is contained in:
张益铭
2021-03-01 15:26:05 +08:00
parent 9064b372e8
commit 6a5f1810f9
3530 changed files with 59613 additions and 479452 deletions

View File

@@ -1,5 +1,9 @@
# Changelog
## 4.0.0
- Upgraded to PostCSS 8 by Evan You (@yyx990803) https://github.com/css-modules/postcss-modules/pull/114
## 3.2.2
### Fixed

View File

@@ -301,7 +301,7 @@ Sure! Take a look at the [example](https://github.com/outpunk/postcss-modules-ex
See [PostCSS] docs for examples for your environment and don't forget to run
```
npm install --save-dev postcss-modules
npm install --save-dev postcss postcss-modules
```
[filesystemloader]: https://github.com/css-modules/css-modules-loader-core/blob/master/src/file-system-loader.js

View File

@@ -32,7 +32,7 @@ class Core {
load(sourceString, sourcePath, trace, pathFetcher) {
let parser = new _parser2.default(pathFetcher, trace);
return (0, _postcss2.default)(this.plugins.concat([parser.plugin])).process(sourceString, { from: "/" + sourcePath }).then(result => {
return (0, _postcss2.default)(this.plugins.concat([parser.plugin()])).process(sourceString, { from: "/" + sourcePath }).then(result => {
return {
injectableSource: result.css,
exportTokens: parser.exportTokens

View File

@@ -22,8 +22,14 @@ class Parser {
this.trace = trace;
}
plugin(css) {
return Promise.all(this.fetchAllImports(css)).then(() => this.linkImportedSymbols(css)).then(() => this.extractExports(css));
plugin() {
const parser = this;
return {
postcssPlugin: "css-modules-parser",
OnceExit(css) {
return Promise.all(parser.fetchAllImports(css)).then(() => parser.linkImportedSymbols(css)).then(() => parser.extractExports(css));
}
};
}
fetchAllImports(css) {

View File

@@ -92,78 +92,78 @@ function dashesCamelCase(string) {
return string.replace(/-+(\w)/g, (_, firstLetter) => firstLetter.toUpperCase());
}
module.exports = _postcss2.default.plugin(PLUGIN_NAME, (opts = {}) => {
const getJSON = opts.getJSON || _saveJSON2.default;
module.exports = (opts = {}) => {
return {
postcssPlugin: PLUGIN_NAME,
OnceExit(css, { result }) {
return _asyncToGenerator(function* () {
const getJSON = opts.getJSON || _saveJSON2.default;
const inputFile = css.source.input.file;
const pluginList = getDefaultPluginsList(opts, inputFile);
const resultPluginIndex = result.processor.plugins.findIndex(function (plugin) {
return isOurPlugin(plugin);
});
if (resultPluginIndex === -1) {
throw new Error('Plugin missing from options.');
}
const earlierPlugins = result.processor.plugins.slice(0, resultPluginIndex);
const loaderPlugins = [...earlierPlugins, ...pluginList];
const loader = getLoader(opts, loaderPlugins);
const parser = new _parser2.default(loader.fetch.bind(loader));
return (() => {
var _ref = _asyncToGenerator(function* (css, result) {
const inputFile = css.source.input.file;
const pluginList = getDefaultPluginsList(opts, inputFile);
const resultPluginIndex = result.processor.plugins.findIndex(function (plugin) {
return isOurPlugin(plugin);
});
if (resultPluginIndex === -1) {
throw new Error('Plugin missing from options.');
}
const earlierPlugins = result.processor.plugins.slice(0, resultPluginIndex);
const loaderPlugins = [...earlierPlugins, ...pluginList];
const loader = getLoader(opts, loaderPlugins);
const parser = new _parser2.default(loader.fetch.bind(loader));
yield (0, _postcss2.default)([...pluginList, parser.plugin()]).process(css, {
from: inputFile
});
yield (0, _postcss2.default)([...pluginList, parser.plugin]).process(css, {
from: inputFile
});
const out = loader.finalSource;
if (out) css.prepend(out);
const out = loader.finalSource;
if (out) css.prepend(out);
if (opts.localsConvention) {
const isFunc = typeof opts.localsConvention === "function";
if (opts.localsConvention) {
const isFunc = typeof opts.localsConvention === "function";
parser.exportTokens = Object.entries(parser.exportTokens).reduce(function (tokens, [className, value]) {
if (isFunc) {
tokens[opts.localsConvention(className, value, inputFile)] = value;
parser.exportTokens = Object.entries(parser.exportTokens).reduce(function (tokens, [className, value]) {
if (isFunc) {
tokens[opts.localsConvention(className, value, inputFile)] = value;
return tokens;
}
switch (opts.localsConvention) {
case "camelCase":
tokens[className] = value;
tokens[(0, _lodash2.default)(className)] = value;
break;
case "camelCaseOnly":
tokens[(0, _lodash2.default)(className)] = value;
break;
case "dashes":
tokens[className] = value;
tokens[dashesCamelCase(className)] = value;
break;
case "dashesOnly":
tokens[dashesCamelCase(className)] = value;
break;
}
return tokens;
}
}, {});
}
switch (opts.localsConvention) {
case "camelCase":
tokens[className] = value;
tokens[(0, _lodash2.default)(className)] = value;
result.messages.push({
type: "export",
plugin: "postcss-modules",
exportTokens: parser.exportTokens
});
break;
case "camelCaseOnly":
tokens[(0, _lodash2.default)(className)] = value;
// getJSON may return a promise
return getJSON(css.source.input.file, parser.exportTokens, result.opts.to);
})();
}
};
};
break;
case "dashes":
tokens[className] = value;
tokens[dashesCamelCase(className)] = value;
break;
case "dashesOnly":
tokens[dashesCamelCase(className)] = value;
break;
}
return tokens;
}, {});
}
result.messages.push({
type: "export",
plugin: "postcss-modules",
exportTokens: parser.exportTokens
});
// getJSON may return a promise
return getJSON(css.source.input.file, parser.exportTokens, result.opts.to);
});
return function (_x, _x2) {
return _ref.apply(this, arguments);
};
})();
});
module.exports.postcss = true;

View File

@@ -1,32 +1,32 @@
{
"_args": [
[
"postcss-modules@3.2.2",
"postcss-modules@4.0.0",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "postcss-modules@3.2.2",
"_id": "postcss-modules@3.2.2",
"_from": "postcss-modules@4.0.0",
"_id": "postcss-modules@4.0.0",
"_inBundle": false,
"_integrity": "sha1-7jkN4PnxjnYeF3jfub4maFwCxR8=",
"_integrity": "sha1-K8fydquI8/Gw+t9svXdy1DtfO5s=",
"_location": "/postcss-modules",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "postcss-modules@3.2.2",
"raw": "postcss-modules@4.0.0",
"name": "postcss-modules",
"escapedName": "postcss-modules",
"rawSpec": "3.2.2",
"rawSpec": "4.0.0",
"saveSpec": null,
"fetchSpec": "3.2.2"
"fetchSpec": "4.0.0"
},
"_requiredBy": [
"/@vue/compiler-sfc"
],
"_resolved": "http://192.168.250.101:4873/postcss-modules/-/postcss-modules-3.2.2.tgz",
"_spec": "3.2.2",
"_resolved": "http://192.168.250.101:4873/postcss-modules/-/postcss-modules-4.0.0.tgz",
"_spec": "4.0.0",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Alexander Madyankin",
@@ -39,16 +39,15 @@
"generic-names": "^2.0.1",
"icss-replace-symbols": "^1.1.0",
"lodash.camelcase": "^4.3.0",
"postcss": "^7.0.32",
"postcss-modules-extract-imports": "^2.0.0",
"postcss-modules-local-by-default": "^3.0.2",
"postcss-modules-scope": "^2.2.0",
"postcss-modules-values": "^3.0.0",
"postcss-modules-extract-imports": "^3.0.0",
"postcss-modules-local-by-default": "^4.0.0",
"postcss-modules-scope": "^3.0.0",
"postcss-modules-values": "^4.0.0",
"string-hash": "^1.1.1"
},
"description": "PostCSS plugin to use CSS Modules everywhere",
"devDependencies": {
"autoprefixer": "^9.6.1",
"autoprefixer": "^10.0.2",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-eslint": "^10.1.0",
@@ -59,6 +58,7 @@
"husky": "^4.2.5",
"jest": "^26.0.1",
"lint-staged": "^10.2.11",
"postcss": "^8.1.9",
"prettier": "^2.0.5"
},
"homepage": "https://github.com/css-modules/postcss-modules#readme",
@@ -84,6 +84,9 @@
},
"main": "build/index.js",
"name": "postcss-modules",
"peerDependencies": {
"postcss": "^8.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/css-modules/postcss-modules.git"
@@ -97,5 +100,5 @@
"test": "$(npm bin)/jest",
"transpile": "$(npm bin)/babel src -d build"
},
"version": "3.2.2"
"version": "4.0.0"
}