From 4acabb9860539cb702c0039039273da88e5bd332 Mon Sep 17 00:00:00 2001 From: Chawye Hsu Date: Sun, 19 Jan 2025 18:35:25 +0800 Subject: [PATCH] fix!: workaround vue ssr cannot resolve lazy load components in subdir related to https://github.com/vuejs/vue/issues/12924 Signed-off-by: Chawye Hsu --- packages/@alterjs/saber/src/utils/getFileNames.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/@alterjs/saber/src/utils/getFileNames.ts b/packages/@alterjs/saber/src/utils/getFileNames.ts index d0218b35..50267a2f 100644 --- a/packages/@alterjs/saber/src/utils/getFileNames.ts +++ b/packages/@alterjs/saber/src/utils/getFileNames.ts @@ -5,7 +5,13 @@ */ export default function getFileNames(useHash: boolean) { return { - js: useHash ? 'js/[name].[chunkhash:8].js' : 'js/[name].js', + // FIXME(chawyehsu): + // Ideally we want all js files to be placed in the `js/` subdirectory, + // but vue-server-renderer 2.x has a bug [1] with webpack 5 that it cannot + // resolve the correct path of the component that is imported using `import()`. + // + // [1]: https://github.com/vuejs/vue/issues/12924 + js: useHash ? '[name].[chunkhash:8].js' : '[name].js', css: useHash ? 'css/[name].[chunkhash:8].css' : 'css/[name].css', font: useHash ? 'fonts/[name].[hash:8].[ext]' : 'fonts/[path][name].[ext]', image: useHash