Skip to content

Commit 1cde331

Browse files
allow to specify importer in server-functions-plugin
this importer is used during dev
1 parent c0b2a8b commit 1cde331

File tree

1 file changed

+6
-2
lines changed
  • packages/server-functions-plugin/src

1 file changed

+6
-2
lines changed

packages/server-functions-plugin/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export type ServerFnPluginOpts = {
2626
client: ServerFnPluginEnvOpts
2727
ssr: ServerFnPluginEnvOpts
2828
server: ServerFnPluginEnvOpts
29+
importer?: (fn: DirectiveFn) => Promise<any>
2930
}
3031

3132
const manifestFilename =
@@ -62,7 +63,8 @@ export function createTanStackServerFnPlugin(opts: ServerFnPluginOpts): {
6263
// into the manifest because it's a dynamic import. Instead, as you'll
6364
// see below, we augment the manifest output with a code-generated importer
6465
// that looks exactly like this.
65-
importer: () => import(fn.extractedFilename),
66+
importer: () =>
67+
opts.importer ? opts.importer(fn) : import(fn.extractedFilename),
6668
},
6769
]),
6870
),
@@ -202,6 +204,7 @@ export interface TanStackServerFnPluginEnvOpts {
202204
getRuntimeCode: () => string
203205
replacer: ReplacerFn
204206
}
207+
importer: (fn: DirectiveFn) => Promise<any>
205208
}
206209

207210
export function TanStackServerFnPluginEnv(
@@ -240,7 +243,8 @@ export function TanStackServerFnPluginEnv(
240243
// into the manifest because it's a dynamic import. Instead, as you'll
241244
// see below, we augment the manifest output with a code-generated importer
242245
// that looks exactly like this.
243-
importer: () => import(fn.extractedFilename),
246+
importer: () =>
247+
opts.importer ? opts.importer(fn) : import(fn.extractedFilename),
244248
},
245249
]),
246250
),

0 commit comments

Comments
 (0)