Skip to content

Commit

Permalink
Fix build failing with uniquely named types error (#6872)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown authored Nov 2, 2021
1 parent 8dac6bb commit aa98b1c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-mangos-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/keystone': patch
---

Fixed `Schema must contain uniquely named types but contains multiple types named "OrderDirection".` error when running `keystone-next build`.
25 changes: 18 additions & 7 deletions packages/keystone/src/admin-ui/system/buildAdminUI.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
export async function buildAdminUI(projectAdminPath: string) {
if (process.env.NODE_ENV !== 'production') {
throw new Error('process.env.NODE_ENV must be set to production to build the Admin UI');
let prevNodeEnv = process.env.NODE_ENV;
// Next does a broken build unless we set NODE_ENV to production
// @ts-ignore
process.env.NODE_ENV = 'production';
try {
// importing next/dist/build is quite expensive so we're requiring it lazily
/** We do this to stop webpack from bundling next inside of next */
const next = 'next/dist/build';
const build = require(next).default;
await build(projectAdminPath);
} finally {
if (prevNodeEnv === undefined) {
// @ts-ignore
delete process.env.NODE_ENV;
} else {
// @ts-ignore
process.env.NODE_ENV = prevNodeEnv;
}
}
// importing next/dist/build is quite expensive so we're requiring it lazily
/** We do this to stop webpack from bundling next inside of next */
const next = 'next/dist/build';
const build = require(next).default;
await build(projectAdminPath);
}
4 changes: 0 additions & 4 deletions packages/keystone/src/scripts/build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ const reexportKeystoneConfig = async (cwd: string, isDisabled?: boolean) => {
};

export async function build(cwd: string) {
// Next does a broken build unless we set NODE_ENV to production
// @ts-ignore
process.env.NODE_ENV = 'production';

const config = initConfig(requireSource(getConfigPath(cwd)).default);

const { graphQLSchema, adminMeta } = createSystem(config);
Expand Down

0 comments on commit aa98b1c

Please sign in to comment.