Skip to content

Commit c73d432

Browse files
committed
doc: comments
1 parent 7478653 commit c73d432

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ function renderToJS(source: string, config: RenderConfig): string {
122122
components[componentName].base = base;
123123
}
124124

125+
// walk CSS AST and register all component configurations
125126
root.walkRules(node => {
126127
let componentNames = findComponentNames(node);
127128
if (componentNames.length === 0) {
@@ -140,6 +141,7 @@ function renderToJS(source: string, config: RenderConfig): string {
140141
}
141142
});
142143

144+
// generate JS code from component configurations
143145
for (let componentName in components) {
144146
let component = components[componentName];
145147
if (components.hasOwnProperty(componentName)) {
@@ -157,6 +159,9 @@ function renderToJS(source: string, config: RenderConfig): string {
157159
return generate(program(imports.concat(statements))).code;
158160
}
159161

162+
/**
163+
* Webpack loader for React CSS component modules.
164+
*/
160165
export function loader(source: string): string {
161166
this.cacheable();
162167
let query = LoaderUtils.parseQuery(this.query);
@@ -170,6 +175,9 @@ export function loader(source: string): string {
170175
}
171176
}
172177

178+
/**
179+
* Render React CSS component module into JS and CSS sources.
180+
*/
173181
export function render(source: string, config: RenderConfig): {js: string; css: string} {
174182
let js = renderToJS(source, {requestCSS: config.requestCSS});
175183
let css = renderToCSS(source);

0 commit comments

Comments
 (0)