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

fix(remix-dev/vite): remove Vite v4 back compat #8581

Merged
merged 1 commit into from
Jan 23, 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/great-mice-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

Vite: Remove undocumented backwards compatibility layer for Vite v4
24 changes: 3 additions & 21 deletions packages/remix-dev/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,6 @@ const getServerBundleBuildConfig = (
return viteUserConfig.__remixServerBundleBuildConfig as ServerBundleBuildConfig;
};

const getViteMajorVersion = (): number => {
let vitePkg = require("vite/package.json");
return parseInt(vitePkg.version.split(".")[0]!);
};

export let getServerBuildDirectory = (remixConfig: ResolvedVitePluginConfig) =>
path.join(
remixConfig.buildDirectory,
Expand All @@ -428,8 +423,6 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
let viteUserConfig: Vite.UserConfig;
let viteConfig: Vite.ResolvedConfig | undefined;

let isViteV4 = getViteMajorVersion() === 4;

let cssModulesManifest: Record<string, string> = {};
let ssrBuildContext:
| { isSsrBuild: false }
Expand Down Expand Up @@ -586,11 +579,8 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
};

let loadViteManifest = async (directory: string) => {
let manifestPath = isViteV4
? "manifest.json"
: path.join(".vite", "manifest.json");
let manifestContents = await fse.readFile(
path.resolve(directory, manifestPath),
path.resolve(directory, ".vite", "manifest.json"),
"utf-8"
);
return JSON.parse(manifestContents) as Vite.Manifest;
Expand Down Expand Up @@ -731,12 +721,6 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
)
);

let isSsrBuild =
"ssrBuild" in viteConfigEnv &&
typeof viteConfigEnv.ssrBuild === "boolean"
? viteConfigEnv.ssrBuild // Vite v4 back compat
: viteConfigEnv.isSsrBuild;

return {
__remixPluginResolvedConfig: remixConfig,
appType: "custom",
Expand Down Expand Up @@ -784,7 +768,7 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
base: remixConfig.publicPath,
build: {
...viteUserConfig.build,
...(!isSsrBuild
...(!viteConfigEnv.isSsrBuild
? {
manifest: true,
outDir: getClientBuildDirectory(remixConfig),
Expand Down Expand Up @@ -862,9 +846,7 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
{
command: viteConfig.command,
mode: viteConfig.mode,
...(isViteV4
? { ssrBuild: ssrBuildContext.isSsrBuild }
: { isSsrBuild: ssrBuildContext.isSsrBuild }),
isSsrBuild: ssrBuildContext.isSsrBuild,
},
viteConfig.configFile
);
Expand Down