File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -408,7 +408,7 @@ StyleDictionary.extend({
408
408
} ) . buildAllPlatforms ( ) ;
409
409
410
410
// create CommonJS index.js
411
- const collections = { } ;
411
+ const collections = [ ] ;
412
412
fs . readdirSync ( CJS_DIR )
413
413
. filter ( file => file !== 'index.cjs' )
414
414
. forEach ( file => {
@@ -418,10 +418,18 @@ fs.readdirSync(CJS_DIR)
418
418
let mode = parts [ 1 ] ;
419
419
// special case for base.js and components
420
420
if ( mode === 'default' || ! mode ) [ mode ] = parts ;
421
- collections [ mode ] = `require(./${ file } )` ;
421
+ fs . appendFileSync (
422
+ `${ CJS_DIR } index.cjs` ,
423
+ `const ${ mode } = require('./${ file } ');\n` ,
424
+ ) ;
425
+ collections . push ( mode ) ;
422
426
}
423
427
} ) ;
424
- const output = `module.exports = ${ JSON . stringify ( collections , null , 2 ) } ` ;
425
- fs . writeFileSync ( `${ CJS_DIR } index.cjs` , output ) ;
428
+
429
+ const output = `\nmodule.exports = { ${ collections . map (
430
+ collection => collection ,
431
+ ) } };\n`;
432
+ fs . appendFileSync ( `${ CJS_DIR } index.cjs` , output ) ;
433
+ // fs.writeFileSync(`${CJS_DIR}index.cjs`, output);
426
434
427
435
console . log ( '✅ CSS, Javascript, and JSON files have been generated.' ) ;
You can’t perform that action at this time.
0 commit comments