@@ -11,7 +11,9 @@ var caniuse = require("caniuse-api")
1111// null == always enable (& no caniuse data)
1212var caniuseFeaturesMap = {
1313 customProperties : [ "css-variables" ] ,
14- // calc: null, // calc() transformation only make sense with transformed custom properties, don't you think ?
14+ // calc() transformation only make sense with transformed custom properties,
15+ // don't you think ?
16+ // calc: null,
1517 // @todo open PR on caniuse repo https://github.com/Fyrd/caniuse
1618 // customMedia: [null],
1719 // mediaQueriesRange: [null],
@@ -22,44 +24,75 @@ var caniuseFeaturesMap = {
2224 // colorHexAlpha: [null],
2325 // colorFunction:[null],
2426 // fontVariant: [null],
25- // filter: [null], // @todo can be done using a callback, this is only used for Firefox < 35
27+ // @todo can be done using a callback, this is only used for Firefox < 35
28+ // filter: [null],
2629 rem : [ "rem" ] ,
2730 pseudoElements : [ "css-gencontent" ] ,
2831 // pseudoClassMatches: [null],
2932 // pseudoClassNot: [null],
3033 colorRgba : [ "css3-colors" ] ,
31- // autoprefixer: [null] // will always be null since autoprefixer does the same game as we do
34+ // will always be null since autoprefixer does the same game as we do
35+ // autoprefixer: [null]
3236}
3337
3438var libraryFeatures = {
3539 // Reminder: order is important
36- customProperties : function ( options ) { return require ( "postcss-custom-properties" ) ( options ) } ,
37- calc : function ( options ) { return require ( "postcss-calc" ) ( options ) } ,
38- customMedia : function ( options ) { return require ( "postcss-custom-media" ) ( options ) } ,
39- mediaQueriesRange : function ( options ) { return require ( "postcss-media-minmax" ) ( options ) } ,
40- customSelectors : function ( options ) { return require ( "postcss-custom-selectors" ) ( options ) } ,
41- colorRebeccapurple : function ( options ) { return require ( "postcss-color-rebeccapurple" ) ( options ) } ,
42- colorHwb : function ( options ) { return require ( "postcss-color-hwb" ) ( options ) } ,
43- colorGray : function ( options ) { return require ( "postcss-color-gray" ) ( options ) } ,
44- colorHexAlpha : function ( options ) { return require ( "postcss-color-hex-alpha" ) ( options ) } ,
45- colorFunction : function ( options ) { return require ( "postcss-color-function" ) ( options ) } ,
46- fontVariant : function ( options ) { return require ( "postcss-font-variant" ) ( options ) } ,
47- filter : function ( options ) { return require ( "pleeease-filters" ) ( options ) } ,
48- rem : function ( options ) { return require ( "pixrem" ) ( options ) } ,
49- pseudoElements : function ( options ) { return require ( "postcss-pseudoelements" ) ( options ) } ,
50- pseudoClassMatches : function ( options ) { return require ( "postcss-selector-matches" ) ( options ) } ,
51- pseudoClassNot : function ( options ) { return require ( "postcss-selector-not" ) ( options ) } ,
52- colorRgba : function ( options ) { return require ( "postcss-color-rgba-fallback" ) ( options ) } ,
53- autoprefixer : function ( options ) { return require ( "autoprefixer-core" ) ( options ) . postcss } ,
40+ customProperties : function ( options ) {
41+ return require ( "postcss-custom-properties" ) ( options )
42+ } ,
43+ calc : function ( options ) {
44+ return require ( "postcss-calc" ) ( options )
45+ } ,
46+ customMedia : function ( options ) {
47+ return require ( "postcss-custom-media" ) ( options )
48+ } ,
49+ mediaQueriesRange : function ( options ) {
50+ return require ( "postcss-media-minmax" ) ( options )
51+ } ,
52+ customSelectors : function ( options ) {
53+ return require ( "postcss-custom-selectors" ) ( options )
54+ } ,
55+ colorRebeccapurple : function ( options ) {
56+ return require ( "postcss-color-rebeccapurple" ) ( options )
57+ } ,
58+ colorHwb : function ( options ) {
59+ return require ( "postcss-color-hwb" ) ( options )
60+ } ,
61+ colorGray : function ( options ) {
62+ return require ( "postcss-color-gray" ) ( options )
63+ } ,
64+ colorHexAlpha : function ( options ) {
65+ return require ( "postcss-color-hex-alpha" ) ( options )
66+ } ,
67+ colorFunction : function ( options ) {
68+ return require ( "postcss-color-function" ) ( options )
69+ } ,
70+ fontVariant : function ( options ) {
71+ return require ( "postcss-font-variant" ) ( options )
72+ } ,
73+ filter : function ( options ) {
74+ return require ( "pleeease-filters" ) ( options )
75+ } ,
76+ rem : function ( options ) {
77+ return require ( "pixrem" ) ( options )
78+ } ,
79+ pseudoElements : function ( options ) {
80+ return require ( "postcss-pseudoelements" ) ( options )
81+ } ,
82+ pseudoClassMatches : function ( options ) {
83+ return require ( "postcss-selector-matches" ) ( options )
84+ } ,
85+ pseudoClassNot : function ( options ) {
86+ return require ( "postcss-selector-not" ) ( options )
87+ } ,
88+ colorRgba : function ( options ) {
89+ return require ( "postcss-color-rgba-fallback" ) ( options )
90+ } ,
91+ autoprefixer : function ( options ) {
92+ return require ( "autoprefixer-core" ) ( options ) . postcss
93+ } ,
5494}
5595
56- /**
57- * Expose cssnext
58- *
59- * @type {Function }
60- */
61- module . exports = cssnext
62-
6396/**
6497 * Process a CSS `string`
6598 *
@@ -83,7 +116,8 @@ function cssnext(string, options) {
83116
84117 var features = options . features || { }
85118
86- // options.browsers is deliberately undefined by defaut to inherit browserslist default behavior
119+ // options.browsers is deliberately undefined by defaut to inherit
120+ // browserslist default behavior
87121
88122 // default sourcemap
89123 // if `map` option is passed, `sourcemap` option is ignored
@@ -93,9 +127,13 @@ function cssnext(string, options) {
93127 // propagate browsers option to autoprefixer
94128 if ( features . autoprefixer !== false ) {
95129 features . autoprefixer = features . autoprefixer || { }
96- features . autoprefixer . browsers = features . autoprefixer . browsers || options . browsers
130+ features . autoprefixer . browsers = features . autoprefixer . browsers ||
131+ options . browsers
132+
97133 // autoprefixer doesn't like an "undefined" value. Related to coffee ?
98- if ( features . autoprefixer . browsers === undefined ) { delete features . autoprefixer . browsers }
134+ if ( features . autoprefixer . browsers === undefined ) {
135+ delete features . autoprefixer . browsers
136+ }
99137 }
100138
101139 var postcssInstance = postcss ( )
@@ -105,18 +143,29 @@ function cssnext(string, options) {
105143 if ( fs && fs . readFile ) {
106144 // @import
107145 if ( options . import !== false ) {
108- postcssInstance . use ( require ( "postcss-import" ) ( typeof options . import === "object" ? options . import : undefined ) )
146+ postcssInstance . use ( require ( "postcss-import" ) (
147+ typeof options . import === "object"
148+ ? options . import
149+ : undefined
150+ )
151+ )
109152 }
110153
111154 // url() adjustements
112155 if ( options . url !== false ) {
113- postcssInstance . use ( require ( "postcss-url" ) ( typeof options . url === "object" ? options . url : undefined ) )
156+ postcssInstance . use ( require ( "postcss-url" ) (
157+ typeof options . url === "object"
158+ ? options . url
159+ : undefined
160+ )
161+ )
114162 }
115163 }
116164
117165 // features
118166 Object . keys ( cssnext . features ) . forEach ( function ( key ) {
119- // feature is auto enabled if: not disable && (enabled || no data yet || !supported yet)
167+ // feature is auto enabled if: not disable && (enabled || no data yet ||
168+ // !supported yet)
120169 if (
121170 // feature is not disabled
122171 features [ key ] !== false &&
@@ -135,7 +184,12 @@ function cssnext(string, options) {
135184 )
136185 )
137186 ) {
138- postcssInstance . use ( cssnext . features [ key ] ( typeof features [ key ] === "object" ? features [ key ] : undefined ) )
187+ postcssInstance . use ( cssnext . features [ key ] (
188+ typeof features [ key ] === "object"
189+ ? features [ key ]
190+ : undefined
191+ )
192+ )
139193 }
140194 } )
141195
@@ -178,3 +232,10 @@ function cssnext(string, options) {
178232 * @type {Object }
179233 */
180234cssnext . features = libraryFeatures
235+
236+ /**
237+ * Expose cssnext
238+ *
239+ * @type {Function }
240+ */
241+ module . exports = cssnext
0 commit comments