Skip to content

Commit

Permalink
feat(remix-dev/vite): remove unstable prefix from serverBundles (#8596)
Browse files Browse the repository at this point in the history
  • Loading branch information
markdalgleish committed Jan 25, 2024
1 parent ec21f5d commit 656aa29
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
8 changes: 4 additions & 4 deletions integration/vite-adapter-test.ts
Expand Up @@ -32,9 +32,9 @@ test.describe(async () => {
pluginOptions: `
{
adapter: async ({ remixConfig }) => ({
unstable_serverBundles(...args) {
serverBundles(...args) {
// This lets us assert that user options are passed to adapter options hook
return remixConfig.unstable_serverBundles?.(...args) + "--adapter-options";
return remixConfig.serverBundles?.(...args) + "--adapter-options";
},
async buildEnd(args) {
let fs = await import("node:fs/promises");
Expand All @@ -53,7 +53,7 @@ test.describe(async () => {
}
}),
unstable_serverBundles() {
serverBundles() {
return "user-options";
}
},
Expand All @@ -64,7 +64,7 @@ test.describe(async () => {
});
test.afterAll(() => stop());

test("Vite / adapter / unstable_serverBundles and buildEnd hooks", async () => {
test("Vite / adapter / serverBundles and buildEnd hooks", async () => {
let { status } = viteBuild({ cwd });
expect(status).toBe(0);

Expand Down
2 changes: 1 addition & 1 deletion integration/vite-server-bundles-test.ts
Expand Up @@ -122,7 +122,7 @@ test.describe(() => {
port: devPort,
pluginOptions: `{
manifest: true,
unstable_serverBundles: async ({ branch }) => {
serverBundles: async ({ branch }) => {
// Smoke test to ensure we can read the route files via 'route.file'
await Promise.all(branch.map(async (route) => {
const fs = await import("node:fs/promises");
Expand Down
4 changes: 1 addition & 3 deletions packages/remix-dev/vite/build.ts
Expand Up @@ -153,9 +153,7 @@ async function getServerBuilds(ctx: RemixPluginContext): Promise<{
),
});
if (typeof serverBundleId !== "string") {
throw new Error(
`The "unstable_serverBundles" function must return a string`
);
throw new Error(`The "serverBundles" function must return a string`);
}
buildManifest.routeIdToServerBundleId[route.id] = serverBundleId;

Expand Down
9 changes: 4 additions & 5 deletions packages/remix-dev/vite/plugin.ts
Expand Up @@ -112,7 +112,7 @@ export type ServerBundlesBuildManifest = BaseBuildManifest & {
export type BuildManifest = DefaultBuildManifest | ServerBundlesBuildManifest;

const adapterRemixConfigOverrideKeys = [
"unstable_serverBundles",
"serverBundles",
] as const satisfies ReadonlyArray<keyof VitePluginConfig>;

type AdapterRemixConfigOverrideKey =
Expand Down Expand Up @@ -164,7 +164,7 @@ export type VitePluginConfig = RemixEsbuildUserConfigJsdocOverrides &
* function should return a server bundle ID which will be used as the
* bundle's directory name within the server build directory.
*/
unstable_serverBundles?: ServerBundlesFunction;
serverBundles?: ServerBundlesFunction;
/**
* Enable server-side rendering for your application. Disable to use Remix in
* "SPA Mode", which will request the `/` path at build-time and save it as
Expand Down Expand Up @@ -492,15 +492,14 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
resolvedRemixUserConfig.buildDirectory
);

let { serverBuildFile, unstable_serverBundles: serverBundles } =
resolvedRemixUserConfig;
let { serverBuildFile, serverBundles } = resolvedRemixUserConfig;

// Log warning for incompatible vite config flags
if (isSpaMode && serverBundles) {
console.warn(
colors.yellow(
colors.bold("⚠️ SPA Mode: ") +
"the `unstable_serverBundles` config is invalid with " +
"the `serverBundles` config is invalid with " +
"`unstable_ssr:false` and will be ignored`"
)
);
Expand Down

0 comments on commit 656aa29

Please sign in to comment.