Compare commits

...

3 Commits

@ -76,6 +76,10 @@ Plugin options (all optional):
## Changelog
### v1.1.0 (February 15, 2020)
- __Improvement:__ Now actually explicitly validates the `options` you specify and gives you a helpful error message, instead of a cryptic one.
### v1.0.1 (February 15, 2020)
- __Bug:__ Don't break when an upstream transform erroneously produces a Buffer while claiming it to be `encoding: "utf8"`, by ignoring the `encoding` parameter entirely.

@ -1,5 +1,7 @@
"use strict";
const { validateArguments, required, oneOf, arrayOf, allowExtraProperties, ValidationError } = require("validatem");
const createTransform = require("./src/transform");
const createCssDepsStream = require("./src/phase-streams/deps-css");
const createSyntaxHideStream = require("./src/phase-streams/syntax-hide");
@ -7,6 +9,12 @@ const createSyntaxUnhideStream = require("./src/phase-streams/syntax-unhide");
const createKahnSortingStream = require("./src/phase-streams/sort-kahn");
const createDedupeBundleCssStream = require("./src/phase-streams/dedupe-bundle-css");
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
function setupPipeline(browserify, options) {
@ -35,6 +43,17 @@ function setupPipeline(browserify, options) {
}
module.exports = function (browserify, options) {
console.log(options);
validateArguments(arguments, [
[ "browserify" ],
[ "options", allowExtraProperties({
mode: oneOf([ "local", "global" ]),
before: arrayOf([ required, isPostcssPlugin ]),
after: arrayOf([ required, isPostcssPlugin ])
})]
]);
browserify.transform(createTransform, options);
browserify.on("reset", () => {

@ -1,6 +1,6 @@
{
"name": "icssify",
"version": "1.0.1",
"version": "1.1.0",
"description": "A Browserify plugin for handling CSS (through PostCSS), with **full and correct support** for ICSS and CSS modules.",
"main": "index.js",
"repository": {

Loading…
Cancel
Save