brillout/telefunc

square brackets in path to telefunc file cause error in sveltekit build

samuba opened this issue · 6 comments

Just added telefunc (which looks awesome by the way) to my sveltekit project and it explodes on build.
I'm using sveltekit 1.15.9 vite 4.3.3 nothing fancy going on in the telefunc'tions.

The logs told me to post these information:

Error: [telefunc@0.1.52][Bug] You stumbled upon a bug in Telefunc's source code.

{
  "sourceFiles": [
    "/__telefunc_typeToShield.ts",
    "/Users/sabach/private-source/eventa2/vite.config.ts",
    "/Users/sabach/private-source/eventa2/.svelte-kit/ambient.d.ts",
    "/Users/sabach/private-source/eventa2/src/app.d.ts",
    "/Users/sabach/private-source/eventa2/src/hooks.client.ts",
    "/Users/sabach/private-source/eventa2/src/hooks.server.ts",
    "/Users/sabach/private-source/eventa2/src/telefunc.d.ts",
    "/Users/sabach/private-source/eventa2/tests/common.ts",
    "/Users/sabach/private-source/eventa2/tests/event.spec.ts",
    "/Users/sabach/private-source/eventa2/tests/guest.spec.ts",
    "/Users/sabach/private-source/eventa2/tests/home.spec.ts",
    "/Users/sabach/private-source/eventa2/src/lib/actions.ts",
    "/Users/sabach/private-source/eventa2/src/lib/analytics.ts",
    "/Users/sabach/private-source/eventa2/src/lib/common.ts",
    "/Users/sabach/private-source/eventa2/src/lib/currentEvent.ts",
    "/Users/sabach/private-source/eventa2/src/lib/database.types.ts",
    "/Users/sabach/private-source/eventa2/src/lib/eventTypes.ts",
    "/Users/sabach/private-source/eventa2/src/lib/formSchemas.ts",
    "/Users/sabach/private-source/eventa2/src/lib/routes.ts",
    "/Users/sabach/private-source/eventa2/src/lib/supabase.server.ts",
    "/Users/sabach/private-source/eventa2/src/lib/supabase.ts",
    "/Users/sabach/private-source/eventa2/src/lib/types.d.ts",
    "/Users/sabach/private-source/eventa2/src/lib/user.ts",
    "/Users/sabach/private-source/eventa2/src/routes/+page.server.ts",
    "/Users/sabach/private-source/eventa2/src/lib/server/email.ts",
    "/Users/sabach/private-source/eventa2/src/lib/server/event.ts",
    "/Users/sabach/private-source/eventa2/src/routes/_telefunc/+server.ts",
    "/Users/sabach/private-source/eventa2/.svelte-kit/types/src/routes/$types.d.ts",
    "/Users/sabach/private-source/eventa2/.svelte-kit/types/src/routes/proxy+page.server.ts",
    "/Users/sabach/private-source/eventa2/src/routes/e/[slug]/__telefunc_shieldGen_event.telefunc.ts",
    "/Users/sabach/private-source/eventa2/src/routes/e/[slug]/+page.server.ts",
    "/Users/sabach/private-source/eventa2/src/routes/e/[slug]/event.telefunc.ts",
    "/Users/sabach/private-source/eventa2/src/routes/e/new/+page.server.ts",
    "/Users/sabach/private-source/eventa2/.svelte-kit/types/src/routes/_telefunc/$types.d.ts",
    "/Users/sabach/private-source/eventa2/src/routes/e/[slug]/delete/+server.ts",
    "/Users/sabach/private-source/eventa2/src/routes/e/[slug]/edit/+page.server.ts",
    "/Users/sabach/private-source/eventa2/.svelte-kit/types/src/routes/e/[slug]/$types.d.ts",
    "/Users/sabach/private-source/eventa2/.svelte-kit/types/src/routes/e/[slug]/proxy+page.server.ts",
    "/Users/sabach/private-source/eventa2/.svelte-kit/types/src/routes/e/new/$types.d.ts",
    "/Users/sabach/private-source/eventa2/.svelte-kit/types/src/routes/e/[slug]/delete/$types.d.ts",
    "/Users/sabach/private-source/eventa2/.svelte-kit/types/src/routes/e/[slug]/edit/$types.d.ts"
  ]
}
at getProject (/Users/sabach/private-source/eventa2/node_modules/telefunc/dist/cjs/node/server/shield/codegen/generateShield.js:66:28)
    at generateShield (/Users/sabach/private-source/eventa2/node_modules/telefunc/dist/cjs/node/server/shield/codegen/generateShield.js:17:62)
    at transformTelefuncFileServerSide (/Users/sabach/private-source/eventa2/node_modules/telefunc/dist/cjs/node/transformer/transformTelefuncFileServerSide.js:13:52)
    at async Object.transform (/Users/sabach/private-source/eventa2/node_modules/telefunc/dist/cjs/node/vite/plugins/transform.js:29:24)
    at async transform (file:///Users/sabach/private-source/eventa2/node_modules/rollup/dist/es/shared/node-entry.js:23499:16)
    at async ModuleLoader.addModuleSource (file:///Users/sabach/private-source/eventa2/node_modules/rollup/dist/es/shared/node-entry.js:23705:30)

It looks like this happens when the path to a telefunc file contains square brackets. Was able to reproduce it here:
https://stackblitz.com/edit/sveltejs-kit-template-default-vwsxet?file=src/routes/+page.svelte
just run npm run build in the terminal

I could reproduce indeed. Please publish the reproduction on GitHub.

Nevermind, I'm seeing that I can download the repo from StackBlitz.

Fix released in 0.1.53.

In case you think you can convince your employer: https://github.com/sponsors/brillout.

In using it for a small side project, but would definetly ask my employer if he were involved. You really delivered on that 24h bug fix promise 🔥

Thanks, I appreciate it! And I'm glad you like it :-).