forked from keystonejs/keystone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use esbuild to build server-side code (keystonejs#7809)
Co-authored-by: Daniel Cousens <413395+dcousens@users.noreply.github.com>
- Loading branch information
Showing
32 changed files
with
558 additions
and
478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@keystone-6/core': patch | ||
--- | ||
|
||
Changed platform compilation to use [esbuild](https://esbuild.github.io/), previously used next.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...reak-in-patch/require-source/package.json → ...l-break-in-patch/load-config/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"main": "dist/keystone-6-core-___internal-do-not-use-will-break-in-patch-require-source.cjs.js", | ||
"module": "dist/keystone-6-core-___internal-do-not-use-will-break-in-patch-require-source.esm.js" | ||
"main": "dist/keystone-6-core-___internal-do-not-use-will-break-in-patch-load-config.cjs.js", | ||
"module": "dist/keystone-6-core-___internal-do-not-use-will-break-in-patch-load-config.esm.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/core/src/___internal-do-not-use-will-break-in-patch/load-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { loadConfigOnce as loadConfig } from '../lib/config/loadConfig'; |
1 change: 0 additions & 1 deletion
1
packages/core/src/___internal-do-not-use-will-break-in-patch/require-source.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import esbuild, { BuildOptions } from 'esbuild'; | ||
import { KeystoneConfig } from '../../types'; | ||
import { getBuiltConfigPath } from '../../scripts/utils'; | ||
import { initConfig } from './initConfig'; | ||
|
||
export function getEsbuildConfig(cwd: string): BuildOptions { | ||
return { | ||
entryPoints: ['./keystone'], | ||
absWorkingDir: cwd, | ||
bundle: true, | ||
outfile: '.keystone/config.js', | ||
format: 'cjs', | ||
plugins: [ | ||
{ | ||
name: 'external-node_modules', | ||
setup(build) { | ||
build.onResolve( | ||
{ | ||
// this regex is intended to be the opposite of /^\.\.?(?:\/|$)/ | ||
// so it matches anything that isn't a relative import | ||
// so this means that we're only going to bundle relative imports | ||
// we can't use a negative lookahead/lookbehind because this regex is executed | ||
// by Go's regex package which doesn't support them | ||
// this regex could have less duplication with nested groups but this is probably easier to read | ||
filter: /(?:^[^.])|(?:^\.[^/.])|(?:^\.\.[^/])/, | ||
}, | ||
args => { | ||
return { external: true, path: args.path }; | ||
} | ||
); | ||
}, | ||
}, | ||
], | ||
}; | ||
} | ||
|
||
export function loadBuiltConfig(cwd: string): KeystoneConfig { | ||
return initConfig(require(getBuiltConfigPath(cwd)).default); | ||
} | ||
|
||
export async function loadConfigOnce(cwd: string): Promise<KeystoneConfig> { | ||
await esbuild.build(getEsbuildConfig(cwd)); | ||
return loadBuiltConfig(cwd); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.