Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with root + tsconfigPaths paths setup #475

Open
Meemaw opened this issue May 31, 2023 · 1 comment
Open

Issues with root + tsconfigPaths paths setup #475

Meemaw opened this issue May 31, 2023 · 1 comment

Comments

@Meemaw
Copy link

Meemaw commented May 31, 2023

Hi. I'm trying to use vite-plugin-relay on a project that uses src as the root, and uses tsconfig paths for absolute imports.

vitest.config.ts

import react from "@vitejs/plugin-react"
import tsconfigPaths from "vite-tsconfig-paths"
import { defineConfig } from "vitest/config"
import relay from "vite-plugin-relay"

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react(), tsconfigPaths(), relay],
  test: {
    globals: true,
    environment: "jsdom",
    setupFiles: ["./__tests__/setupVitestTests.ts"]
  },
  root: "src",
})

relay.config.js

module.exports = {
  src: "./src",
  schema: "./schema.graphql",
  schemaExtensions: ["./src"],
  exclude: [
    "**/__generated__/**",
    "**/__mocks__/**",
    "**/node_modules/**",
    "src/.next/**",
  ],
  language: "typescript",
  eagerEsModules: true,
  artifactDirectory: "./src/lib/graphql/__generated__",
}

tsconfig paths:

"paths": {
   "@/*": ["./*"]
}

Imports:

import { CollectionWatchlistButtonTestQuery } from "@/lib/graphql/__generated__/CollectionWatchlistButtonTestQuery.graphql"

When trying to run tests, vitest fails to find generated modules:

Screenshot 2023-05-31 at 08 16 40
@criskell
Copy link

Any solution?
Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants