diff --git a/packages/start/config/index.js b/packages/start/config/index.js index 64f5497ee..b8dbb8b00 100644 --- a/packages/start/config/index.js +++ b/packages/start/config/index.js @@ -37,6 +37,14 @@ function solidStartServerFsRouter(config) { ); } +/** + * @param {string} filepath + * @returns {string} + */ +function convertToRelativePath(filepath) { + return filepath.replace(process.cwd(), "~"); +} + const SolidStartServerFnsPlugin = createTanStackServerFnPlugin({ // This is the ID that will be available to look up and import // our server function manifest and resolve its module @@ -47,7 +55,7 @@ const SolidStartServerFnsPlugin = createTanStackServerFnPlugin({ fileURLToPath(new URL("../dist/runtime/server-runtime.js", import.meta.url)) )}"`, replacer: opts => - `createServerReference(${() => {}}, '${opts.functionId}', '${opts.extractedFilename}')` + `createServerReference(${() => {}}, '${opts.functionId}', '${encodeURIComponent(convertToRelativePath(opts.extractedFilename))}')` }, ssr: { getRuntimeCode: () => @@ -55,7 +63,7 @@ const SolidStartServerFnsPlugin = createTanStackServerFnPlugin({ fileURLToPath(new URL("../dist/runtime/server-fns-runtime.js", import.meta.url)) )}'`, replacer: opts => - `createServerReference(${opts.fn}, '${opts.functionId}', '${opts.extractedFilename}')` + `createServerReference(${opts.fn}, '${opts.functionId}', '${encodeURIComponent(convertToRelativePath(opts.extractedFilename))}')` }, server: { getRuntimeCode: () => @@ -63,7 +71,7 @@ const SolidStartServerFnsPlugin = createTanStackServerFnPlugin({ fileURLToPath(new URL("../dist/runtime/server-fns-runtime.js", import.meta.url)) )}'`, replacer: opts => - `createServerReference(${opts.fn}, '${opts.functionId}', '${opts.extractedFilename}')` + `createServerReference(${opts.fn}, '${opts.functionId}', '${encodeURIComponent(convertToRelativePath(opts.extractedFilename))}')` } });