From b6f0084e3884a3846feb7ed3319cef620ff6cec5 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Mon, 6 May 2024 16:07:34 -0400 Subject: [PATCH] Use @-imports in TS runtime code (#50470) Co-authored-by: Robert Sese <734194+rsese@users.noreply.github.com> --- Dockerfile | 1 + src/frame/lib/app.ts | 2 +- vitest.config.ts | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b33ee4f8dc..66895d39ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -93,6 +93,7 @@ COPY --chown=node:node .remotejson-cache* ./.remotejson-cache COPY --chown=node:node .pageinfo-cache.json.br* ./.pageinfo-cache.json.br COPY --chown=node:node data ./data COPY --chown=node:node next.config.js ./ +COPY --chown=node:node tsconfig.json ./ EXPOSE $PORT diff --git a/src/frame/lib/app.ts b/src/frame/lib/app.ts index b8049eba8e..3060493b97 100644 --- a/src/frame/lib/app.ts +++ b/src/frame/lib/app.ts @@ -1,5 +1,5 @@ import express from 'express' -import middleware from '../middleware/index.js' +import middleware from '@/frame/middleware/index.js' function createApp() { const app = express() diff --git a/vitest.config.ts b/vitest.config.ts index 1d0a742810..332e0c3611 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -5,6 +5,11 @@ export default { exclude: ['**/tests/playwright-*.spec.ts'], // Default is `!process.env.CI` watch: false, + // vitest doesn't account for tsconfig.json `paths` settings so we have to + // manually set this alias to resolve our TS @-imports + alias: { + '@/': new URL('./src/', import.meta.url).pathname, + }, globalSetup: './src/tests/vitest.setup.ts', },