File tree Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change 22" @keystone-6/core " : minor
33---
44
5- Add support for developers to add ` esbuild.keystone.js ` to the working directory to replace the default esbuild configuration
5+ Add support for developers to add ` esbuild.keystone.js ` to the working directory to mutate the default esbuild configuration
Original file line number Diff line number Diff line change 11// WARNING: be careful not to import `esbuild` within next
22import { type BuildOptions } from 'esbuild'
33
4+ function identity ( x : BuildOptions ) { return x }
5+
46export function getEsbuildConfig ( cwd : string ) : BuildOptions {
7+ let esbuildFn : typeof identity | undefined
58 try {
6- return require ( require . resolve ( `${ cwd } /esbuild.keystone.js` ) )
9+ esbuildFn = require ( require . resolve ( `${ cwd } /esbuild.keystone.js` ) )
710 } catch ( e ) { }
11+ esbuildFn ??= identity
812
9- // default fallback
10- return {
13+ return esbuildFn ( {
1114 entryPoints : [ './keystone' ] ,
1215 absWorkingDir : cwd ,
1316 bundle : true ,
@@ -20,18 +23,15 @@ export function getEsbuildConfig (cwd: string): BuildOptions {
2023 {
2124 name : 'external-node_modules' ,
2225 setup ( build ) {
23- build . onResolve (
24- {
25- // don't bundle anything that is NOT a relative import
26- // WARNING: we can't use a negative lookahead/lookbehind because esbuild uses Go
27- filter : / (?: ^ [ ^ . ] ) | (?: ^ \. [ ^ / . ] ) | (?: ^ \. \. [ ^ / ] ) / ,
28- } ,
29- ( { path } ) => {
30- return { external : true , path }
31- }
32- )
26+ build . onResolve ( {
27+ // don't bundle anything that is NOT a relative import
28+ // WARNING: we can't use a negative lookahead/lookbehind because esbuild uses Go
29+ filter : / (?: ^ [ ^ . ] ) | (?: ^ \. [ ^ / . ] ) | (?: ^ \. \. [ ^ / ] ) / ,
30+ } , ( { path } ) => {
31+ return { external : true , path }
32+ } )
3333 } ,
3434 } ,
3535 ] ,
36- }
36+ } satisfies BuildOptions )
3737}
You can’t perform that action at this time.
0 commit comments