Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan committed Jun 23, 2023
1 parent fc7ef13 commit 5759d0a
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/remix/src/utils/futureFlags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { GLOBAL_OBJ } from '@sentry/utils';

import type { FutureConfig, ServerBuild } from './types';

export type EnhancedGlobal = typeof GLOBAL_OBJ & {
__remixContext?: {
future?: FutureConfig;
};
};

/**
* Get the future flags from the Remix browser context
*
* @returns The future flags
*/
export function getFutureFlagsBrowser(): FutureConfig | undefined {
const window = GLOBAL_OBJ as EnhancedGlobal;

if (!window.__remixContext) {
return;
}

return window.__remixContext.future;
}

/**
* Get the future flags from the Remix server build
*
* @param build The Remix server build
*
* @returns The future flags
*/
export function getFutureFlagsServer(build: ServerBuild): FutureConfig | undefined {
return build.future;
}
29 changes: 29 additions & 0 deletions packages/remix/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,34 @@ import type * as Express from 'express';
import type { Agent } from 'https';
import type { ComponentType } from 'react';

type Dev = {
command?: string;
scheme?: string;
host?: string;
port?: number;
restart?: boolean;
tlsKey?: string;
tlsCert?: string;
};

export interface FutureConfig {
unstable_dev: boolean | Dev;
/** @deprecated Use the `postcss` config option instead */
unstable_postcss: boolean;
/** @deprecated Use the `tailwind` config option instead */
unstable_tailwind: boolean;
v2_errorBoundary: boolean;
v2_headers: boolean;
v2_meta: boolean;
v2_normalizeFormMethod: boolean;
v2_routeConvention: boolean;
}

export interface RemixConfig {
[key: string]: any;
future: FutureConfig;
}

export type RemixRequestState = {
method: string;
redirect: RequestRedirect;
Expand Down Expand Up @@ -133,6 +161,7 @@ export interface ServerBuild {
assets: AssetsManifest;
publicPath?: string;
assetsBuildDirectory?: string;
future?: FutureConfig;
}

export interface HandleDocumentRequestFunction {
Expand Down

0 comments on commit 5759d0a

Please sign in to comment.