Help with (new) monorepo tsconfig

Ive just started merging two codebases into a monorepo basically i have FM and reporting we have a /tsconfig.json (in FM) and a /reporting/tsconfig.json after merging all the /reporting tests passed, but then after updating the prisma.schema in /prisma/prisma.schema the reporting tests started to fail both of these tsconfigs had
"paths": {
"src/*": ["./src/*"],
}
"paths": {
"src/*": ["./src/*"],
}
and a prisma client importing "src/prisma" i've now moved /reporting/src to reporting/code and done a replace all on "src/" to "code/" and then changed all the "code/prisma" references to "src/prisma" so that we should be referencing FM's prisma client but the paths in tsconifg are not resolving the way i expect...
21 Replies
fotoflo
fotoflo•15mo ago
I tried updating paths like this:
"rootDir": "code",
"baseUrl": "./",
"paths": {
"code/*": ["./code/*"],
"src/*": ["../src/*"]
},
"rootDir": "code",
"baseUrl": "./",
"paths": {
"code/*": ["./code/*"],
"src/*": ["../src/*"]
},
Ok i resolved this issue but now im getting ../src/server/db/PrismaClient.ts:3:21 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("src/env/server.mjs")' call instead. To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field "type": "module" to '/Users/fotoflo/dev/fastmonitor/package.json'. 3 import { env } from "src/env/server.mjs";
Unknown User
Unknown User•15mo ago
Message Not Public
Sign In & Join Server To View
fotoflo
fotoflo•15mo ago
hi @florida-dev i still ahve two packages im thinjking to delete one actually lets see @florida-dev thanks for looking Type 'import("/Users/fotoflo/dev/fastmonitor/node_modules/.prisma/client/index").reportingBatch' is not assignable to type 'import("/Users/fotoflo/dev/fastmonitor/reporting/node_modules/.prisma/client/index").reportingBatch'. wtf clearly using two prisma clients
import type { reportingBatch } from "@prisma/client"; // where's this one from?
import prisma from "PrismaClient"; // from paths { "PrismaClient": ["../src/PrismaClient"] i think }
import type { reportingBatch } from "@prisma/client"; // where's this one from?
import prisma from "PrismaClient"; // from paths { "PrismaClient": ["../src/PrismaClient"] i think }
if i delete the/reporting/package.json and merge is that advisable @florida-dev ? i merged the packages and added type:module get this now: ReferenceError: require is not defined in ES module scope, you can use import instead
Unknown User
Unknown User•15mo ago
Message Not Public
Sign In & Join Server To View
fotoflo
fotoflo•15mo ago
From /tsconfig
{
"compilerOptions": {
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"noEmit": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"noUncheckedIndexedAccess": true,
"lib": ["dom", "dom.iterable", "esnext"],
"target": "es2017",
"module": "commonjs",
"moduleResolution": "node",
"paths": {
"src/*": ["./src/*"],
"code/*": ["./reporting/code/*"],
"DesignSystem/*": ["./src/components/DesignSystem/*"],
"AuthPages/*": ["./src/components/AuthPages/*"],
"DashPages/*": ["./src/components/DashPages/*"],
"SettingsPages/*": ["./src/components/SettingsPages/*"],
"server/*": ["./src/server/*"],
"PrismaClient": ["./src/server/db/PrismaClient"]
},
"plugins": [
{
"name": "next"
}
]
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"**/*.cjs",
"**/*.mjs",
".next/types/**/*.ts",
"jest.config.js",
"./reporting/**/*"
],
"exclude": ["node_modules"]
}
{
"compilerOptions": {
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"noEmit": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"noUncheckedIndexedAccess": true,
"lib": ["dom", "dom.iterable", "esnext"],
"target": "es2017",
"module": "commonjs",
"moduleResolution": "node",
"paths": {
"src/*": ["./src/*"],
"code/*": ["./reporting/code/*"],
"DesignSystem/*": ["./src/components/DesignSystem/*"],
"AuthPages/*": ["./src/components/AuthPages/*"],
"DashPages/*": ["./src/components/DashPages/*"],
"SettingsPages/*": ["./src/components/SettingsPages/*"],
"server/*": ["./src/server/*"],
"PrismaClient": ["./src/server/db/PrismaClient"]
},
"plugins": [
{
"name": "next"
}
]
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"**/*.cjs",
"**/*.mjs",
".next/types/**/*.ts",
"jest.config.js",
"./reporting/**/*"
],
"exclude": ["node_modules"]
}
and from /reporting/tsconif g
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "../",
"baseUrl": "./",
"paths": {
"code/*": ["./code/*"],
"src/*": ["../src/*"],
"PrismaClient": ["../src/server/db/PrismaClient"]
}
}
}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "../",
"baseUrl": "./",
"paths": {
"code/*": ["./code/*"],
"src/*": ["../src/*"],
"PrismaClient": ["../src/server/db/PrismaClient"]
}
}
}
i hate this tsconfig stuff @florida-dev i let chatgpt merge my packages... hahah
fotoflo
fotoflo•15mo ago
it did a good job 🙂
fotoflo
fotoflo•15mo ago
now i cd into reporting to run jest tho
Unknown User
Unknown User•15mo ago
Message Not Public
Sign In & Join Server To View
fotoflo
fotoflo•15mo ago
yeah i think they snuck in
fotoflo
fotoflo•15mo ago
fotoflo
fotoflo•15mo ago
can i cahnge something here? err even my old jestconfig.js uses require
Unknown User
Unknown User•15mo ago
Message Not Public
Sign In & Join Server To View
fotoflo
fotoflo•15mo ago
nope
fotoflo
fotoflo•15mo ago
Unknown User
Unknown User•15mo ago
Message Not Public
Sign In & Join Server To View
fotoflo
fotoflo•15mo ago
prety breezy
Unknown User
Unknown User•15mo ago
Message Not Public
Sign In & Join Server To View
fotoflo
fotoflo•15mo ago
id be much happier of the tests ran successfully after each time now jest still nto working but i think it works thats inside reporting wow i think it worked i just updated liek 30 files and suddly jest is running ok now we're back to tsconfig stuff ... import prisma from "PrismaClient"; Cannot find module 'PrismaClient' from 'reporting/code/test/testUtils.ts'
fotoflo
fotoflo•15mo ago
Unknown User
Unknown User•15mo ago
Message Not Public
Sign In & Join Server To View
fotoflo
fotoflo•15mo ago
still same
Want results from more Discord servers?
Add your server
More Posts