Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(*): polishing upstream work on the data proxy [DPGA, 5] #13629

Merged
merged 39 commits into from Jun 7, 2022

Conversation

millsp
Copy link
Member

@millsp millsp commented Jun 2, 2022

This PR aims to finalize the work on the Data Proxy GA. It is released as an integration version so that we can upgrade ecosystem tests and do manual QA. Small defects will be corrected here and missing tests will be written here too. Please base your review on the comments, and not the commits.

Todo:

Prev #13627

https://github.com/orgs/prisma/projects/70#card-82366798

@janpio janpio changed the title chore(*): polishing upstream work on the data proxy [DPGA] chore(*): polishing upstream work on the data proxy [DPGA-5] Jun 3, 2022
@janpio janpio changed the title chore(*): polishing upstream work on the data proxy [DPGA-5] chore(*): polishing upstream work on the data proxy [DPGA, 5] Jun 3, 2022
@millsp millsp force-pushed the integration/chore/data-proxy-ga-5 branch from 5b1607e to 5cf1374 Compare June 3, 2022 17:52
await makeDir(dotPrismaClientDir)

const dotPrismaClientEdgeDir = path.join(dotPrismaClientDir, 'edge')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed anymore, instead of having a full folder, we just have one file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Isomorphism is not needed because bundling for the edge means that we always bundle for the browser)

@@ -123,17 +123,8 @@ export async function buildClient({

// we only generate the edge client if `--data-proxy` is passed
if (dataProxy === true) {
fileMap[path.join('edge', 'index.js')] = await JS(edgeTsClient, true)
fileMap[path.join('edge', 'package.json')] = JSON.stringify(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed anymore, instead of having a full folder, we just have one file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Isomorphism is not needed because bundling for the edge means that we always bundle for the browser)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, so that means in isomporphic setups we will be bundling the whole client for the browser, right? In previous setup it was only enums, version info and a bunch of stubs, so significantly smaller amount of code. Is that what we want?

Copy link
Member Author

@millsp millsp Jun 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you deploy on Cloudflare Workers, it is by default bundled via the browser field. The same applies to Vercel Edge Functions, they always chose browser field. That means we cannot have such isomorphism, but just a browser build, hence the single file. So yes, if you bundle @prisma/client/edge into your frontend, you get the non-needed runtime with it, unfortunately. The best way to tackle this would be to have esm modules so that tree-shaking can take place (but that's a bigger project). In the meantime @prisma/client can be used.

@@ -0,0 +1,3 @@
export const fn = () => {}

fn.prototype = fn
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Polyfill for Vercel which disallows Function.

},
plugins: [
fillPlugin({
// we remove eval and Function for vercel
eval: { define: 'undefined' },
Function: {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-define Function as being fn (to rename it), and inject fn.

@millsp millsp force-pushed the integration/chore/data-proxy-ga-5 branch 2 times, most recently from 58fe700 to 736ce04 Compare June 6, 2022 15:25
}).join('\n')

const schemaAnnotations = buildNFTSchemaAnnotation(engineType, relativeOutdir)
const schemaAnnotations = buildNFTAnnotation('schema.prisma', relativeOutdir)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just shrinking the code here.

@millsp millsp marked this pull request as ready for review June 6, 2022 16:16
@millsp millsp merged commit 0ab97f8 into chore/data-proxy-ga-4 Jun 7, 2022
@millsp millsp deleted the integration/chore/data-proxy-ga-5 branch June 7, 2022 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants