Compare commits

...

6 Commits

@ -76,6 +76,11 @@ Plugin options (all optional):
## Changelog
### 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.
- __Bug:__ Fall back to working directory for relative path calculation, when no explicit entry path is specified.
### v1.0.0 (November 24, 2019)
Initial release.

@ -7,6 +7,8 @@ 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");
// 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) {
/* Not shown here: the default 'deps' phase stream will process all the CSS files through our custom transform (defined elsewhere). That transform handles the discovery of CSS dependencies, by pre-processing the CSS files (normalizing 'composes' statements etc. into :import/:export statements), and then extracting all the imports from them, emitting them to Browserify as additional dependencies to fetch. */

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

@ -16,8 +16,11 @@ module.exports = function createDedupeBundleCssStream(options) {
let allCss = "";
let loaderItem;
// Get the (absolute!) path of the folder containing the initial entry file, as a reference point for relative paths in the output
let entryPoint = path.dirname(path.resolve(options._flags.entries[0]));
let entryPoint = (options._flags.entries != null)
// Get the (absolute!) path of the folder containing the initial entry file, as a reference point for relative paths in the output
? path.dirname(path.resolve(options._flags.entries[0]))
// ... or, if no entry file is specified, go off the current working directory
: process.cwd()
return stream((item) => {
// And the same for the loader shim path. All this relative-path stuff is to prevent absolute filesystem URLs from leaking into the output, as those might contain sensitive information.

@ -5,13 +5,14 @@ const through2 = require("through2");
const assureArray = require("assure-array");
function wrapStreamHandler(stream, handler, callback, item) {
return Promise.try(() => {
Promise.try(() => {
return handler(item);
}).then((result) => {
return assureArray(result);
}).each((newItem) => {
stream.push(newItem);
}).then(() => {
// TODO: Fix the "a promise was created in a handler at [...] but was not returned from it" Bluebird warning that occurs here
callback();
}).catch((err) => {
callback(err);

@ -17,11 +17,12 @@ module.exports = function createTransform(file, options) {
let buffer = new bl.BufferList();
function chunkHandler(chunk, encoding, callback) {
if (encoding === "buffer") {
// NOTE: We check the `chunk` here, not the `encoding`, because in at least one instance a Buffer was passed in claiming to be a "utf8" string according to the `encoding` argument
if (Buffer.isBuffer(chunk)) {
buffer.append(chunk);
callback();
} else {
throw new Error(`Expected Buffer, got ${encoding} string instead`);
throw new Error(`Expected Buffer, got string instead (encoding = ${encoding})`);
}
}

Loading…
Cancel
Save