Skip to content

Commit

Permalink
fix windows build issue (#6530)
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamsi authored Sep 14, 2021
1 parent e0d9626 commit 80cd313
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-pianos-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/keystone': patch
---

Fixed remaining windows issue where it creates invalid import path. This removes some duplicate code which caused this.
17 changes: 2 additions & 15 deletions packages/keystone/src/scripts/build/build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Path from 'path';
import prettier from 'prettier';
import fs from 'fs-extra';
import { AdminFileToWrite } from '../../types';
import { buildAdminUI, generateAdminUI } from '../../admin-ui/system';
Expand All @@ -8,6 +7,8 @@ import { initConfig } from '../../lib/config/initConfig';
import { requireSource } from '../../lib/config/requireSource';
import { generateNodeModulesArtifacts, validateCommittedArtifacts } from '../../artifacts';
import { getAdminPath, getConfigPath } from '../utils';
import { serializePathForImport } from '../../admin-ui/utils/serializePathForImport';
import { formatSource } from '../../admin-ui/system/generateAdminUI';

// FIXME: Duplicated from admin-ui package. Need to decide on a common home.
async function writeAdminFile(file: AdminFileToWrite, projectAdminPath: string) {
Expand All @@ -27,20 +28,6 @@ async function writeAdminFile(file: AdminFileToWrite, projectAdminPath: string)
}
}

// FIXME: Duplicated from admin-ui package. Need to decide on a common home.
export function serializePathForImport(path: string) {
// JSON.stringify is important here because it will escape windows style paths(and any thing else that might potentionally be in there)
return JSON.stringify(
path
// Next is unhappy about imports that include .ts/tsx in them because TypeScript is unhappy with them becasue when doing a TypeScript compilation with tsc, the imports won't be written so they would be wrong there
.replace(/\.tsx?$/, '')
);
}

// FIXME: Duplicated from admin-ui package. Need to decide on a common home.
export const formatSource = (src: string, parser: 'babel' | 'babel-ts' = 'babel') =>
prettier.format(src, { parser, trailingComma: 'es5', singleQuote: true });

const reexportKeystoneConfig = async (cwd: string, isDisabled?: boolean) => {
const projectAdminPath = getAdminPath(cwd);
const configPath = getConfigPath(cwd);
Expand Down

0 comments on commit 80cd313

Please sign in to comment.