I created a React Next.js project with Typescript on pnpm and using graphql-codegen/typescript to create types. On vercel build, I get module not found error for import of generated types with codegen.
On development server I generate types with ‘pnpm gen’ command manually from terminal. Probably while next build on vercel, it doesn’t run this command. I tried to add it, but couldn’t find where to add.
Here is package.json
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"codegen": "graphql-codegen --require dotenv/config --config codegen.ts",
"gen": "graphql-codegen --config codegen.ts"
},
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/server": "^11.11.0",
"@graphql-codegen/typescript": "^4.0.1",
"@graphql-codegen/typescript-operations": "^4.0.1",
"@graphql-typed-document-node/core": "^3.2.0",
"@mantine/carousel": "^6.0.19",
"@mantine/core": "^6.0.19",
"@mantine/dates": "^6.0.19",
"@mantine/form": "^6.0.19",
"@mantine/hooks": "^6.0.19",
"@mantine/next": "^6.0.19",
"@react-icons/all-files": "^4.1.0",
"@saleor/auth-sdk": "^0.8.0",
"@tabler/icons": "^2.34.0",
"@tabler/icons-react": "^2.31.0",
"autoprefixer": "^10.4.15",
"date-fns": "^2.30.0",
"graphql": "^16.6.0",
"graphql-tag": "^2.12.6",
"next": "^13.4.3",
"next-urql": "^5.0.1",
"options": "^0.0.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"tailwindcss": "^3.3.3",
"ts-invariant": "^0.10.3",
"urql": "^4.0.2"
},
"devDependencies": {
"@graphql-codegen/cli": "5.0.0",
"@graphql-codegen/client-preset": "4.1.0",
"@types/node": "^20.2.3",
"@types/react": "^18.2.6",
"@types/react-dom": "^18.2.4",
"dotenv": "^16.0.3",
"eslint": "^8.41.0",
"eslint-config-next": "^13.4.3",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
}
}