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

feat: add tuono.config.ts support #153

Merged
merged 20 commits into from
Nov 30, 2024
Merged

feat: add tuono.config.ts support #153

merged 20 commits into from
Nov 30, 2024

Conversation

Valerioageno
Copy link
Member

@Valerioageno Valerioageno commented Nov 25, 2024

Context & Description

This PR is the first iteration for creating the main configuration file tuono.config.ts.

We are creating the binding for adding the alias option to the vite configuration.
Enable the ability to resolve #114.

How does it work?

Original implementation When the `tuono.config.ts` file exists, we build it into a commonjs module inside the `.tuono/config/config.js` file. Then any vite script before starting read the file and apply the changes.

I decided to create the folder .tuono/config/ because when we will have to share the config with rust we will need to strip out all the ineligible values for the V8 engine so we will need to create a sibling config-server.js file (built again with vite and maybe a proper plugin).

Since the file is in the ./tuono/config folder using __dirname will cause issues with the path resolution so, in order to overcome this, I created a path module that has the path.join() function that automatically strips out the wrong filepath and correct __dirname with the tuono folder

New proposed approach can be found in the comment below

@Valerioageno Valerioageno self-assigned this Nov 25, 2024
packages/tuono/src/config/types.ts Show resolved Hide resolved
packages/tuono/src/config/types.ts Outdated Show resolved Hide resolved
packages/tuono/src/config/types.ts Show resolved Hide resolved
packages/tuono/src/build/index.ts Outdated Show resolved Hide resolved
@marcalexiei marcalexiei added the enhancement New feature or request label Nov 26, 2024
@marcalexiei marcalexiei changed the title New tuono.config.ts feat: add tuono.config.ts support Nov 26, 2024
@Valerioageno Valerioageno force-pushed the init-tuono-config-file branch from e4045e7 to 940eb63 Compare November 28, 2024 18:21
@Valerioageno Valerioageno linked an issue Nov 28, 2024 that may be closed by this pull request
@Valerioageno

This comment was marked as outdated.

marcalexiei

This comment was marked as outdated.

@Valerioageno
Copy link
Member Author

Valerioageno commented Nov 29, 2024

Decision after brain-melting:

tuono.config.ts bundling

  • Change output extension to mjs (ESM FTW !✨)
  • No additional processing (no transform plugin).

Alias processing (for now) after load config

Aliases will be processed from tuono npm package using the following routines:

  • If the path is relative turn them into an absolute path from the project root
  • If the path is absolute replace .tuono/config/ with /

Copy link
Member

@marcalexiei marcalexiei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I applied all the changes we discussed to day and added relevant unit tests.
Let me know if everything checks out also on your end.

@Valerioageno Valerioageno merged commit ec4577c into main Nov 30, 2024
11 checks passed
@Valerioageno Valerioageno deleted the init-tuono-config-file branch November 30, 2024 18:58
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
Status: Done
Development

Successfully merging this pull request may close these issues.

Add basic tuono.config.ts config file [Bug]: Documentation website loads all the @tabler/icon-react chunks
2 participants