-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement route scoping solution (#836)
* implement route scoping solution * remove unused variable * remove appServerActions feature from app14.0.0 fixture * avoid string concatenation for warn function imports
- Loading branch information
1 parent
0a07f34
commit 2115b9e
Showing
7 changed files
with
305 additions
and
28 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
'@cloudflare/next-on-pages': patch | ||
--- | ||
|
||
fix: implement route specific global scoping strategy | ||
|
||
currently routes all share the same global scope, this can be problematic and cause | ||
race conditions and failures | ||
|
||
One example of this is the following code that is present in route function files: | ||
|
||
```ts | ||
self.webpackChunk_N_E = ... | ||
``` | ||
|
||
and | ||
|
||
```ts | ||
self.webpackChunk_N_E.push(...) | ||
``` | ||
|
||
this indicates that an in-memory global collection of the webpack chunks is shared by all routes, | ||
this combined with the fact that chunks can have their own module state this can easily cause routes to conflict with each other at runtime. | ||
|
||
So, in order to solve the above issue, all route functions are wrapped in a function which accepts as parameters, thus overrides, the `self`, `globalThis` and `global` symbols. The symbols | ||
will be resolved with proxies that redirect setters to route-scoped in-memory maps and | ||
getters to the above mentioned map's values and fallback to the original symbol values otherwise | ||
(i.e. `globalThis` will be overridden by a proxy that, when setting values, sets them in a separate | ||
location and, when getting values, gets them from said location if present there or from the real | ||
`globalThis` otherwise) |
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
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
Oops, something went wrong.