Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bless 4.0.0 generates empty files #91

Closed
hostep opened this issue Feb 23, 2016 · 20 comments · Fixed by #104
Closed

bless 4.0.0 generates empty files #91

hostep opened this issue Feb 23, 2016 · 20 comments · Fixed by #104

Comments

@hostep
Copy link

hostep commented Feb 23, 2016

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 [email protected]
[email protected] node_modules/bless
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected]
├── [email protected]
└── [email protected] ([email protected])

$ 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
Copy link
Author

hostep commented Feb 23, 2016

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 [email protected]
[email protected] node_modules/bless
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected]
├── [email protected]
└── [email protected] ([email protected])

$ 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
Copy link
Contributor

Strange, here's the diff: v4.0.0-alpha.1...v4.0.0

@hostep
Copy link
Author

hostep commented Feb 23, 2016

Nope, here is the diff: 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
Copy link
Author

hostep commented Feb 28, 2016

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
Copy link
Member

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

@mtscout6
Copy link
Member

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
Copy link
Author

hostep commented Apr 6, 2016

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 [email protected]
npm WARN engine [email protected]: wanted: {"node":">=4.0.0","npm":">=3.0.0"} (current: {"node":"4.4.2","npm":"2.15.2"})
[email protected] node_modules/bless
...

mtscout6 added a commit that referenced this issue Apr 6, 2016
This is an artifact of updating lodash to v4 that was missed.
mtscout6 pushed a commit that referenced this issue Apr 6, 2016
This is an artifact of updating lodash to v4 that was missed.
mtscout6 pushed a commit that referenced this issue Apr 6, 2016
This is an artifact of updating lodash to v4 that was missed.
mtscout6 added a commit that referenced this issue Apr 6, 2016
Fix lodash error as reported in #91
@mtscout6
Copy link
Member

mtscout6 commented Apr 6, 2016

@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
Copy link
Author

hostep commented Apr 7, 2016

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 [email protected]: wanted: {"node":">=4.0.0","npm":">=3.0.0"} (current: {"node":"4.4.2","npm":"2.15.2"})
[email protected] node_modules/bless
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected]
├── [email protected]
└── [email protected] ([email protected])

$ 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
Copy link
Member

mtscout6 commented Apr 7, 2016

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
Copy link
Author

hostep commented Apr 7, 2016

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
Copy link

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

@jonscottclark
Copy link

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
Copy link

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

@Lyquix
Copy link

Lyquix commented May 20, 2016

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
Copy link

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
Copy link

Lyquix commented Jun 15, 2016

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
Copy link
Member

mtscout6 commented Jun 16, 2016

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
Copy link
Member

Fix released in v4.0.3

@hostep
Copy link
Author

hostep commented Jun 18, 2016

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

Tnx a lot @mtscout6!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants