-
Notifications
You must be signed in to change notification settings - Fork 126
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
implement route scoping solution #836
Conversation
🦋 Changeset detectedLatest commit: ca1ab06 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🧪 Prereleases are available for testing 🧪 @cloudflare/next-on-pagesYou can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/10214693462/npm-package-next-on-pages-836 @cloudflare/eslint-plugin-next-on-pagesYou can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/10214693462/npm-package-eslint-plugin-next-on-pages-836 |
88c1452
to
e11f952
Compare
b122cc1
to
60158e1
Compare
56d65f2
to
03154df
Compare
packages/next-on-pages/src/buildApplication/processVercelFunctions/dedupeEdgeFunctions.ts
Outdated
Show resolved
Hide resolved
packages/next-on-pages/src/buildApplication/processVercelFunctions/dedupeEdgeFunctions.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done a first pass of review with my very limited knowedlge.
I'll do a second pass of review tomorrow.
One thing that would be nice is a high level description of what the PR do - 1 or 2 sentences to give context, describes the problem that is solved (the content is currently empty).
packages/next-on-pages/src/buildApplication/processVercelFunctions/dedupeEdgeFunctions.ts
Outdated
Show resolved
Hide resolved
packages/next-on-pages/src/buildApplication/processVercelFunctions/dedupeEdgeFunctions.ts
Outdated
Show resolved
Hide resolved
packages/next-on-pages/src/buildApplication/processVercelFunctions/dedupeEdgeFunctions.ts
Outdated
Show resolved
Hide resolved
03154df
to
ef3df46
Compare
update regex
use a single return statement instead of updating fileContents
add missing semicolon
avoid unnecessary spreading
7842b1c
to
c1f5650
Compare
generalize regex
improve buildFunctionFile code and make it more clear
add entries()
packages/next-on-pages/src/buildApplication/processVercelFunctions/dedupeEdgeFunctions.ts
Outdated
Show resolved
Hide resolved
avoid string concatenation for functionImports
fix incorrect entries call
avoid introducing named esm exports for then regex-replace them
introduce namedExportsObjectName to make solution less ugly/brittle
fix wrong namedExportsObjectName name
update namedExportsObjectName name (for consistency)
improve named exports solution a bit further
make sure solution works with older versions of the Vercel CLI
8824942
to
b37bce2
Compare
packages/next-on-pages/src/buildApplication/processVercelFunctions/dedupeEdgeFunctions.ts
Outdated
Show resolved
Hide resolved
packages/next-on-pages/src/buildApplication/processVercelFunctions/dedupeEdgeFunctions.ts
Outdated
Show resolved
Hide resolved
use more consistent param names
join using newlines instead of semicolons
currently routes all share the same global scope, this can be problematic and cause race conditions and failures, like the one presented in #805 that happens when various requests are handled in parallel (and the global scope ends up in an invalid state).
So, this PR solves the issue by wrapping each js file (functions and chunks included) in functions that override the
self
,globalThis
andglobal
symbols with proxies that try to make (as reasonably well as possible) each route's global scope as isolated as possible.fixes #805