Skip to content

Commit 09c5626

Browse files
committed
WIP
1 parent e583fe9 commit 09c5626

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { GLOBAL_OBJ } from '@sentry/utils';
2+
3+
import type { FutureConfig, ServerBuild } from './types';
4+
5+
export type EnhancedGlobal = typeof GLOBAL_OBJ & {
6+
__remixContext?: {
7+
future?: FutureConfig;
8+
};
9+
};
10+
11+
/**
12+
* Get the future flags from the Remix browser context
13+
*
14+
* @returns The future flags
15+
*/
16+
export function getFutureFlagsBrowser(): FutureConfig | undefined {
17+
const window = GLOBAL_OBJ as EnhancedGlobal;
18+
19+
if (!window.__remixContext) {
20+
return;
21+
}
22+
23+
return window.__remixContext.future;
24+
}
25+
26+
/**
27+
* Get the future flags from the Remix server build
28+
*
29+
* @param build The Remix server build
30+
*
31+
* @returns The future flags
32+
*/
33+
export function getFutureFlagsServer(build: ServerBuild): FutureConfig | undefined {
34+
return build.future;
35+
}

packages/remix/src/utils/types.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,34 @@ import type * as Express from 'express';
1414
import type { Agent } from 'https';
1515
import type { ComponentType } from 'react';
1616

17+
type Dev = {
18+
command?: string;
19+
scheme?: string;
20+
host?: string;
21+
port?: number;
22+
restart?: boolean;
23+
tlsKey?: string;
24+
tlsCert?: string;
25+
};
26+
27+
export interface FutureConfig {
28+
unstable_dev: boolean | Dev;
29+
/** @deprecated Use the `postcss` config option instead */
30+
unstable_postcss: boolean;
31+
/** @deprecated Use the `tailwind` config option instead */
32+
unstable_tailwind: boolean;
33+
v2_errorBoundary: boolean;
34+
v2_headers: boolean;
35+
v2_meta: boolean;
36+
v2_normalizeFormMethod: boolean;
37+
v2_routeConvention: boolean;
38+
}
39+
40+
export interface RemixConfig {
41+
[key: string]: any;
42+
future: FutureConfig;
43+
}
44+
1745
export type RemixRequestState = {
1846
method: string;
1947
redirect: RequestRedirect;
@@ -133,6 +161,7 @@ export interface ServerBuild {
133161
assets: AssetsManifest;
134162
publicPath?: string;
135163
assetsBuildDirectory?: string;
164+
future?: FutureConfig;
136165
}
137166

138167
export interface HandleDocumentRequestFunction {

0 commit comments

Comments
 (0)