Skip to content

Commit

Permalink
fix(cli): Fix studio `Query engine binary for current platform ... co…
Browse files Browse the repository at this point in the history
…uld not be found.` (#6563)

(cherry picked from commit 54a2f70)
  • Loading branch information
Siddhant authored and Jolg42 committed Apr 14, 2021
1 parent 8ebff26 commit 57fda54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
19 changes: 0 additions & 19 deletions src/packages/cli/helpers/build.js
Expand Up @@ -9,24 +9,6 @@ const { promisify } = require('util')
const copyFile = promisify(fs.copyFile)
const lineReplace = require('line-replace')

let prismaClientPlugin = {
name: 'prisma-client-plugin',
setup(build) {
// Redirect all imports from `@prisma/client*` to `../prisma-client*`. This is needed because of Studio.
build.onResolve({ filter: /^@prisma\/client/ }, (args) => {
return {
path: require.resolve(
path.resolve(
__dirname,
'../',
args.path.replace('@prisma/client', 'prisma-client'),
),
),
}
})
},
}

async function main() {
const before = Date.now()

Expand All @@ -42,7 +24,6 @@ async function main() {
platform: 'node',
bundle: true,
target: 'node10',
plugins: [prismaClientPlugin],
outfile: 'build/index.js',
entryPoints: ['src/bin.ts'],
external: ['@prisma/engines', '_http_common'],
Expand Down
18 changes: 6 additions & 12 deletions src/packages/cli/src/Studio.ts
Expand Up @@ -111,18 +111,12 @@ ${chalk.bold('Examples')}
const browser = args['--browser'] || process.env.BROWSER
const platform = await getPlatform()
const extension = platform === 'windows' ? '.exe' : ''
const queryEnginePath =
process.env.NODE_ENV === 'production'
? path.join(__dirname, `../query-engine-${platform}${extension}`)
: path.join(
__dirname,
`../node_modules/@prisma/engines/query-engine-${platform}${extension}`,
)

const staticAssetDir =
process.env.NODE_ENV === 'production'
? path.resolve(__dirname, './public')
: path.resolve(__dirname, '../build/public')
const queryEnginePath = path.join(
require.resolve('@prisma/engines'),
`../../query-engine-${platform}${extension}`,
)

const staticAssetDir = path.resolve(__dirname, '../build/public')

const studio = new StudioServer({
schemaPath,
Expand Down

0 comments on commit 57fda54

Please sign in to comment.