Skip to content

Issue importing local TS files from entry #21

@giacomorebonato

Description

@giacomorebonato

The following is the code my entry points to:

import type { FastifyCookieOptions } from '@fastify/cookie';
import type { DefineFastifyRoutes } from '@matthewp/astro-fastify';
import { fastifyTRPCPlugin } from '@trpc/server/adapters/fastify';

import { createApiContext } from './api-context.js' // fails;
import { env } from './env.js';                                     // fails
import { apiRouter } from './routes/index.js';           // fails

const defineRoutes: DefineFastifyRoutes = async (fastify) => {
  const cookieOption: FastifyCookieOptions = {
    secret: env.JWT_SECRET,
  }

  fastify
    .register(import('fastify-graceful-shutdown'))
    .register(import('@fastify/websocket'))
    .register(import('@fastify/cookie'), cookieOption)
    .register(import('@fastify/csrf-protection'))
    .register(fastifyTRPCPlugin, {
      prefix: '/trpc',
      useWSS: true,
      trpcOptions: { router: apiRouter, createContext: createApiContext },
    })
};

export default defineRoutes;

All the local imports fail with:

Failed to load url ./api-context.ts (resolved id: ./api-context.ts). Does the file exist?

Do you know what's happening?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions