Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): Exclude source maps from bundled client (#18571)
Client, bundled in cli still shipped with source maps. Fixed by using `npm-packlist`, so that contents of bundled client will always be identical to `@prisma/client` pacakge.
- Loading branch information
Showing
3 changed files
with
21 additions
and
19 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 |
---|---|---|
@@ -1,23 +1,25 @@ | ||
import fg from 'fast-glob' | ||
import { copySync } from 'fs-extra' | ||
import packlist from 'npm-packlist' | ||
import path from 'path' | ||
|
||
// that's where we want to copy the local client for @prisma/studio | ||
const clientCopyPath = path.join(__dirname, '..', 'prisma-client') | ||
async function main() { | ||
// that's where we want to copy the local client for @prisma/studio | ||
const clientCopyPath = path.join(__dirname, '..', 'prisma-client') | ||
|
||
// we resolve where the client is located via our own dependencies | ||
const clientPath = path.dirname(require.resolve('@prisma/client')) | ||
const clientPkg = require('@prisma/client/package.json') | ||
// we resolve where the client is located via our own dependencies | ||
const clientPath = path.dirname(require.resolve('@prisma/client')) | ||
|
||
// we compute the paths of the files that would get npm published | ||
// this uses a glob library to understand patterns in files. | ||
// Using tooling from npm would be even better, but it is in magnitudes slower compared to this approach. | ||
// Ideally, it would be great if we could remove this somehow. | ||
const clientFiles = fg.sync(clientPkg.files, { cwd: clientPath, dot: true, onlyFiles: false }) | ||
const clientFiles = await packlist({ path: clientPath }) | ||
|
||
// we copy each file that we found in pkg to a new destination | ||
for (const file of clientFiles) { | ||
const from = path.join(clientPath, file) | ||
const to = path.join(clientCopyPath, file) | ||
copySync(from, to, { overwrite: true, recursive: true }) | ||
// we copy each file that we found in pkg to a new destination | ||
for (const file of clientFiles) { | ||
const from = path.join(clientPath, file) | ||
const to = path.join(clientCopyPath, file) | ||
copySync(from, to, { overwrite: true, recursive: true }) | ||
} | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error) | ||
process.exitCode = 1 | ||
}) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.