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

feat: migrate to vite v6 #1012

Merged
merged 43 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f74e9ef
feat: migrate to vite v6
himself65 Nov 24, 2024
e5b1e35
Merge branch 'main' into himself65/20241123/migrate
dai-shi Nov 27, 2024
bd1c8bc
vite 6
dai-shi Nov 27, 2024
8d9903a
Merge branch 'main' into himself65/20241123/migrate
dai-shi Nov 27, 2024
5e9777a
fix: wtf fix
himself65 Nov 28, 2024
d461ed3
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 2, 2024
c6c73b8
vite@6.0.2
dai-shi Dec 2, 2024
5c4e92d
Merge branch 'himself65/20241123/migrate' of github.com:himself65/wak…
dai-shi Dec 2, 2024
11b71ed
fix prettier
dai-shi Dec 2, 2024
9d77236
throw if unexpected
dai-shi Dec 2, 2024
818d651
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 8, 2024
26a6b13
vite@6.0.3
dai-shi Dec 8, 2024
8b42efc
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 9, 2024
704c8a3
resolve potential conflict
dai-shi Dec 9, 2024
8c872c8
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 10, 2024
63b5896
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 11, 2024
a83e615
use vite from https://github.com/vitejs/vite/pull/18361
dai-shi Dec 11, 2024
a306165
hack resolve.conditions
dai-shi Dec 11, 2024
203a5f3
use require
dai-shi Dec 11, 2024
16c1cb0
fix als
dai-shi Dec 11, 2024
c679370
change vite in examples
dai-shi Dec 11, 2024
16469c5
applies the same hack to rsc server
dai-shi Dec 11, 2024
d627fc5
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 13, 2024
c53287f
fix vite loader
dai-shi Dec 13, 2024
1b48c80
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 13, 2024
211848f
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 13, 2024
71f3bee
hack FOR NOW
dai-shi Dec 13, 2024
5077b27
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 13, 2024
1eefb80
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 13, 2024
288054f
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 14, 2024
2663e68
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 14, 2024
4c8dfb4
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 18, 2024
2a7c0dd
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 20, 2024
d932340
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 22, 2024
371fb6a
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 24, 2024
d385154
fix vite.config
dai-shi Dec 24, 2024
cd48f5f
proper fix!
dai-shi Dec 25, 2024
a4b7383
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 26, 2024
ada4cf0
vite 6
dai-shi Dec 26, 2024
f6f53be
revert to https://github.com/vitejs/vite/pull/18361 verion of vite pkg
dai-shi Dec 27, 2024
8f34933
Revert "revert to https://github.com/vitejs/vite/pull/18361 verion of…
dai-shi Dec 27, 2024
f942a6d
Merge branch 'main' into himself65/20241123/migrate
dai-shi Dec 27, 2024
50cb7a8
fix(vite-6): requireAsyncModule is defined twice in same file in vite 6
tylersayshi Dec 27, 2024
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
27 changes: 6 additions & 21 deletions e2e/fixtures/ssr-catch-error/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
export default ({ mode }: { mode: string }) => {
if (mode === 'development') {
return {
plugins: [
{
name: 'externalize-react-error-boundary',
configResolved(config: any) {
// TODO HACK temporary solution until v0.22.0
if (
config.cacheDir.endsWith(
'node_modules/.vite/waku-dev-server-main',
)
) {
config.ssr.noExternal = ['react-error-boundary'];
}
},
},
],
};
}
return {};
export default {
ssr: {
resolve: {
conditions: ['module', 'node'],
},
},
};
2 changes: 1 addition & 1 deletion examples/12_nossr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"autoprefixer": "10.4.20",
"tailwindcss": "3.4.17",
"typescript": "5.7.2",
"vite": "5.4.10"
"vite": "6.0.6"
}
}
2 changes: 1 addition & 1 deletion examples/37_css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@types/react-dom": "19.0.2",
"@vanilla-extract/vite-plugin": "4.0.18",
"typescript": "5.7.2",
"vite": "5.4.10",
"vite": "6.0.6",
"vite-plugin-stylex-dev": "0.7.5"
}
}
2 changes: 1 addition & 1 deletion examples/41_path-alias/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@types/react": "19.0.2",
"@types/react-dom": "19.0.2",
"typescript": "5.7.2",
"vite": "5.4.10",
"vite": "6.0.6",
"vite-tsconfig-paths": "5.1.4"
}
}
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,5 @@
"typescript": "^5.7.2",
"wait-port": "^1.1.0",
"waku": "workspace:*"
},
"pnpm": {
"overrides": {
"vite": "5.4.10"
}
}
}
4 changes: 2 additions & 2 deletions packages/waku/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@
"dotenv": "16.4.7",
"hono": "4.6.14",
"rsc-html-stream": "0.0.4",
"vite": "5.4.10"
"vite": "6.0.6"
},
"devDependencies": {
"@netlify/functions": "^3.0.0",
"@swc/cli": "^0.5.2",
"rollup": "^4.29.1",
"ts-expect": "^1.3.0",
"vitest": "^2.1.8"
"vitest": "^3.0.0-beta.3"
},
"peerDependencies": {
"react": "~19.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/waku/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ async function loadConfig(): Promise<Config> {
if (!existsSync(CONFIG_FILE)) {
return {};
}
// FIXME can we avoid using vite to load the config?
const { loadServerFile } = await import('./lib/utils/vite-loader.js');
const file = pathToFileURL(path.resolve(CONFIG_FILE)).toString();
return (await loadServerFile(file)).default;
Expand Down
4 changes: 1 addition & 3 deletions packages/waku/src/lib/plugins/vite-plugin-rsc-entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ export function rscEntriesPlugin(opts: {
moduleMap: Record<string, string>;
}): Plugin {
const codeToPrepend = `
try {
globalThis.AsyncLocalStorage = (await import('node:async_hooks')).AsyncLocalStorage;
} catch (e) {}
globalThis.AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage;
`;
let codeToAppend = `
export function loadModule(id) {
Expand Down
11 changes: 6 additions & 5 deletions packages/waku/src/lib/plugins/vite-plugin-rsc-rsdw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ const patchRsdw = (code: string, type: 'SERVER' | 'CLIENT') => {
if (index === -1) {
throw new Error('rscRsdwPlugin: Unexpected code structure');
}
code =
code.slice(0, index) +

return code.replaceAll(
'function requireAsyncModule(id)',
`
globalThis.__WAKU_${type}_MODULE_LOADING__ ||= new Map();
globalThis.__WAKU_${type}_MODULE_CACHE__ ||= new Map();
Expand All @@ -26,9 +27,9 @@ globalThis.__WAKU_${type}_CHUNK_LOAD__ ||= (id) => {
return globalThis.__WAKU_${type}_MODULE_LOADING__.get(id);
};
globalThis.__WAKU_${type}_REQUIRE__ ||= (id) => globalThis.__WAKU_${type}_MODULE_CACHE__.get(id);
` +
code.slice(index);
return code;
function requireAsyncModule(id)
`,
);
};

export function rscRsdwPlugin(): Plugin {
Expand Down
4 changes: 3 additions & 1 deletion packages/waku/src/lib/utils/vite-loader.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { createServer as createViteServer } from 'vite';

import { fileURLToFilePath } from '../utils/path.js';

export const loadServerFile = async (fileURL: string) => {
const vite = await createViteServer({
ssr: {
external: ['waku'],
},
server: { middlewareMode: true, watch: null },
});
try {
return vite.ssrLoadModule(fileURLToFilePath(fileURL));
} finally {
await vite.close();
await vite.ws.close();
}
};
2 changes: 1 addition & 1 deletion packages/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"shiki": "^1.24.4",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
"vite": "5.4.10"
"vite": "6.0.6"
}
}
Loading
Loading