Skip to content

Commit

Permalink
feat(remix-cloudflare): deprecate createCloudflareKVSessionStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Dec 21, 2022
1 parent ec947fb commit 7bdae5e
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-dancers-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/cloudflare": minor
---

Rename `createCloudflareKVSessionStorage` to `createWorkersKVSessionStorage`
2 changes: 1 addition & 1 deletion docs/api/remix.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ title: Remix Packages

[Moved →][moved-59]

### `createCloudflareKVSessionStorage` (cloudflare-workers)
### `createWorkersKVSessionStorage` (Cloudflare Workers)

[Moved →][moved-60]

Expand Down
1 change: 1 addition & 0 deletions integration/cf-compiler-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ test.describe("cloudflare compiler", () => {
"createMemorySessionStorage",
"createSessionStorage",
"createSession",
"createWorkersKVSessionStorage",
"isCookie",
"isSession",
"json",
Expand Down
20 changes: 16 additions & 4 deletions packages/remix-cloudflare/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import "./globals";

export {
import {createWorkersKVSessionStorage} from './sessions/workersKVStorage';

const warn = <T extends Function>(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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ it("replaces multi-kind, multi-specifier imports", async () => {

it("replaces runtime-specific and adapter-specific imports", async () => {
let code = [
'import { json, createCloudflareKVSessionStorage, createRequestHandler, createPagesFunctionHandler, Form } from "remix"',
'import { json, createWorkersKVSessionStorage, createRequestHandler, createPagesFunctionHandler, Form } from "remix"',
'import type { ActionFunction, GetLoadContextFunction, createPagesFunctionHandlerParams, LinkProps } from "remix"',
].join("\n");
let transform = replaceRemixMagicImports({
Expand All @@ -71,7 +71,7 @@ it("replaces runtime-specific and adapter-specific imports", async () => {
let result = eol.normalize(transform(code, "fake.tsx"));
expect(result).toBe(
[
'import { type ActionFunction, createCloudflareKVSessionStorage, json } from "@remix-run/cloudflare";',
'import { type ActionFunction, createWorkersKVSessionStorage, json } from "@remix-run/cloudflare";',
"", // recast adds a newline here https://github.com/benjamn/recast/issues/39
"import {",
" type GetLoadContextFunction,",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ const defaultRuntimeExports: ExportNames = {

const exportNamesByRuntime: Record<Runtime, Partial<ExportNames>> = {
cloudflare: {
value: ["createCloudflareKVSessionStorage"],
value: [
"createCloudflareKVSessionStorage",
"createWorkersKVSessionStorage",
],
},
node: {
type: ["HeadersInit", "RequestInfo", "RequestInit", "ResponseInit"],
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-eslint-config/rules/packageExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const architectSpecificExports = {
};

const cloudflareSpecificExports = {
value: ["createCloudflareKVSessionStorage"],
value: ["createCloudflareKVSessionStorage", "createWorkersKVSessionStorage"],
type: [],
};

Expand Down

0 comments on commit 7bdae5e

Please sign in to comment.