diff --git a/.changeset/breezy-dancers-lie.md b/.changeset/breezy-dancers-lie.md new file mode 100644 index 00000000000..a836b093213 --- /dev/null +++ b/.changeset/breezy-dancers-lie.md @@ -0,0 +1,5 @@ +--- +"@remix-run/cloudflare": minor +--- + +Rename `createCloudflareKVSessionStorage` to `createWorkersKVSessionStorage` diff --git a/integration/cf-compiler-test.ts b/integration/cf-compiler-test.ts index a1d058e981a..10ada83fa71 100644 --- a/integration/cf-compiler-test.ts +++ b/integration/cf-compiler-test.ts @@ -155,6 +155,7 @@ test.describe("cloudflare compiler", () => { "createMemorySessionStorage", "createSessionStorage", "createSession", + "createCloudflareKVSessionStorage", "isCookie", "isSession", "json", diff --git a/packages/remix-cloudflare/index.ts b/packages/remix-cloudflare/index.ts index c78a1b1fbec..ee6d76c2fb8 100644 --- a/packages/remix-cloudflare/index.ts +++ b/packages/remix-cloudflare/index.ts @@ -1,10 +1,22 @@ import "./globals"; -export { +import {createWorkersKVSessionStorage} from './sessions/workersKVStorage'; + +const warn = (fn: T, message: string): T => + ((...args: unknown[]) => { + console.warn(message); + + return fn(...args); + }) as unknown as T; + + +/** @deprecated Use `createWorkersKVSessionStorage` instead. */ +export const createCloudflareKVSessionStorage = warn( createWorkersKVSessionStorage, - // TODO: Deprecate createCloudflareKVSessionStorage - createWorkersKVSessionStorage as createCloudflareKVSessionStorage, -} from "./sessions/workersKVStorage"; + "`createCloudflareKVSessionStorage` is deprecated. Please use `createWorkersKVSessionStorage` instead.", +); + +export { createWorkersKVSessionStorage } from "./sessions/workersKVStorage"; export { createCookie, diff --git a/packages/remix-dev/codemod/replace-remix-magic-imports/utils/export.ts b/packages/remix-dev/codemod/replace-remix-magic-imports/utils/export.ts index b078e2065ec..4c7e49f912b 100644 --- a/packages/remix-dev/codemod/replace-remix-magic-imports/utils/export.ts +++ b/packages/remix-dev/codemod/replace-remix-magic-imports/utils/export.ts @@ -100,7 +100,10 @@ const defaultRuntimeExports: ExportNames = { const exportNamesByRuntime: Record> = { cloudflare: { - value: ["createCloudflareKVSessionStorage"], + value: [ + "createCloudflareKVSessionStorage", + "createWorkersKVSessionStorage", + ], }, node: { type: ["HeadersInit", "RequestInfo", "RequestInit", "ResponseInit"], diff --git a/packages/remix-eslint-config/rules/packageExports.js b/packages/remix-eslint-config/rules/packageExports.js index 690f6b425d4..8ef34ecb8ed 100644 --- a/packages/remix-eslint-config/rules/packageExports.js +++ b/packages/remix-eslint-config/rules/packageExports.js @@ -66,7 +66,7 @@ const architectSpecificExports = { }; const cloudflareSpecificExports = { - value: ["createCloudflareKVSessionStorage"], + value: ["createCloudflareKVSessionStorage", "createWorkersKVSessionStorage"], type: [], };