Skip to content

Commit ab1b44c

Browse files
authored
Add support for developers to replace the default esbuild configuration (#9235)
Co-authored-by: Daniel Cousens <[email protected]>
1 parent d7e275f commit ab1b44c

File tree

15 files changed

+386
-43
lines changed

15 files changed

+386
-43
lines changed

.changeset/add-custom-esbuild.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@keystone-6/core": minor
3+
---
4+
5+
Add support for developers to add `esbuild.keystone.ts` to the working directory to mutate the default esbuild configuration

examples/custom-esbuild/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Base Project - Custom Esbuild
2+
3+
...
4+
5+
## Try it out in CodeSandbox 🧪
6+
7+
You can play with this example online in a web browser using the free [codesandbox.io](https://codesandbox.io/) service. To launch this example, open the URL <https://githubbox.com/keystonejs/keystone/tree/main/examples/custom-id>. You can also fork this sandbox to make your own changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { type BuildOptions } from 'esbuild'
2+
3+
export default function (defaults: BuildOptions) {
4+
return {
5+
...defaults,
6+
logLevel: 'verbose'
7+
}
8+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { config } from '@keystone-6/core'
2+
import { fixPrismaPath } from '../example-utils'
3+
import { lists } from './schema'
4+
import type { TypeInfo } from '.keystone/types'
5+
6+
export default config<TypeInfo>({
7+
db: {
8+
provider: 'sqlite',
9+
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
10+
11+
// WARNING: this is only needed for our monorepo examples, don't do this
12+
...fixPrismaPath,
13+
},
14+
lists,
15+
})
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "@keystone-6/example-custom-id",
3+
"version": "0.0.1",
4+
"private": true,
5+
"license": "MIT",
6+
"scripts": {
7+
"dev": "keystone dev",
8+
"start": "keystone start",
9+
"build": "keystone build",
10+
"postinstall": "keystone postinstall"
11+
},
12+
"dependencies": {
13+
"@keystone-6/core": "workspace:^",
14+
"@prisma/client": "catalog:"
15+
},
16+
"devDependencies": {
17+
"prisma": "catalog:",
18+
"typescript": "catalog:"
19+
}
20+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"template": "node",
3+
"container": {
4+
"startScript": "keystone dev",
5+
"node": "16"
6+
}
7+
}
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
# This file is automatically generated by Keystone, do not modify it manually.
2+
# Modify your Keystone config when you want to change this.
3+
4+
type Post {
5+
id: ID!
6+
name: String
7+
content: String
8+
}
9+
10+
input PostWhereUniqueInput {
11+
id: ID
12+
}
13+
14+
input PostWhereInput {
15+
AND: [PostWhereInput!]
16+
OR: [PostWhereInput!]
17+
NOT: [PostWhereInput!]
18+
id: IDFilter
19+
name: StringFilter
20+
content: StringFilter
21+
}
22+
23+
input IDFilter {
24+
equals: ID
25+
in: [ID!]
26+
notIn: [ID!]
27+
lt: ID
28+
lte: ID
29+
gt: ID
30+
gte: ID
31+
not: IDFilter
32+
}
33+
34+
input StringFilter {
35+
equals: String
36+
in: [String!]
37+
notIn: [String!]
38+
lt: String
39+
lte: String
40+
gt: String
41+
gte: String
42+
contains: String
43+
startsWith: String
44+
endsWith: String
45+
not: NestedStringFilter
46+
}
47+
48+
input NestedStringFilter {
49+
equals: String
50+
in: [String!]
51+
notIn: [String!]
52+
lt: String
53+
lte: String
54+
gt: String
55+
gte: String
56+
contains: String
57+
startsWith: String
58+
endsWith: String
59+
not: NestedStringFilter
60+
}
61+
62+
input PostOrderByInput {
63+
id: OrderDirection
64+
name: OrderDirection
65+
content: OrderDirection
66+
}
67+
68+
enum OrderDirection {
69+
asc
70+
desc
71+
}
72+
73+
input PostUpdateInput {
74+
name: String
75+
content: String
76+
}
77+
78+
input PostUpdateArgs {
79+
where: PostWhereUniqueInput!
80+
data: PostUpdateInput!
81+
}
82+
83+
input PostCreateInput {
84+
name: String
85+
content: String
86+
}
87+
88+
"""
89+
The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).
90+
"""
91+
scalar JSON @specifiedBy(url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf")
92+
93+
type Mutation {
94+
createPost(data: PostCreateInput!): Post
95+
createPosts(data: [PostCreateInput!]!): [Post]
96+
updatePost(where: PostWhereUniqueInput!, data: PostUpdateInput!): Post
97+
updatePosts(data: [PostUpdateArgs!]!): [Post]
98+
deletePost(where: PostWhereUniqueInput!): Post
99+
deletePosts(where: [PostWhereUniqueInput!]!): [Post]
100+
}
101+
102+
type Query {
103+
posts(where: PostWhereInput! = {}, orderBy: [PostOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PostWhereUniqueInput): [Post!]
104+
post(where: PostWhereUniqueInput!): Post
105+
postsCount(where: PostWhereInput! = {}): Int
106+
keystone: KeystoneMeta!
107+
}
108+
109+
type KeystoneMeta {
110+
adminMeta: KeystoneAdminMeta!
111+
}
112+
113+
type KeystoneAdminMeta {
114+
lists: [KeystoneAdminUIListMeta!]!
115+
list(key: String!): KeystoneAdminUIListMeta
116+
}
117+
118+
type KeystoneAdminUIListMeta {
119+
key: String!
120+
itemQueryName: String!
121+
listQueryName: String!
122+
hideCreate: Boolean!
123+
hideDelete: Boolean!
124+
path: String!
125+
label: String!
126+
singular: String!
127+
plural: String!
128+
description: String
129+
initialColumns: [String!]!
130+
pageSize: Int!
131+
labelField: String!
132+
fields: [KeystoneAdminUIFieldMeta!]!
133+
groups: [KeystoneAdminUIFieldGroupMeta!]!
134+
initialSort: KeystoneAdminUISort
135+
isHidden: Boolean!
136+
isSingleton: Boolean!
137+
}
138+
139+
type KeystoneAdminUIFieldMeta {
140+
path: String!
141+
label: String!
142+
description: String
143+
isOrderable: Boolean!
144+
isFilterable: Boolean!
145+
isNonNull: [KeystoneAdminUIFieldMetaIsNonNull!]
146+
fieldMeta: JSON
147+
viewsIndex: Int!
148+
customViewsIndex: Int
149+
createView: KeystoneAdminUIFieldMetaCreateView!
150+
listView: KeystoneAdminUIFieldMetaListView!
151+
itemView(id: ID): KeystoneAdminUIFieldMetaItemView
152+
search: QueryMode
153+
}
154+
155+
enum KeystoneAdminUIFieldMetaIsNonNull {
156+
read
157+
create
158+
update
159+
}
160+
161+
type KeystoneAdminUIFieldMetaCreateView {
162+
fieldMode: KeystoneAdminUIFieldMetaCreateViewFieldMode!
163+
}
164+
165+
enum KeystoneAdminUIFieldMetaCreateViewFieldMode {
166+
edit
167+
hidden
168+
}
169+
170+
type KeystoneAdminUIFieldMetaListView {
171+
fieldMode: KeystoneAdminUIFieldMetaListViewFieldMode!
172+
}
173+
174+
enum KeystoneAdminUIFieldMetaListViewFieldMode {
175+
read
176+
hidden
177+
}
178+
179+
type KeystoneAdminUIFieldMetaItemView {
180+
fieldMode: KeystoneAdminUIFieldMetaItemViewFieldMode
181+
fieldPosition: KeystoneAdminUIFieldMetaItemViewFieldPosition
182+
}
183+
184+
enum KeystoneAdminUIFieldMetaItemViewFieldMode {
185+
edit
186+
read
187+
hidden
188+
}
189+
190+
enum KeystoneAdminUIFieldMetaItemViewFieldPosition {
191+
form
192+
sidebar
193+
}
194+
195+
enum QueryMode {
196+
default
197+
insensitive
198+
}
199+
200+
type KeystoneAdminUIFieldGroupMeta {
201+
label: String!
202+
description: String
203+
fields: [KeystoneAdminUIFieldMeta!]!
204+
}
205+
206+
type KeystoneAdminUISort {
207+
field: String!
208+
direction: KeystoneAdminUISortDirection!
209+
}
210+
211+
enum KeystoneAdminUISortDirection {
212+
ASC
213+
DESC
214+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// This file is automatically generated by Keystone, do not modify it manually.
2+
// Modify your Keystone config when you want to change this.
3+
4+
datasource sqlite {
5+
url = env("DATABASE_URL")
6+
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
7+
provider = "sqlite"
8+
}
9+
10+
generator client {
11+
provider = "prisma-client-js"
12+
output = "node_modules/.myprisma/client"
13+
}
14+
15+
model Post {
16+
id String @id @default(cuid())
17+
name String @default("")
18+
content String @default("")
19+
}

examples/custom-esbuild/schema.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { list } from '@keystone-6/core'
2+
import { allowAll } from '@keystone-6/core/access'
3+
import { text } from '@keystone-6/core/fields'
4+
import type { Lists } from '.keystone/types'
5+
6+
export const lists = {
7+
Post: list({
8+
access: allowAll,
9+
fields: {
10+
name: text(),
11+
content: text(),
12+
},
13+
}),
14+
} satisfies Lists

packages/core/src/lib/esbuild.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)