rstacruz / css-condense

[unsupported] A CSS compressor that shows no mercy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type error

maxfenton opened this issue · comments

A CSS file with the following line throws a fatal error. Any idea what might be the cause?

@media (min-width: 699px) { #header__navigation--secondary li:last-child:after, #header__navigation--secondary li:nth-child(3):after { content: ""; display: table; clear: both; }
  #header__navigation--secondary li:last-child:after, #header__navigation--secondary li:nth-child(3):after { content: ''; padding-left: 0; } }

The error:

/usr/local/lib/node_modules/css-condense/node_modules/css-stringify/node_modules/css/lib/stringify/compiler.js:33
  return this[node.type](node);
                  ^
TypeError: Cannot read property 'type' of undefined
    at Compiler.visit (/usr/local/lib/node_modules/css-condense/node_modules/css-stringify/node_modules/css/lib/stringify/compiler.js:33:19)
    at Compiler.mapVisit (/usr/local/lib/node_modules/css-condense/node_modules/css-stringify/node_modules/css/lib/stringify/compiler.js:45:17)
    at Compiler.media (/usr/local/lib/node_modules/css-condense/node_modules/css-stringify/node_modules/css/lib/stringify/compress.js:61:12)
    at Compiler.visit (/usr/local/lib/node_modules/css-condense/node_modules/css-stringify/node_modules/css/lib/stringify/compiler.js:33:25)
    at Array.map (native)
    at Compiler.compile (/usr/local/lib/node_modules/css-condense/node_modules/css-stringify/node_modules/css/lib/stringify/compress.js:34:12)
    at Object.module.exports [as stringify] (/usr/local/lib/node_modules/css-condense/node_modules/css-stringify/node_modules/css/lib/stringify/index.js:40:23)
    at compressCode (/usr/local/lib/node_modules/css-condense/index.js:55:20)
    at compress (/usr/local/lib/node_modules/css-condense/index.js:27:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/css-condense/bin/cssc:51:15)

This does work: cssc --no-consolidate-via-selectors --no-sort-selectors --line-breaks --no-sort-declarations --no-sort main.css > main.condensed.css

Looks like it might be a bug with css-stringify. what version of the dependencies are you using (npm ls -g)? can you try reinstalling css-condense (npm uninstall -g css-condense && npm i -g css-condense) to see if it persists?

Still trying to sort this out @rstacruz — sorry to post a n00b question as an issue.

css-condense@0.0.6 /usr/local/lib/node_modules/css-condense
├── commander@2.3.0
├── css-parse@2.0.0 (css@2.0.0)
└── css-stringify@2.0.0 (css@2.0.0)

Having a similar issue:

/usr/local/lib/node_modules/css-condense/node_modules/css-stringify/index.js:178
      + node.declarations.map(this.declaration, this).join(';')
                          ^
TypeError: Cannot call method 'map' of undefined