amzn / style-dictionary

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

RangeError: Maximum call stack size exceeded #1105

Open doug-wade opened 8 months ago

doug-wade commented 8 months ago

I'm trying to set up a new project, with the following file structure

» tree
.
├── README.md
├── config.json
├── package.json
├── tokens
│   ├── border.json
│   ├── color
│   │   ├── base.json
│   │   └── font.json
│   └── size
│       └── font.json
└── yarn.lock

4 directories, 8 files

However, I'm getting an error from lodash when I try to build the project. To reproduce

1.) Create a new project 2.) Copy-paste the complete config.json example 3.) Run style-dictionary build

» npx style-dictionary@3.9.2 build

ios
✔︎ ios/Classes/Generated/StyleDictionarySize.h
✔︎ ios/Classes/Generated/StyleDictionarySize.m
No properties for StyleDictionaryIcons.h. File not created.
No properties for StyleDictionaryIcons.m. File not created.
✔︎ ios/Classes/Generated/StyleDictionaryColor.h
✔︎ ios/Classes/Generated/StyleDictionaryColor.m
✔︎ ios/Classes/Generated/StyleDictionaryProperties.h
undefined:35
 function buildDictionary(props, indent) {
                         ^

RangeError: Maximum call stack size exceeded
    at buildDictionary (eval at <anonymous> (/Users/doug/code/odyssey-tokens/node_modules/lodash/template.js:259:12), <anonymous>:35:26)
    at buildDictionary (eval at <anonymous> (/Users/doug/code/odyssey-tokens/node_modules/lodash/template.js:259:12), <anonymous>:53:48)
    at buildDictionary (eval at <anonymous> (/Users/doug/code/odyssey-tokens/node_modules/lodash/template.js:259:12), <anonymous>:53:48)
    at buildDictionary (eval at <anonymous> (/Users/doug/code/odyssey-tokens/node_modules/lodash/template.js:259:12), <anonymous>:53:48)
    at buildDictionary (eval at <anonymous> (/Users/doug/code/odyssey-tokens/node_modules/lodash/template.js:259:12), <anonymous>:53:48)
    at buildDictionary (eval at <anonymous> (/Users/doug/code/odyssey-tokens/node_modules/lodash/template.js:259:12), <anonymous>:53:48)
    at buildDictionary (eval at <anonymous> (/Users/doug/code/odyssey-tokens/node_modules/lodash/template.js:259:12), <anonymous>:53:48)
    at buildDictionary (eval at <anonymous> (/Users/doug/code/odyssey-tokens/node_modules/lodash/template.js:259:12), <anonymous>:53:48)
    at buildDictionary (eval at <anonymous> (/Users/doug/code/odyssey-tokens/node_modules/lodash/template.js:259:12), <anonymous>:53:48)
    at buildDictionary (eval at <anonymous> (/Users/doug/code/odyssey-tokens/node_modules/lodash/template.js:259:12), <anonymous>:53:48)

Node.js v20.11.0
jorenbroekema commented 7 months ago

Could you try on the v4 branch perhaps to see if it's still a problem there? the offending code has been refactored a fair bit.

See changelog for the breaking changes, needed when migrating https://github.com/amzn/style-dictionary/blob/v4/CHANGELOG.md

doug-wade commented 7 months ago

I tried it out on my project and while it does not resolve the issue, it does change the stack trace somewhat

» npx style-dictionary@4.0.0-prerelease.23 build

ios

android

android-asset
No tokens for StyleDictionaryIcons.h. File not created.
No tokens for StyleDictionaryIcons.m. File not created.
undefined:38
  if (Object.hasOwn(token, `${options.usesDtcg ? '$' : ''}value`)) {
             ^

RangeError: Maximum call stack size exceeded
    at String.hasOwn (<anonymous>)
    at Function.hasOwn (<anonymous>)
    at buildDictionary (eval at <anonymous> (file:///Users/doug/code/odyssey-tokens/node_modules/lodash-es/template.js:259:12), <anonymous>:38:14)
    at buildDictionary (eval at <anonymous> (file:///Users/doug/code/odyssey-tokens/node_modules/lodash-es/template.js:259:12), <anonymous>:56:48)
    at buildDictionary (eval at <anonymous> (file:///Users/doug/code/odyssey-tokens/node_modules/lodash-es/template.js:259:12), <anonymous>:56:48)
    at buildDictionary (eval at <anonymous> (file:///Users/doug/code/odyssey-tokens/node_modules/lodash-es/template.js:259:12), <anonymous>:56:48)
    at buildDictionary (eval at <anonymous> (file:///Users/doug/code/odyssey-tokens/node_modules/lodash-es/template.js:259:12), <anonymous>:56:48)
    at buildDictionary (eval at <anonymous> (file:///Users/doug/code/odyssey-tokens/node_modules/lodash-es/template.js:259:12), <anonymous>:56:48)
    at buildDictionary (eval at <anonymous> (file:///Users/doug/code/odyssey-tokens/node_modules/lodash-es/template.js:259:12), <anonymous>:56:48)
    at buildDictionary (eval at <anonymous> (file:///Users/doug/code/odyssey-tokens/node_modules/lodash-es/template.js:259:12), <anonymous>:56:48)

Node.js v20.12.0