@@ -122,6 +122,7 @@ function renderToJS(source: string, config: RenderConfig): string {
122
122
components [ componentName ] . base = base ;
123
123
}
124
124
125
+ // walk CSS AST and register all component configurations
125
126
root . walkRules ( node => {
126
127
let componentNames = findComponentNames ( node ) ;
127
128
if ( componentNames . length === 0 ) {
@@ -140,6 +141,7 @@ function renderToJS(source: string, config: RenderConfig): string {
140
141
}
141
142
} ) ;
142
143
144
+ // generate JS code from component configurations
143
145
for ( let componentName in components ) {
144
146
let component = components [ componentName ] ;
145
147
if ( components . hasOwnProperty ( componentName ) ) {
@@ -157,6 +159,9 @@ function renderToJS(source: string, config: RenderConfig): string {
157
159
return generate ( program ( imports . concat ( statements ) ) ) . code ;
158
160
}
159
161
162
+ /**
163
+ * Webpack loader for React CSS component modules.
164
+ */
160
165
export function loader ( source : string ) : string {
161
166
this . cacheable ( ) ;
162
167
let query = LoaderUtils . parseQuery ( this . query ) ;
@@ -170,6 +175,9 @@ export function loader(source: string): string {
170
175
}
171
176
}
172
177
178
+ /**
179
+ * Render React CSS component module into JS and CSS sources.
180
+ */
173
181
export function render ( source : string , config : RenderConfig ) : { js: string ; css: string } {
174
182
let js = renderToJS ( source , { requestCSS : config . requestCSS } ) ;
175
183
let css = renderToCSS ( source ) ;
0 commit comments