BlessCSS / bless

CSS Post-Processor
blesscss.com
MIT License
282 stars 60 forks source link

bless 4.0.0 generates empty files #91

Closed hostep closed 8 years ago

hostep commented 8 years ago

Hi guys

Just testing out the new version of Bless, which looks awesome. Unfortunately I can't get it to work, it generates the splitted files, but the files are empty.

As a test I download bootstrap 3.3.6 and duplicated the content to get to enough selectors. But we also have it for other css files, bootstrap was just used as an example here:

$ cat bootstrap.css > big-bootstrap.css

$ cat bootstrap.css >> big-bootstrap.css

$ npm install bless@4.0.0
bless@4.0.0 node_modules/bless
├── format-number@1.0.2
├── colors@1.1.2
├── fs-promise@0.3.1 (any-promise@0.1.0)
├── yargs@3.32.0 (camelcase@2.1.0, window-size@0.1.4, y18n@3.2.0, decamelize@1.1.2, cliui@3.1.0, string-width@1.0.1, os-locale@1.4.0)
├── css@2.2.1 (inherits@2.0.1, urix@0.1.0, source-map@0.1.43, source-map-resolve@0.3.1)
├── columnify@1.5.4 (strip-ansi@3.0.1, wcwidth@1.0.0)
├── lodash@3.10.1
├── rx@2.5.3
└── babel-runtime@5.8.35 (core-js@1.2.6)

$ node_modules/.bin/blessc count big-bootstrap.css
.
File Path    Selector Count (Limit: 4095)
             5,014

$ node_modules/.bin/blessc chunk big-bootstrap.css
Complete

$ ls -l
total 864
-rw-r--r--  1 me  staff     0B Feb 23 21:51 big-bootstrap.0.css
-rw-r--r--  1 me  staff     0B Feb 23 21:51 big-bootstrap.1.css
-rw-r--r--  1 me  staff   285K Feb 23 21:50 big-bootstrap.css
-rw-r--r--@ 1 me  staff   143K Nov 24 19:34 bootstrap.css
drwxr-xr-x  5 me  staff   170B Feb 23 21:50 node_modules

You can see the big-bootstrap.#.css files are empty here.

My node version is 4.3.1 in case it matters...

Any idea's?

hostep commented 8 years ago

A quick update, I just tested this with version 4.0.0-alpha.0, and that works, so something must have gone wrong between that version and the "stable" version ;)

$ npm install bless@4.0.0-alpha.0
bless@4.0.0-alpha.0 node_modules/bless
├── format-number@1.0.2
├── colors@1.1.2
├── fs-promise@0.3.1 (any-promise@0.1.0)
├── css@2.2.1 (inherits@2.0.1, urix@0.1.0, source-map-resolve@0.3.1, source-map@0.1.43)
├── columnify@1.5.4 (strip-ansi@3.0.1, wcwidth@1.0.0)
├── yargs@3.32.0 (camelcase@2.1.0, window-size@0.1.4, y18n@3.2.0, decamelize@1.1.2, cliui@3.1.0, os-locale@1.4.0, string-width@1.0.1)
├── lodash@3.10.1
├── rx@2.5.3
└── babel-runtime@5.8.35 (core-js@1.2.6)

$ node_modules/.bin/blessc chunk big-bootstrap.css
complete

$ ls -l
total 1440
-rw-r--r--  1 me  staff   220K Feb 23 23:15 big-bootstrap.0.css
-rw-r--r--  1 me  staff    67K Feb 23 23:15 big-bootstrap.1.css
-rw-r--r--  1 me  staff   285K Feb 23 21:50 big-bootstrap.css
-rw-r--r--@ 1 me  staff   143K Nov 24 19:34 bootstrap.css
drwxr-xr-x  5 me  staff   170B Feb 23 23:15 node_modules
paulyoung commented 8 years ago

Strange, here's the diff: https://github.com/BlessCSS/bless/compare/v4.0.0-alpha.1...v4.0.0

hostep commented 8 years ago

Nope, here is the diff: https://github.com/BlessCSS/bless/compare/v4.0.0-alpha.0...v4.0.0 ;)

I can't install 'alpha.1', only 'alpha.0' since it wasn't published on npm.

hostep commented 8 years ago

Am I the only one who has this problem? Can someone confirm if it actually works with version 4.0.0 on their system?

aabenoja commented 8 years ago

Not just you. I'll look into it when I can spare the time.

mtscout6 commented 8 years ago

There was an update to fs-promise that seems to have fix a number of file parsing issues. Let's see if #96 fixes this. That along with an update to Node >=4.0.

hostep commented 8 years ago

Hi guys

I just tested again using the new version 4.0.1 and the issue remains :(

And next to that, the count functionality now throws an error:

$ node_modules/.bin/blessc count big-bootstrap.css
.
File Path    Selector Count (Limit: 4095)
             5,014
TypeError: _lodash2.default.any is not a function

Although this might have something to do with the fact that I'm using the LTS version of npm and apparently you stopped supporting this for some reason?

$ npm install bless@4.0.1
npm WARN engine bless@4.0.1: wanted: {"node":">=4.0.0","npm":">=3.0.0"} (current: {"node":"4.4.2","npm":"2.15.2"})
bless@4.0.1 node_modules/bless
...
mtscout6 commented 8 years ago

@hostep you mentioned in #100 that the chunk command is still not working for you. Can you provide more information? I ran it against the ./test/fixtures/input files and it is working for me.

I'm on Node v4.2.3 and npm v3.7.3, though I wouldn't imagine that those are the problem.

hostep commented 8 years ago

I tested a few of the files inside the test/fixtures/input path of the repo, and they are still empty:

$ mkdir bless-testing && cd bless-testing

$ git clone https://github.com/BlessCSS/bless.git bless-repo
Cloning into 'bless-repo'...
remote: Counting objects: 1171, done.
remote: Compressing objects: 100% (24/24), done.
remote: Total 1171 (delta 6), reused 0 (delta 0), pack-reused 1147
Receiving objects: 100% (1171/1171), 224.56 KiB | 0 bytes/s, done.
Resolving deltas: 100% (512/512), done.
Checking connectivity... done.

$ npm install bless
npm WARN engine bless@4.0.2: wanted: {"node":">=4.0.0","npm":">=3.0.0"} (current: {"node":"4.4.2","npm":"2.15.2"})
bless@4.0.2 node_modules/bless
├── format-number@2.0.1
├── colors@1.1.2
├── columnify@1.5.4 (strip-ansi@3.0.1, wcwidth@1.0.0)
├── yargs@3.32.0 (decamelize@1.2.0, camelcase@2.1.1, y18n@3.2.1, window-size@0.1.4, os-locale@1.4.0, string-width@1.0.1, cliui@3.1.2)
├── css@2.2.1 (inherits@2.0.1, urix@0.1.0, source-map-resolve@0.3.1, source-map@0.1.43)
├── fs-promise@0.5.0 (any-promise@1.1.0, thenify-all@1.6.0, mz@2.4.0, fs-extra@0.26.7)
├── rx@4.1.0
├── lodash@4.8.2
└── babel-runtime@6.6.1 (core-js@2.2.2)

$ node_modules/.bin/blessc chunk bless-repo/test/fixtures/input/over-limit.css --out-dir .
Complete

$ node_modules/.bin/blessc chunk bless-repo/test/fixtures/input/twice-over-limit.css --out-dir .
Complete

$ ls -l
total 0
drwxr-xr-x  21 me  staff   714B  7 apr 19:19 bless-repo
drwxr-xr-x   4 me  staff   136B  7 apr 19:19 node_modules
-rw-r--r--   1 me  staff     0B  7 apr 19:22 over-limit.0.css
-rw-r--r--   1 me  staff     0B  7 apr 19:22 over-limit.1.css
-rw-r--r--   1 me  staff     0B  7 apr 19:23 twice-over-limit.0.css
-rw-r--r--   1 me  staff     0B  7 apr 19:23 twice-over-limit.1.css
-rw-r--r--   1 me  staff     0B  7 apr 19:23 twice-over-limit.2.css

$ node --version
v4.4.2

$ npm --version
2.15.2

$ node_modules/.bin/blessc --version
v4.0.2

If I can help in some other way, please let me know (although I have no experience whatsoever with developing nodejs applications)

mtscout6 commented 8 years ago

Ok, I'm seeing the issue now. Though for some reason it works on some files:

➜  tmp git:(master) ✗ ls -l ./folder-test
total 512
-rw-r--r--  1 smithm  staff   1694 Apr  7 11:42 at-rules.0.css
-rw-r--r--  1 smithm  staff    462 Apr  7 11:42 keyframes.0.css
-rw-r--r--  1 smithm  staff  28678 Apr  7 11:42 nested-media-queries.0.css
-rw-r--r--  1 smithm  staff    254 Apr  7 11:42 nested-media-queries.1.css
-rw-r--r--  1 smithm  staff      0 Apr  7 11:42 no-selectors.0.css
-rw-r--r--  1 smithm  staff  28675 Apr  7 11:42 over-limit-inside-media-query.0.css
-rw-r--r--  1 smithm  staff    113 Apr  7 11:42 over-limit-inside-media-query.1.css
-rw-r--r--  1 smithm  staff  28675 Apr  7 11:42 over-limit-inside-rule.0.css
-rw-r--r--  1 smithm  staff     31 Apr  7 11:42 over-limit-inside-rule.1.css
-rw-r--r--  1 smithm  staff  28682 Apr  7 11:42 over-limit-with-at-page.0.css
-rw-r--r--  1 smithm  staff    115 Apr  7 11:42 over-limit-with-at-page.1.css
-rw-r--r--  1 smithm  staff  28909 Apr  7 11:42 over-limit-with-at-rules.0.css
-rw-r--r--  1 smithm  staff   1374 Apr  7 11:42 over-limit-with-at-rules.1.css
-rw-r--r--  1 smithm  staff  28727 Apr  7 11:42 over-limit-with-comment.0.css
-rw-r--r--  1 smithm  staff     36 Apr  7 11:42 over-limit-with-comment.1.css
-rw-r--r--  1 smithm  staff  28810 Apr  7 11:42 over-limit-with-keyframes.0.css
-rw-r--r--  1 smithm  staff      0 Apr  7 11:42 over-limit-with-media-query.0.css
-rw-r--r--  1 smithm  staff      0 Apr  7 11:42 over-limit-with-media-query.1.css
-rw-r--r--  1 smithm  staff      0 Apr  7 11:42 over-limit.0.css
-rw-r--r--  1 smithm  staff      0 Apr  7 11:42 over-limit.1.css
-rw-r--r--  1 smithm  staff      0 Apr  7 11:42 twice-over-limit.0.css
-rw-r--r--  1 smithm  staff      0 Apr  7 11:42 twice-over-limit.1.css
-rw-r--r--  1 smithm  staff      0 Apr  7 11:42 twice-over-limit.2.css
-rw-r--r--  1 smithm  staff      0 Apr  7 11:42 under-limit-with-comment.0.css
-rw-r--r--  1 smithm  staff      0 Apr  7 11:42 under-limit.0.css

I'm not sure of the cause yet though.

hostep commented 8 years ago

I saw that too, if you run it on the entire directory some work, some don't. But if you run it one file at the time, they are all empty. Very strange behavior...

whjvenyl commented 8 years ago

This issue get's resolved if you use fsp.writeFileSync instead of the asyncronous version in chunk.js

jonscottclark commented 8 years ago

I'm getting this issue as well.

Bless v. 4.0.2

Went into the source and made the change that @whjvenyl suggested, and then it worked.

jonscottclark commented 8 years ago

Works when using it with gulp-bless which seems to also be getting v. 4.0.2 — Now I am very confused.

Lyquix commented 8 years ago

Having the same issue in 2 different environments:

bless: 4.0.2 npm: 3.9.2 nodejs: 4.4.3 running in git bash terminal in windows

and bless: 4.0.2 npm: 3.9.2 nodejs: 4.4.4 running in ubuntu 14.04

I get empty files even with suggestion from @jonscottclark on dabbcf5

I have a CSS file with 8379 selectors, built from LESS and passed through PostCSS Autoprefixer. You can find it here: https://gist.github.com/Lyquix/9e6533e4f7b3754cbd627acbe14773ee

Processing the same file with Bless 3.0.3 works.

coffeemug777 commented 8 years ago

I had the same issue.

I tried dabbcf5 and it didn't work.

I managed to fix it by using whjvenyl's suggestion (change writeFile to writeFileSync) on /usr/local/lib/node_modules/bless/lib/commands/chunk.js

bless: v4.0.2 npm: 3.8.3 node: v5.10.1 Ubuntu 14.04

Lyquix commented 8 years ago

Thanks @coffeemug777 !

I confirm that making the changes in the files /usr/local/lib/node_modules/bless/lib/commands/chunk.js (and for Windows, C:\Users\<Username>\AppData\Roaming\npm\node_modules\bless\lib\commands\chunk.js) fixes the problem.

mtscout6 commented 8 years ago

The problem with changing it to writeFileSync is that you would then force a blocking File IO operation. This will significantly slow down the tool when processing a large folder of css files.

I believe I have found the proper fix as outlined in PR #104 can you all test and confirm?

mtscout6 commented 8 years ago

Fix released in v4.0.3

hostep commented 8 years ago

I can confirm that the issue is fixed in v4.0.3.

Tnx a lot @mtscout6!