Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

Conversation

@dslovinsky
Copy link
Member

@dslovinsky dslovinsky commented May 14, 2023

Changes

  • Creates getConfig to load the contents of user quarks.config.ts
  • Allows devs to overwrite quark props to use their own functions

Closes #9

Other notes (things to check, explanation of implementation, etc.)

The challenge here has been loading the config in a method that a frontend framework like next supports. The problem is next seems to not like that fs is being used within findup-sync since this is a frontend project where fs is not allowed. But it's the only way we have access to the dependent repo's config file.
Relevant threads:

  1. https://stackoverflow.com/q/69216029
  2. https://stackoverflow.com/q/56729491

Why use findup-sync:
Ordinarily we could just use path.resolve to get the contents of a specific file path in the dependent project, but the difficult is that "root directory" can actually mean several different places, for example depending on if you're in a monorepo. So instead the approach is to start from a working directory then move up into ancestors looking for a file that matches the target glob. Findup sync seems good for this:

Example:
See lib/loadConfig.ts in Tailwind

JITI may useful:
https://www.npmjs.com/package/jiti

@dslovinsky dslovinsky self-assigned this May 14, 2023
@dslovinsky dslovinsky changed the base branch from main to prop-types May 14, 2023 03:10
Base automatically changed from prop-types to main May 14, 2023 03:48
@jpwallace22
Copy link
Contributor

@dslovinsky I didnt see any use of findup-sync or fs in the Tailwind library. Also, after digging into it a bit, I notice that this package hasn't been touched in two years and never had great support to begin with. Are we sure that there isn't anything wrong with findup-sync? We can write a custom function to search for the config file pretty easily.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow users to create custom overwrites

3 participants