Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
address pr feedback: better error message wording
Browse files Browse the repository at this point in the history
pcattori committed Dec 12, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent a6dff9a commit 27826f0
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions packages/remix-dev/vite/plugin.ts
Original file line number Diff line number Diff line change
@@ -962,8 +962,10 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {
"",
` '${id}' imported by route '${importerShort}'`,
"",
` The only route exports that can reference server-only modules are: ${serverOnlyExports}`,
` but other route exports in '${importerShort}' depend on '${id}'.`,
` The only route exports that can reference server-only modules are:`,
` ${serverOnlyExports}`,
"",
` But other route exports in '${importerShort}' depend on '${id}'.`,
"",
" For more see https://remix.run/docs/en/main/discussion/server-vs-client",
"",
@@ -973,13 +975,6 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {

let importedBy = path.parse(importerShort);
let ext = importedBy.ext === ".jsx" ? ".js" : ".ts";
let dotServerDir = path
.join(
path.basename(pluginConfig.appDirectory),
".server",
"utils" + ext
)
.replace(/\.jsx$/, ".js");
let dotServerFile = path.join(
importedBy.dir,
importedBy.name + ".server" + ext
@@ -991,17 +986,19 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {
"",
` '${id}' imported by '${importerShort}'`,
"",

` * If all code in '${importerShort}' is server-only:`,
"",
` Rename it to '${dotServerFile}'`,
"",
` * Otherwise:`,
"",
` Keep client-safe code in '${importerShort}'`,
` and move server-only code:`,
` - Keep client-safe code in '${importerShort}'`,
` - And move server-only code to a \`.server\` file`,
` e.g. '${dotServerFile}'`,
"",
` - Into a \`.server\` directory e.g. '${dotServerDir}'`,
` - Or into a \`.server\` file e.g. '${dotServerFile}'`,
" If you have lots of `.server` files, try using",
" a `.server` directory e.g. 'app/.server'",
"",
" For more, see https://remix.run/docs/en/main/future/vite#server-code-not-tree-shaken-in-development",
"",

0 comments on commit 27826f0

Please sign in to comment.