Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run within a module repository #213

Open
Garbee opened this issue Apr 17, 2023 · 1 comment
Open

Run within a module repository #213

Garbee opened this issue Apr 17, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@Garbee
Copy link

Garbee commented Apr 17, 2023

I seem to only be able to run the generator when the type is set to commonjs. Setting the package type to module always causes a configuration error, even if the config is named .cjs to force the commonjs loader.

Example: https://github.com/Garbee/material-icons

Steps to reproduce:

  1. git clone --recursive git clone --recursive https://github.com/Garbee/material-icons.git icons-test
  2. cd icons-test
  3. npm ci
  4. npm run icons

Does anyone know of a way to make this work while in a module package? Or will we need to change back to commonjs when running this for the time being?

I did some digging earlier and it looks like cosmiconfig is looking for maintainers and no longer actively maintained. There are some issues around module loading upstream. So this could be a non-issue here technically. However, an alternative config loader should be looked into if that is the case and cosmiconfig isn't actively maintained.

@nivekcode nivekcode added the enhancement New feature or request label Nov 14, 2023
@rajsite
Copy link

rajsite commented Mar 7, 2024

cosmiconfig landed support for cjs in 8.2.0 so all that's needed is a cosmiconfig dep version bump! cosmiconfig/cosmiconfig#224 (comment)

rajsite added a commit to ni/nimble that referenced this issue Aug 20, 2024
# Pull Request

## 🤨 Rationale

This PR represents the minimal set of changes to get to style dictionary
v4. Perks of being on style dictionary v4 are:
- It was [co-maintained by the TokensStudio
folks](https://styledictionary.com/version-4/statement/), hopefully
leading towards better Figma integration via
[TokensStudio](https://tokens.studio/) (not tested yet)
- It [supports the DTCG token
format](https://styledictionary.com/info/dtcg/) recommended by the W3C
Design Tokens Community group (although future work would be to switch
to that format)
- Has a supported (instead of internal) [utils
api](https://styledictionary.com/reference/utils/references/) to
manipulate tokens programmatically (not used yet but expect to be useful
for generating the static CSS examples)

Fixes #2232

## 👩‍💻 Implementation

- Switched the package to `"type": "module"` which required updated
legacy cjs scripts
- [Could not change the syg-to-ts script to
cjs](nivekcode/svg-to-ts#213) so instead
switched it to a json configuration
- Tokens now use a `type` field instead of relying on the json hierarchy
for type information. Migrated just the tokens that needed an explicit
type to evaluate correctly (likely want to redo the structure after
experimenting with Figma output so did the bare minimum required
changes)
- Re-enabled renovate updates for style-dicitionary

## 🧪 Testing

- Validated manually that the generated output had no effective
difference (other than generated comments) compared to
[[email protected]](https://unpkg.com/browse/@ni/[email protected]/dist/styledictionary/)
- Triggered the storybook rebuild to validate no visual differences

## ✅ Checklist

- [x] I have updated the project documentation to reflect my changes or
determined no changes are needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants