-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rename ALS instances to prevent bad auto imports (#73480)
this is a little quality-of-life improvement, with no behavioral changes. it's slightly silly though. for bundling reasons, our ALSes should only ever be imported from `some-async-storage.external`, not `some-async-storage-instance`. unfortunately editor autocomplete doesn't care about that, and always suggests `-instance` first. we can solve this by renaming the undesireable one from `someAsyncStorage` to `someAsyncStorageInstace`, which makes it rank lower in the autocomplete suggestions, so the top suggestion becomes the correct one. before the rename: <img width="617" alt="Screenshot 2024-12-03 at 17 53 24" src="https://github.com/user-attachments/assets/750f653a-f108-4fbf-9da5-4825dac6389d"> after the rename: <img width="587" alt="Screenshot 2024-12-03 at 17 52 45" src="https://github.com/user-attachments/assets/fa016050-9df3-44fb-b0c1-2821f84696dc"> ### Alternatives considered marking the instance with `/** @ignore */` doesn't work, because JSDoc comments propagate to reexports, so it hides *both* from autocomplete, which sucks.
- Loading branch information
1 parent
e5336c2
commit 1f44f13
Showing
7 changed files
with
15 additions
and
13 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
packages/next/src/server/app-render/action-async-storage-instance.ts
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,4 +1,5 @@ | ||
import type { ActionAsyncStorage } from './action-async-storage.external' | ||
import { createAsyncLocalStorage } from './async-local-storage' | ||
|
||
export const actionAsyncStorage: ActionAsyncStorage = createAsyncLocalStorage() | ||
export const actionAsyncStorageInstance: ActionAsyncStorage = | ||
createAsyncLocalStorage() |
4 changes: 2 additions & 2 deletions
4
packages/next/src/server/app-render/action-async-storage.external.ts
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,12 +1,12 @@ | ||
import type { AsyncLocalStorage } from 'async_hooks' | ||
|
||
// Share the instance module in the next-shared layer | ||
import { actionAsyncStorage } from './action-async-storage-instance' with { 'turbopack-transition': 'next-shared' } | ||
import { actionAsyncStorageInstance } from './action-async-storage-instance' with { 'turbopack-transition': 'next-shared' } | ||
export interface ActionStore { | ||
readonly isAction?: boolean | ||
readonly isAppRoute?: boolean | ||
} | ||
|
||
export type ActionAsyncStorage = AsyncLocalStorage<ActionStore> | ||
|
||
export { actionAsyncStorage } | ||
export { actionAsyncStorageInstance as actionAsyncStorage } |
3 changes: 2 additions & 1 deletion
3
packages/next/src/server/app-render/work-async-storage-instance.ts
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,4 +1,5 @@ | ||
import type { WorkAsyncStorage } from './work-async-storage.external' | ||
import { createAsyncLocalStorage } from './async-local-storage' | ||
|
||
export const workAsyncStorage: WorkAsyncStorage = createAsyncLocalStorage() | ||
export const workAsyncStorageInstance: WorkAsyncStorage = | ||
createAsyncLocalStorage() |
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
2 changes: 1 addition & 1 deletion
2
packages/next/src/server/app-render/work-unit-async-storage-instance.ts
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,5 +1,5 @@ | ||
import { createAsyncLocalStorage } from './async-local-storage' | ||
import type { WorkUnitAsyncStorage } from './work-unit-async-storage.external' | ||
|
||
export const workUnitAsyncStorage: WorkUnitAsyncStorage = | ||
export const workUnitAsyncStorageInstance: WorkUnitAsyncStorage = | ||
createAsyncLocalStorage() |
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