Skip to content

Commit

Permalink
add a note about function + stringify in TEMPLATING doc
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 committed Oct 18, 2024
1 parent 5612c8a commit 5235434
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contributors/TEMPLATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ import { stringify } from "../path/to/templates/utils.js";
| Array, add new items | `const arrWithAdditionalItems = ${stringify(['a', 'b', ...arrayToSpread[0]])}` | `const arrayToSpread = ["Spread", "This"]` | `const arrWithAdditionalItems = ["a", "b", "Spread", "This"]` |
| BigInt | `const bigInt = ${stringify(someBigInt[0])};` | `const someBigInt = 123n` | `const bigInt = 123n;` |

> NOTE: If the object contains function as a value `stringify` utility truncates it to `[Function keyName]`. In this case we have to use object spread operator while merging the objects and `JSON.stringify` while replacing the objects. Checkout [`next.config.template.mjs`](https://github.com/scaffold-eth/create-eth/blob/main/templates/base/packages/nextjs/next.config.template.mjs) for an example.
## Merging package.json files

The package we use to merge `package.json` files [merge-packages](https://www.npmjs.com/package/merge-packages) will attempt to find intersections of dependencies. If there is a conflict, the version from the last `package.json` will be taken.
Expand Down

0 comments on commit 5235434

Please sign in to comment.