Skip to content

Commit

Permalink
feat: deprecate all functions & types exported from magicExports
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Jun 21, 2022
1 parent 556cd2c commit d956a2c
Show file tree
Hide file tree
Showing 7 changed files with 423 additions and 109 deletions.
18 changes: 17 additions & 1 deletion packages/remix-architect/magicExports/remix.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
/* eslint-disable import/no-extraneous-dependencies */

import * as architect from "@remix-run/architect";

const warn = <T extends Function>(fn: T, message: string): T =>
((...args: unknown[]) => {
console.warn(message);

return fn(...args);
}) as unknown as T;

const getDeprecatedMessage = (functionName: string, packageName: string) =>
`All \`remix\` exports are considered deprecated as of v1.3.3. Please import \`${functionName}\` from \`@remix-run/${packageName}\` instead. You can run \`remix migrate --migration replace-remix-imports\` to automatically migrate your code.`;

// Re-export everything from this package that is available in `remix`.

export { createArcTableSessionStorage } from "@remix-run/architect";
/** @deprecated Import `createArcTableSessionStorage` from `@remix-run/architect` instead. */
export const createArcTableSessionStorage = warn(
architect.createArcTableSessionStorage,
getDeprecatedMessage("createArcTableSessionStorage", "architect")
);
18 changes: 17 additions & 1 deletion packages/remix-cloudflare-pages/magicExports/remix.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
import * as cloudflare from "@remix-run/cloudflare";

const warn = <T extends Function>(fn: T, message: string): T =>
((...args: unknown[]) => {
console.warn(message);

return fn(...args);
}) as unknown as T;

const getDeprecatedMessage = (functionName: string, packageName: string) =>
`All \`remix\` exports are considered deprecated as of v1.3.3. Please import \`${functionName}\` from \`@remix-run/${packageName}\` instead. You can run \`remix migrate --migration replace-remix-imports\` to automatically migrate your code.`;

// Re-export everything from this package that is available in `remix`.

export { createCloudflareKVSessionStorage } from "@remix-run/cloudflare";
/** @deprecated Import `createCloudflareKVSessionStorage` from `@remix-run/cloudflare` instead. */
export const createCloudflareKVSessionStorage = warn(
cloudflare.createCloudflareKVSessionStorage,
getDeprecatedMessage("createCloudflareKVSessionStorage", "cloudflare")
);
18 changes: 17 additions & 1 deletion packages/remix-cloudflare-workers/magicExports/remix.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
import * as cloudflare from "@remix-run/cloudflare";

const warn = <T extends Function>(fn: T, message: string): T =>
((...args: unknown[]) => {
console.warn(message);

return fn(...args);
}) as unknown as T;

const getDeprecatedMessage = (functionName: string, packageName: string) =>
`All \`remix\` exports are considered deprecated as of v1.3.3. Please import \`${functionName}\` from \`@remix-run/${packageName}\` instead. You can run \`remix migrate --migration replace-remix-imports\` to automatically migrate your code.`;

// Re-export everything from this package that is available in `remix`.

export { createCloudflareKVSessionStorage } from "@remix-run/cloudflare";
/** @deprecated Import `createCloudflareKVSessionStorage` from `@remix-run/cloudflare` instead. */
export const createCloudflareKVSessionStorage = warn(
cloudflare.createCloudflareKVSessionStorage,
getDeprecatedMessage("createCloudflareKVSessionStorage", "cloudflare")
);
44 changes: 37 additions & 7 deletions packages/remix-cloudflare/magicExports/remix.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
/* eslint-disable import/no-extraneous-dependencies */

import * as cloudflare from "@remix-run/cloudflare";

const warn = <T extends Function>(fn: T, message: string): T =>
((...args: unknown[]) => {
console.warn(message);

return fn(...args);
}) as unknown as T;

const getDeprecatedMessage = (functionName: string, packageName: string) =>
`All \`remix\` exports are considered deprecated as of v1.3.3. Please import \`${functionName}\` from \`@remix-run/${packageName}\` instead. You can run \`remix migrate --migration replace-remix-imports\` to automatically migrate your code.`;

// Re-export everything from this package that is available in `remix`.

export {
createCloudflareKVSessionStorage,
createCookie,
createSessionStorage,
createCookieSessionStorage,
createMemorySessionStorage,
} from "@remix-run/cloudflare";
/** @deprecated Import `createCloudflareKVSessionStorage` from `@remix-run/cloudflare` instead. */
export const createCloudflareKVSessionStorage = warn(
cloudflare.createCloudflareKVSessionStorage,
getDeprecatedMessage("createCloudflareKVSessionStorage", "cloudflare")
);
/** @deprecated Import `createCookie` from `@remix-run/cloudflare` instead. */
export const createCookie = warn(
cloudflare.createCookie,
getDeprecatedMessage("createCookie", "cloudflare")
);
/** @deprecated Import `createSessionStorage` from `@remix-run/cloudflare` instead. */
export const createSessionStorage = warn(
cloudflare.createSessionStorage,
getDeprecatedMessage("createSessionStorage", "cloudflare")
);
/** @deprecated Import `createCookieSessionStorage` from `@remix-run/cloudflare` instead. */
export const createCookieSessionStorage = warn(
cloudflare.createCookieSessionStorage,
getDeprecatedMessage("createCookieSessionStorage", "cloudflare")
);
/** @deprecated Import `createMemorySessionStorage` from `@remix-run/cloudflare` instead. */
export const createMemorySessionStorage = warn(
cloudflare.createMemorySessionStorage,
getDeprecatedMessage("createMemorySessionStorage", "cloudflare")
);
68 changes: 57 additions & 11 deletions packages/remix-node/magicExports/remix.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,62 @@
/* eslint-disable import/no-extraneous-dependencies */

import * as node from "@remix-run/node";
import type * as NodeTypes from "@remix-run/node";

const warn = <T extends Function>(fn: T, message: string): T =>
((...args: unknown[]) => {
console.warn(message);

return fn(...args);
}) as unknown as T;

const getDeprecatedMessage = (functionName: string, packageName: string) =>
`All \`remix\` exports are considered deprecated as of v1.3.3. Please import \`${functionName}\` from \`@remix-run/${packageName}\` instead. You can run \`remix migrate --migration replace-remix-imports\` to automatically migrate your code.`;

// Re-export everything from this package that is available in `remix`.

export {
createCookie,
createSessionStorage,
createCookieSessionStorage,
createMemorySessionStorage,
createFileSessionStorage,
unstable_createFileUploadHandler,
unstable_createMemoryUploadHandler,
unstable_parseMultipartFormData,
} from "@remix-run/node";
/** @deprecated Import `createCookie` from `@remix-run/node` instead. */
export const createCookie = warn(
node.createCookie,
getDeprecatedMessage("createCookie", "node")
);
/** @deprecated Import `createSessionStorage` from `@remix-run/node` instead. */
export const createSessionStorage = warn(
node.createSessionStorage,
getDeprecatedMessage("createSessionStorage", "node")
);
/** @deprecated Import `createCookieSessionStorage` from `@remix-run/node` instead. */
export const createCookieSessionStorage = warn(
node.createCookieSessionStorage,
getDeprecatedMessage("createCookieSessionStorage", "node")
);
/** @deprecated Import `createMemorySessionStorage` from `@remix-run/node` instead. */
export const createMemorySessionStorage = warn(
node.createMemorySessionStorage,
getDeprecatedMessage("createMemorySessionStorage", "node")
);
/** @deprecated Import `createFileSessionStorage` from `@remix-run/node` instead. */
export const createFileSessionStorage = warn(
node.createFileSessionStorage,
getDeprecatedMessage("createFileSessionStorage", "node")
);
/** @deprecated Import `unstable_createFileUploadHandler` from `@remix-run/node` instead. */
export const unstable_createFileUploadHandler = warn(
node.unstable_createFileUploadHandler,
getDeprecatedMessage("unstable_createFileUploadHandler", "node")
);
/** @deprecated Import `unstable_createMemoryUploadHandler` from `@remix-run/node` instead. */
export const unstable_createMemoryUploadHandler = warn(
node.unstable_createMemoryUploadHandler,
getDeprecatedMessage("unstable_createMemoryUploadHandler", "node")
);
/** @deprecated Import `unstable_parseMultipartFormData` from `@remix-run/node` instead. */
export const unstable_parseMultipartFormData = warn(
node.unstable_parseMultipartFormData,
getDeprecatedMessage("unstable_parseMultipartFormData", "node")
);

export type { UploadHandler, UploadHandlerPart } from "@remix-run/node";
/** @deprecated Import type `UploadHandler` from `@remix-run/node` instead. */
export type UploadHandler = NodeTypes.UploadHandler;
/** @deprecated Import type `UploadHandlerArgs` from `@remix-run/node` instead. */
export type UploadHandlerPart = NodeTypes.UploadHandlerPart;
Loading

0 comments on commit d956a2c

Please sign in to comment.