Skip to content
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
4 changes: 0 additions & 4 deletions packages/example-fs-routing/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import { defineConfig } from "vite";
export default defineConfig({
plugins: [
funstackStatic({
// SSR is required for file-system routing to render in the dev server
// (pages are server components rendered through FUNSTACK Router), and is
// recommended in general for SEO and faster initial load.
ssr: true,
// Built-in file-system routing. Pages under `src/pages` are mapped to
// routes via the Next.js-like adapter and rendered with FUNSTACK Router.
fsRoutes: {
Expand Down
29 changes: 16 additions & 13 deletions packages/static/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,24 +247,27 @@ export default function funstackStatic(
if (!config.optimizeDeps) {
config.optimizeDeps = {};
}
config.optimizeDeps.include ??= [];
// Needed for properly bundling @vitejs/plugin-rsc for browser.
// See: https://github.com/vitejs/vite-plugin-react/tree/79bf57cc8b9c77e33970ec2e876bd6d2f1568d5d/packages/plugin-rsc#using-vitejsplugin-rsc-as-a-framework-packages-dependencies
if (config.optimizeDeps.include) {
config.optimizeDeps.include = config.optimizeDeps.include.map(
(entry) => {
if (entry.startsWith("@vitejs/plugin-rsc")) {
entry = `@funstack/static > ${entry}`;
}
return entry;
},
);
}
if (!config.optimizeDeps.exclude) {
config.optimizeDeps.exclude = [];
}
config.optimizeDeps.include = config.optimizeDeps.include.map(
(entry) => {
if (entry.startsWith("@vitejs/plugin-rsc")) {
entry = `@funstack/static > ${entry}`;
}
return entry;
},
);
config.optimizeDeps.exclude ??= [];
// Since code includes imports to virtual modules, we need to exclude
// us from Optimize Deps.
config.optimizeDeps.exclude.push("@funstack/static");
// However, since Vite prohibits excluding a CommonJS package,
// we need to include React and ReactDOM so they are bundled properly.
config.optimizeDeps.include.push(
"@funstack/static > react",
"@funstack/static > react-dom",
);
},
},
{
Expand Down