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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for remix.config.ts #438

Closed
wants to merge 5 commits into from
Closed

Add support for remix.config.ts #438

wants to merge 5 commits into from

Conversation

jensmeindertsma
Copy link

Hello 馃憢.

I love using Remix, and what better way to show than to implement support for a feature I'd really love to see in Remix? It's a minor change but one that I quite like.

This pull requests implements support for remix.config.ts in addition to the existing remix.config.js. Writing your config files in TypeScript can be nice for projects which try to use as much TypeScript as possible, it increases the confidence you can have that your app still works after a dependency change. It also provides autocompletion ( I'm aware JSDoc also does this ). It also updates the gists-app fixture to verify that this feature works. Please let me know if you'd prefer to see this fixture change be reverted and would rather see a new fixture app created for this feature.

Thanks for all the awesome work on Remix! 馃檹

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Nov 22, 2021

Hi @jensmeindertsma,

Welcome, and thank you for contributing to Remix!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run.

Thanks!

- The Remix team

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Nov 22, 2021

Thank you for signing the Contributor License Agreement. Let's get this merged! 馃コ

);
}

let temporaryFile = path.resolve(os.tmpdir(), "_remix.config.js");
Copy link

Choose a reason for hiding this comment

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

this would cause problem if you write path.join(__dirname, './some-path') in your config, __dirname will be the tmpdir.

Copy link
Author

Choose a reason for hiding this comment

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

I could also generate a _remix.config.js file in the project root just temporarily, then unlink it immediately. Would that be better?

Copy link
Author

Choose a reason for hiding this comment

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

If I do that I might not need the bundle option either

Copy link

Choose a reason for hiding this comment

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

you do need the bundle option since you might import another ts file in your config

Copy link
Author

Choose a reason for hiding this comment

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

I could probably generate the temporary file in the project root instead, then __dirname would still work?

Copy link

Choose a reason for hiding this comment

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

maybe check out https://github.com/egoist/bundle-require/blob/main/README.md#how-it-works, it's how Vite loads vite.config.ts

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, I might use that instead. Hand rolling my own solution is likely going to cause some problems down the line

Copy link
Author

Choose a reason for hiding this comment

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

Done 馃榿

@jensmeindertsma
Copy link
Author

Let me know if there's anything I can do to help get this merged 馃槉

@ryanflorence
Copy link
Member

Thanks Jens. We don't want to add the complexity and a new dependency right now, the remix config is pretty basic.

(You might want to check your editor to make sure it's using the project's prettier config because this PR has a bunch of formatting changes in unrelated files.)

@jensmeindertsma
Copy link
Author

Would you accept this PR if it didn't add any new dependencies ( just use esbuild ), or not?

@donavon
Copy link
Contributor

donavon commented Mar 31, 2022

We don't want to add the complexity and a new dependency right now, the remix config is pretty basic.

I don't care how basic is it, this is a bad call, IMO. Maybe not this PR, but is there any way we can get the concept of a remix.config.ts reopened? JavaScript is killing me.

@donavon
Copy link
Contributor

donavon commented Mar 31, 2022

Here's an example of why it's important to have a type-safe config file. Here depth can only be 1 through 6.

image

p.s. I've patched my Remix to allow remix.config.ts.

@donavon
Copy link
Contributor

donavon commented Apr 5, 2022

If you're reading this you may want to check out https://github.com/donavon/remix-patches and the remix-config-ts patch.

@sjc5
Copy link

sjc5 commented Jul 2, 2023

It would be lovely if this were revisited, given that the config potentially includes writing functions to define custom routes and things of that nature. Not to rehash why typescript even exists, but doing that in pure JS is painful and buggy. Got bit by this last night.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants