Skip to content

Separate classes from client code #1119

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

Merged

Conversation

jacobparis
Copy link
Contributor

Vite is pickier than the old compiler about server/client code separation

  • all exports other than Remix's are required to be client safe, and it will fail the build if server-only code is used in one
  • non-exported functions at top level are okay as long as they're only used in loaders and actions, HOWEVER that doesn't seem to apply to classes, and having top level classes that import server code triggers Remix Vite to fail the build. This might be a Remix bug and I've asked them about it

So this PR just goes through the offending files with top level service classes and moves them into sibling files

routes/
- api.v1.endpoint.ts
+ api.v1.endpoint/
+   route.ts
+   Service.server.ts

Closes #

✅ Checklist

  • I have followed every step in the contributing guide
  • The PR title follows the convention.
  • I ran and tested the code works

Testing

[Describe the steps you took to test this change]


Changelog

[Short description of what has changed]


Screenshots

[Screenshots]

💯

Copy link

changeset-bot bot commented May 22, 2024

⚠️ No Changeset found

Latest commit: 74ed6ee

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@matt-aitken matt-aitken force-pushed the separate-classes-from-client-code branch from e5fb0a0 to 74ed6ee Compare May 23, 2024 15:00
@matt-aitken matt-aitken merged commit f537778 into triggerdotdev:main May 23, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants