Update to PostCSS 8

Jan Tojnar 3 years ago
parent 2442998218
commit 2203ac48b7

@ -3,18 +3,13 @@
const { validateArguments } = require("@validatem/core"); const { validateArguments } = require("@validatem/core");
const ValidationError = require("@validatem/error"); const ValidationError = require("@validatem/error");
const isBoolean = require("@validatem/is-boolean"); const isBoolean = require("@validatem/is-boolean");
const isPostcssPlugin = require("@validatem/is-postcss-plugin");
const isString = require("@validatem/is-string"); const isString = require("@validatem/is-string");
const required = require("@validatem/required"); const required = require("@validatem/required");
const arrayOf = require("@validatem/array-of"); const arrayOf = require("@validatem/array-of");
const oneOf = require("@validatem/one-of"); const oneOf = require("@validatem/one-of");
const allowExtraProperties = require("@validatem/allow-extra-properties"); const allowExtraProperties = require("@validatem/allow-extra-properties");
function isPostcssPlugin(value) {
if (value.postcssPlugin == null || value.postcssVersion == null || typeof value !== "function") {
throw new ValidationError(`Must be a PostCSS plugin`);
}
}
// FIXME: When there's >1 icssify instance set up on the Browserify instance (can this happen when a module specifies its own dependency on icssify?), either throw an error (if incompatible?) or merge the two somehow, so that there's only one resulting .css file // FIXME: When there's >1 icssify instance set up on the Browserify instance (can this happen when a module specifies its own dependency on icssify?), either throw an error (if incompatible?) or merge the two somehow, so that there's only one resulting .css file
module.exports = function (browserify, options) { module.exports = function (browserify, options) {

@ -27,6 +27,7 @@
"@validatem/core": "^0.3.15", "@validatem/core": "^0.3.15",
"@validatem/error": "^1.1.0", "@validatem/error": "^1.1.0",
"@validatem/is-boolean": "^0.1.1", "@validatem/is-boolean": "^0.1.1",
"@validatem/is-postcss-plugin": "^0.2.0",
"@validatem/is-string": "^1.0.0", "@validatem/is-string": "^1.0.0",
"@validatem/one-of": "^0.1.1", "@validatem/one-of": "^0.1.1",
"@validatem/required": "^0.1.1", "@validatem/required": "^0.1.1",
@ -39,15 +40,18 @@
"insert-css": "^2.0.0", "insert-css": "^2.0.0",
"map-obj": "^4.1.0", "map-obj": "^4.1.0",
"object.fromentries": "^2.0.1", "object.fromentries": "^2.0.1",
"postcss": "^6.0.9", "postcss-modules-extract-imports": "^3.0.0",
"postcss-modules-extract-imports": "^2.0.0", "postcss-modules-local-by-default": "^4.0.0",
"postcss-modules-local-by-default": "^3.0.2", "postcss-modules-scope": "^3.0.0",
"postcss-modules-scope": "^2.1.0", "postcss-modules-values": "^4.0.0",
"postcss-modules-values": "^3.0.0",
"through2": "^2.0.3" "through2": "^2.0.3"
}, },
"devDependencies": { "devDependencies": {
"@joepie91/eslint-config": "^1.1.0", "@joepie91/eslint-config": "^1.1.0",
"eslint": "^6.8.0" "eslint": "^6.8.0",
"postcss": "^8.0.0"
},
"peeerDependencies": {
"postcss": "^8.0.0"
} }
} }

@ -11,14 +11,15 @@ Licensed under:
MIT (https://opensource.org/licenses/MIT) MIT (https://opensource.org/licenses/MIT)
*/ */
const postcss = require("postcss");
const icssUtils = require("icss-utils"); const icssUtils = require("icss-utils");
const loaderUtils = require("loader-utils"); const loaderUtils = require("loader-utils");
const pluginName = 'postcss-icss-find-imports'; const pluginName = 'postcss-icss-find-imports';
module.exports = postcss.plugin(pluginName, (_options = {}) => { module.exports = (_options = {}) => {
return function process(css, result) { return {
postcssPlugin: pluginName,
Once(root, { result }) {
let discoveredImports = new Set(); let discoveredImports = new Set();
let { icssImports } = icssUtils.extractICSS(css, false); let { icssImports } = icssUtils.extractICSS(css, false);
@ -34,5 +35,8 @@ module.exports = postcss.plugin(pluginName, (_options = {}) => {
url: url url: url
}); });
} }
},
}; };
}); };
module.exports.postcss = true;

@ -11,7 +11,6 @@ Licensed under:
MIT (https://opensource.org/licenses/MIT) MIT (https://opensource.org/licenses/MIT)
*/ */
const postcss = require("postcss");
const icssUtils = require("icss-utils"); const icssUtils = require("icss-utils");
const loaderUtils = require("loader-utils"); const loaderUtils = require("loader-utils");
const { validateOptions } = require("@validatem/core"); const { validateOptions } = require("@validatem/core");
@ -21,13 +20,15 @@ const isFunction = require("@validatem/is-function");
const pluginName = 'postcss-icss-parser'; const pluginName = 'postcss-icss-parser';
module.exports = postcss.plugin(pluginName, (options = {}) => { module.exports = (options = {}) => {
validateOptions([options], { validateOptions([options], {
keyReplacer: [ required, isFunction ], keyReplacer: [ required, isFunction ],
autoExportImports: [ isBoolean ] autoExportImports: [ isBoolean ]
}); });
return function process(css, result) { return {
postcssPlugin: pluginName,
Once(css, { result }) {
const importReplacements = Object.create(null); const importReplacements = Object.create(null);
const { icssImports, icssExports } = icssUtils.extractICSS(css); const { icssImports, icssExports } = icssUtils.extractICSS(css);
@ -76,5 +77,8 @@ module.exports = postcss.plugin(pluginName, (options = {}) => {
item: { name, value: parsedValue } item: { name, value: parsedValue }
}); });
} }
},
}; };
}); };
module.exports.postcss = true;

Loading…
Cancel
Save