Skip to content

Make Prisma Client (usage + generation) ASAR compatible #4356

@sdnts

Description

@sdnts

Problem

I would like to package the Studio electron app's resources as an ASAR archive.

There are two issues that have come up when I try to do this:

  1. Paths inside an ASAR archive are unreliable:
    All JS code is "packed" into one app.asar file. This has the implication that there would no longer be a real file system inside the electron app's code. For most cases, this is fine, but in order to run a binary, ASAR "unpacks" / moves all executable files outside the main archive. This means any code that relies on __dirname or relative paths to figure out the QE binary's location can no longer work. These methods need a way to override this binary location.
    Functions to consider: getConfig, getGenerators

  2. ASAR archives are readonly:
    From what I can see, getGenerators (and accompanying code in @prisma/client that actually does the generation) heavily relies on modifying the node_modules directory. This will not be possible with an ASAR archive, because it is read only. It seems to be downloading the QE binary (even when skipDownload is set t true, which could be a separate issue altogether). I suppose we could either not download the binary and instead use one that is provided, or I give the function a read-write path that it can use. This needs a bit of discussion.

Unpacking all Prisma dependencies out of the archive defeats the purpose of the archive.
Windows has a problem with paths that are longer than 260 characters (out of the box), and so ASAR is almost a requirement for it. On other platforms, it prevents security risks, so it is very much recommended.

Suggested solution

Needs to be discussed

Metadata

Metadata

Assignees

Labels

kind/techA technical change.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions