@@ -21,6 +21,7 @@ import HTMLTagList from './HTMLTagList';
21
21
import CSSPseudoClassList from './CSSPseudoClassList' ;
22
22
import * as ComponentRef from './ComponentRef' ;
23
23
24
+
24
25
type RenderConfig = {
25
26
requestCSS : string ;
26
27
} ;
@@ -45,6 +46,8 @@ type ComponentSpecCollection = {
45
46
46
47
const LOADER = require . resolve ( '../webpack' ) ;
47
48
49
+ const OBJECT_ASSIGN = require . resolve ( 'object-assign' ) ;
50
+
48
51
const COMPONENT_RE = / ^ [ A - Z ] [ a - z A - Z _ 0 - 9 ] * $ / ;
49
52
50
53
const PROP_VARIANT_NAME = ':prop' ;
@@ -219,8 +222,9 @@ function renderToJS(source: string, config: RenderConfig): string {
219
222
let root = postcss . parse ( source ) ;
220
223
221
224
let imports = stmt `
222
- import React from "react";
223
- import styles from "${ config . requestCSS } ";
225
+ var React = require("react");
226
+ var objectAssign = require("${ OBJECT_ASSIGN } ");
227
+ var styles = require("${ config . requestCSS } ");
224
228
` ;
225
229
let statements = [ ] ;
226
230
let components : ComponentSpecCollection = { } ;
@@ -258,9 +262,7 @@ function renderToJS(source: string, config: RenderConfig): string {
258
262
) ;
259
263
base = identifier ( componentName + '__Base' ) ;
260
264
imports . push ( stmt `
261
- import {
262
- ${ identifier ( ref . name ) } as ${ base }
263
- } from "${ ref . source } ";
265
+ var ${ base } = require("${ ref . source } ").${ identifier ( ref . name ) } ;
264
266
` ) ;
265
267
}
266
268
@@ -316,11 +318,12 @@ function renderToJS(source: string, config: RenderConfig): string {
316
318
}
317
319
}
318
320
statements . push ( stmt `
319
- export function ${ identifier ( componentName ) } ({variant = {}, ...props}) {
320
- let className = ${ className } ;
321
+ module.exports.${ identifier ( componentName ) } = function ${ identifier ( componentName ) } (props) {
322
+ var variant = props.variant || {};
323
+ var className = ${ className } ;
321
324
return React.createElement(
322
325
${ component . base } ,
323
- {... props, className}
326
+ objectAssign({}, props, { className: className, variant: undefined})
324
327
);
325
328
}
326
329
` ) ;
0 commit comments