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

Add mode field into generated vite server build #8539

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tender-cherries-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

Vite: Add `mode` field into generated server build
12 changes: 12 additions & 0 deletions packages/remix-dev/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,13 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {
};

let getServerEntry = async () => {
invariant(viteConfig, "viteconfig required to generate the server entry");

// v3 TODO:
// - Deprecate `ServerBuild.mode` once we officially stabilize vite and
// mark the old compiler as deprecated
// - Remove `ServerBuild.mode` in v3

return `
import * as entryServer from ${JSON.stringify(
resolveFileUrl(pluginConfig, pluginConfig.entryServerFilePath)
Expand All @@ -466,6 +473,11 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {
)};`;
})
.join("\n")}
/**
* \`mode\` is only relevant for the old Remix compiler but
* is included here to satisfy the \`ServerBuild\` typings.
*/
export const mode = ${JSON.stringify(viteConfig.mode)};
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a comment to remove this once we deprecated and remove the old compiler? This field exists only as a way to address issues with the old compiler and isn't used for Vite.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should have a board for all the things we want to deprecate/remove so we don't forget to do those when we bump a major version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I guess we'll want to deprecate after we stabilize vite and officially mark the old compiler as deprecated and remove it in v3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

export { default as assets } from ${JSON.stringify(serverManifestId)};
export const assetsBuildDirectory = ${JSON.stringify(
pluginConfig.relativeAssetsBuildDirectory
Expand Down
3 changes: 3 additions & 0 deletions packages/remix-server-runtime/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import type { AppLoadContext } from "./data";
* The output of the compiler for the server build.
*/
export interface ServerBuild {
// v3 TODO:
// - Deprecate when we deprecate the old compiler
// - Remove in v3
mode: string;
entry: {
module: ServerEntryModule;
Expand Down
Loading