amzn / style-dictionary

A build system for creating cross-platform styles.
https://styledictionary.com
Apache License 2.0
3.87k stars 543 forks source link

How to create extend as ES6 module #902

Closed Rajdeepc closed 6 months ago

Rajdeepc commented 1 year ago

How to write the below line in ES6 Module

CommonJS: const StyleDictionary = require('style-dictionary').extend('config.json');

ES6??

Rajdeepc commented 1 year ago

Ok I figured out that it can be written as

import StyleDictionary from 'style-dictionary'
const styleDictionary = StyleDictionary.extend( 'config.js' );

But I have written this line in build-css.js and this is my file structure build-css.js config.js

But I am getting this error Error: Cannot find module '/Users/rajdeepc/Documents/Projects/project/config.js'

jorenbroekema commented 6 months ago

v4 has first-class ESM support, see https://github.com/amzn/style-dictionary/blob/v4/CHANGELOG.md