Skip to content
Open
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
14 changes: 11 additions & 3 deletions packages/start/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -47,23 +55,23 @@ 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: () =>
`import { createServerReference } from '${normalize(
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: () =>
`import { createServerReference } from '${normalize(
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))}')`
}
});

Expand Down