since 1.4.0 we have minify() and earlier (eg. 1.3.12) it was ONLY justDoIt()
in csso 1.8.0 csso.minify() and csso.justDoIt() both exists and they are functions.
in csso 2.0.0 and 2.3.1 has no justDoIt() AT ALL.
I did deep research of how your suggested change can affect potential end customers/consumers of require-css.
And here is my code change suggestion:
try {
if (typeof csso.minify === 'function') {
var minifyResult = csso.minify(css);
if (typeof minifyResult === 'string'){ // for csso < 2.0.0
css = minifyResult;
} else if (typeof minifyResult === 'object'){ // for csso >= 2.0.0
css = minifyResult.css;
}
} else { // justDoIt() was always. minify() appeared in csso 1.4.0.
css = csso.justDoIt(css);
}
}
I did this, because I know enterprise projects, which still use old version of require-css and csso, so my approach is universal. Tested with:
require-css 0.1.8.
csso 1.3.12, 1.4.0, 1.8.0, 2.0.0 and latest (checked 2017/02/18) 2.3.1.
requirejs 2.1.10 and 2.3.2
node 6.9.5 + npm 3.10.10
node 7.5.2 + npm 4.1.2
command r.js -o example/build.js with optimizeCss: "standard"
Note: I realize, this change may be overthinking/overcomplex, but so far the fact is - if we merge ur current code change, someone who will upgrade to new require-css version, but remain old csso version, they will have errors like I mentioned in this PR and in #203.
So @prantlf please consider my code above as a suggestion to apply to your PR. After 1 week silence, I will close this PR, and recreate new one with my suggested code.
csso
releases review:I did deep research of how your suggested change can affect potential end customers/consumers of
require-css
.And here is my code change suggestion:
I did this, because I know enterprise projects, which still use old version of require-css and csso, so my approach is universal. Tested with:
0.1.8
.1.3.12
,1.4.0
,1.8.0
,2.0.0
and latest (checked 2017/02/18)2.3.1
.2.1.10
and2.3.2
6.9.5
+ npm3.10.10
7.5.2
+ npm4.1.2
r.js -o example/build.js
withoptimizeCss: "standard"
Note: I realize, this change may be overthinking/overcomplex, but so far the fact is - if we merge ur current code change, someone who will upgrade to new
require-css
version, but remain oldcsso
version, they will have errors like I mentioned in this PR and in #203.So @prantlf please consider my code above as a suggestion to apply to your PR. After 1 week silence, I will close this PR, and recreate new one with my suggested code.
cc/ @guybedford