Skip to content

Commit

Permalink
feat(vite): error messages when .server files are referenced by client (
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori authored Dec 12, 2023
1 parent 19d7f83 commit 9a845b6
Show file tree
Hide file tree
Showing 5 changed files with 308 additions and 175 deletions.
18 changes: 18 additions & 0 deletions .changeset/breezy-grapes-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
"@remix-run/dev": minor
---

Vite: Error messages when .server files are referenced by client

Previously, referencing a `.server` module from client code resulted in an error message like:

```txt
The requested module '/app/models/answer.server.ts' does not provide an export named 'isDateType'
```

Which was confusing because `answer.server.ts` _does_ provide the `isDateType` export,
but Remix was replacing `.server` modules with empty modules (`export {}`) for the client build.

Now, Remix explicitly fails at compile time when a `.server` module is referenced from client code
and includes dedicated error messages depending on whether the import occurs in a route or a non-route
module. The error messages also include links to relevant documentation.
2 changes: 1 addition & 1 deletion integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
"tailwindcss": "^3.3.0",
"type-fest": "^4.0.0",
"typescript": "^5.1.0",
"vite-tsconfig-paths": "^4.2.1"
"vite-tsconfig-paths": "^4.2.2"
}
}
Loading

0 comments on commit 9a845b6

Please sign in to comment.