Bug description
Hi, the generated output circular references blocking bundlers like webpack. It would be very beneficial to solve this so that we can bundle it for web.
How to reproduce
// config.next.js
/* eslint-disable @typescript-eslint/no-var-requires */
const CircularDependencyPlugin = require('circular-dependency-plugin')
module.exports = withTM({
reactStrictMode: true,
swcMinify: false,
future: {
webpack5: true, // by default, if you customize webpack config, they switch back to version 4.
// Looks like backward compatibility approach.
},
webpack(config) {
const circularDependencyPlugin = new CircularDependencyPlugin({
// exclude detection of files based on a RegExp
exclude: /a\.js|node_modules/,
// include specific files based on a RegExp
// include: //,
// add errors to webpack instead of warnings
failOnError: true,
// allow import cycles that include an asyncronous import,
// e.g. via import(/* webpackMode: "weak" */ './file.js')
allowAsyncCycles: false,
// set the current working directory for displaying module paths
cwd: process.cwd(),
// `onStart` is called before the cycle detection starts
onStart({ compilation }) {
console.log('start detecting webpack modules cycles')
},
// `onDetected` is called for each module that is cyclical
onDetected({ module: webpackModuleRecord, paths, compilation }) {
console.log('new CD error')
console.log(paths)
// `paths` will be an Array of the relative module paths that make up the cycle
// `module` will be the module record generated by webpack that caused the cycle
compilation.errors.push(new Error(paths.join(' -> ')))
},
// `onEnd` is called before the cycle detection ends
onEnd({ compilation }) {
console.log('end detecting webpack modules cycles')
},
})
config.plugins.push(circularDependencyPlugin)
return config
},
})
Expected behavior
No circular references to exist. It should be avoidable by following this paradigm that exports everything from one file: https://medium.com/visual-development/how-to-fix-nasty-circular-dependency-issues-once-and-for-all-in-javascript-typescript-a04c987cf0de
Prisma information
// prisma/schema.prisma
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["interactiveTransactions"]
}
generator fieldEncryptionMigrations {
provider = "prisma-field-encryption"
output = "./migrations"
}
generator typegraphql {
provider = "typegraphql-prisma"
output = "../node_modules/.cache/type-graphql"
}
generator yup {
provider = "prisma-yup-generator"
output = "../src/prisma/gen"
}
generator erd {
provider = "prisma-erd-generator"
output = "../docs/diagrams/entity-relationship-diagram.svg"
}
enum Role {
ADMIN
USER
}
enum OrgRole {
OWNER
ADMIN
MEMBER
}
enum Tier {
FREE
PRO
ENTERPRISE
}
enum PaymentStatus {
PENDING
PAID
}
model License {
tier Tier
price Int
description String
@@unique([tier])
}
enum InvoicePeriod {
MONTHLY
YEARLY
}
model Account {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
userId String
type String
provider String
providerAccountId String
refresh_token String? @map("refreshToken") @db.Text
access_token String? @map("accessToken") @db.Text
expires_at Int? @map("expiresAt")
token_type String? @map("tokenType")
scope String?
id_token String? @map("idToken") @db.Text
session_state String? @map("sessionState")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
tier Tier @default(FREE) // may be upgraded to PRO then ENTERPRISE
clusters Cluster[]
organisation Organisation?
invoice Invoice[]
@@unique([provider, providerAccountId])
}
model Session {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
userId String
expires DateTime
session_token String @unique @map("sessionToken")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model User {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String?
email String? @unique
emailVerified DateTime?
image String?
phoneNumber String? /// @encrypted
address String? /// @encrypted
country String?
state String?
city String? /// @encrypted
zipCode String? /// @encrypted
avatarUrl String? /// @encrypted
company String?
role Role @default(USER)
accounts Account[]
sessions Session[]
userOrgs UserOrg[]
}
model VerificationToken {
identifier String
token String @unique
expires DateTime
@@unique([identifier, token])
}
model UserOrg {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
userId String @map("user_id")
organisationId String
role OrgRole
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
organisation Organisation @relation(fields: [organisationId], references: [id])
@@id([userId, organisationId])
}
model Invoice {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
accountId String
price Int // no fractions, will be exactly as paid in EURO at that moment in time
status PaymentStatus
period InvoicePeriod
startDate DateTime
endDate DateTime
account Account @relation(fields: [accountId], references: [id])
}
model Organisation {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
accountId String @unique
name String @unique
image String?
account Account @relation(fields: [accountId], references: [id])
orgUsers UserOrg[]
}
model Cluster {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
key String @default(cuid())
accountId String
name String
description String
provider String
kubecfg String?
account Account @relation(fields: [accountId], references: [id])
}
Environment & setup
- OS: Mac OS
- Database: PostgreSQL
- Node.js version: 16.14.2
Prisma Version
3.14.0
bug