Skip to content

Commit

Permalink
Revert "Add support for Images binding (#7945)" (#7988)
Browse files Browse the repository at this point in the history
* Revert "Add support for Images binding (#7945)"

This reverts commit d758215.

* add changeset
  • Loading branch information
edmundhung authored Jan 31, 2025
1 parent ff0d9cd commit 444a630
Show file tree
Hide file tree
Showing 30 changed files with 11 additions and 782 deletions.
7 changes: 7 additions & 0 deletions .changeset/gorgeous-geckos-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

Fix #7985.

This reverts the changes on #7945 that caused compatibility issues with Node 16 due to the introduction of `sharp`.
34 changes: 0 additions & 34 deletions packages/wrangler/e2e/dev-with-resources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,40 +720,6 @@ describe.sequential.each(RUNTIMES)("Bindings: $flags", ({ runtime, flags }) => {
await expect(res.text()).resolves.toBe("env.WORKFLOW is available");
});

describe.sequential.each([
{ imagesMode: "remote", extraFlags: "" },
{ imagesMode: "local", extraFlags: "--experimental-images-local-mode" },
] as const)("Images Binding Mode: $imagesMode", async ({ extraFlags }) => {
it("exposes Images bindings", async () => {
await helper.seed({
"wrangler.toml": dedent`
name = "my-images-demo"
main = "src/index.ts"
compatibility_date = "2024-12-27"
[images]
binding = "IMAGES"
`,
"src/index.ts": dedent`
export default {
async fetch(request, env, ctx) {
if (env.IMAGES === undefined) {
return new Response("env.IMAGES is undefined");
}
return new Response("env.IMAGES is available");
}
}
`,
});
const worker = helper.runLongLived(`wrangler dev ${flags} ${extraFlags}`);
const { url } = await worker.waitForReady();
const res = await fetch(url);

await expect(res.text()).resolves.toBe("env.IMAGES is available");
});
});

// TODO(soon): implement E2E tests for other bindings
it.skipIf(isLocal).todo("exposes send email bindings");
it.skipIf(isLocal).todo("exposes browser bindings");
Expand Down
1 change: 0 additions & 1 deletion packages/wrangler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
"esbuild": "0.17.19",
"miniflare": "workspace:*",
"path-to-regexp": "6.3.0",
"sharp": "^0.33.5",
"unenv": "2.0.0-rc.1",
"workerd": "1.20250129.0"
},
Expand Down
3 changes: 0 additions & 3 deletions packages/wrangler/scripts/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ export const EXTERNAL_DEPENDENCIES = [

// workerd contains a native binary, so must be external. Wrangler depends on a pinned version.
"workerd",

// sharp contains native libraries
"sharp",
];

const pathToPackageJson = path.resolve(__dirname, "..", "package.json");
Expand Down
63 changes: 0 additions & 63 deletions packages/wrangler/src/__tests__/config/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2302,69 +2302,6 @@ describe("normalizeAndValidateConfig()", () => {
});
});

// Images
describe("[images]", () => {
it("should error if images is an array", () => {
const { diagnostics } = normalizeAndValidateConfig(
{ images: [] } as unknown as RawConfig,
undefined,
undefined,
{ env: undefined }
);

expect(diagnostics.hasWarnings()).toBe(false);
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- The field \\"images\\" should be an object but got []."
`);
});

it("should error if images is a string", () => {
const { diagnostics } = normalizeAndValidateConfig(
{ images: "BAD" } as unknown as RawConfig,
undefined,
undefined,
{ env: undefined }
);

expect(diagnostics.hasWarnings()).toBe(false);
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- The field \\"images\\" should be an object but got \\"BAD\\"."
`);
});

it("should error if images is a number", () => {
const { diagnostics } = normalizeAndValidateConfig(
{ images: 999 } as unknown as RawConfig,
undefined,
undefined,
{ env: undefined }
);

expect(diagnostics.hasWarnings()).toBe(false);
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- The field \\"images\\" should be an object but got 999."
`);
});

it("should error if ai is null", () => {
const { diagnostics } = normalizeAndValidateConfig(
{ images: null } as unknown as RawConfig,
undefined,
undefined,
{ env: undefined }
);

expect(diagnostics.hasWarnings()).toBe(false);
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- The field \\"images\\" should be an object but got null."
`);
});
});

// Worker Version Metadata
describe("[version_metadata]", () => {
it("should error if version_metadata is an array", () => {
Expand Down
31 changes: 0 additions & 31 deletions packages/wrangler/src/__tests__/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11903,37 +11903,6 @@ export default{
});
});

describe("images", () => {
it("should upload images bindings", async () => {
writeWranglerConfig({
images: { binding: "IMAGES_BIND" },
});
await fs.promises.writeFile("index.js", `export default {};`);
mockSubDomainRequest();
mockUploadWorkerRequest({
expectedBindings: [
{
type: "images",
name: "IMAGES_BIND",
},
],
});

await runWrangler("deploy index.js");
expect(std.out).toMatchInlineSnapshot(`
"Total Upload: xx KiB / gzip: xx KiB
Worker Startup Time: 100 ms
Your worker has access to the following bindings:
- Images:
- Name: IMAGES_BIND
Uploaded test-name (TIMINGS)
Deployed test-name triggers (TIMINGS)
https://test-name.test-sub-domain.workers.dev
Current Version ID: Galaxy-Class"
`);
});
});

describe("python", () => {
it("should upload python module defined in wrangler.toml", async () => {
writeWranglerConfig({
Expand Down
3 changes: 1 addition & 2 deletions packages/wrangler/src/__tests__/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1399,8 +1399,7 @@ describe.sequential("wrangler dev", () => {
--test-scheduled Test scheduled events by visiting /__scheduled in browser [boolean] [default: false]
--log-level Specify logging level [choices: \\"debug\\", \\"info\\", \\"log\\", \\"warn\\", \\"error\\", \\"none\\"] [default: \\"log\\"]
--show-interactive-dev-session Show interactive dev session (defaults to true if the terminal supports interactivity) [boolean]
--experimental-vectorize-bind-to-prod Bind to production Vectorize indexes in local development mode [boolean] [default: false]
--experimental-images-local-mode Use a local lower-fidelity implementation of the Images binding [boolean] [default: false]",
--experimental-vectorize-bind-to-prod Bind to production Vectorize indexes in local development mode [boolean] [default: false]",
"warn": "",
}
`);
Expand Down
3 changes: 1 addition & 2 deletions packages/wrangler/src/__tests__/pages/pages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ describe("pages", () => {
--persist-to Specify directory to use for local persistence (defaults to .wrangler/state) [string]
--log-level Specify logging level [choices: \\"debug\\", \\"info\\", \\"log\\", \\"warn\\", \\"error\\", \\"none\\"]
--show-interactive-dev-session Show interactive dev session (defaults to true if the terminal supports interactivity) [boolean]
--experimental-vectorize-bind-to-prod Bind to production Vectorize indexes in local development mode [boolean] [default: false]
--experimental-images-local-mode Use a local lower-fidelity implementation of the Images binding [boolean] [default: false]"
--experimental-vectorize-bind-to-prod Bind to production Vectorize indexes in local development mode [boolean] [default: false]"
`);
});

Expand Down
3 changes: 0 additions & 3 deletions packages/wrangler/src/__tests__/type-generation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ const bindingsConfigMock: Omit<
ai: {
binding: "AI_BINDING",
},
images: {
binding: "IMAGES_BINDING",
},
version_metadata: {
binding: "VERSION_METADATA_BINDING",
},
Expand Down
3 changes: 0 additions & 3 deletions packages/wrangler/src/api/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export interface Unstable_DevOptions {
devEnv?: boolean;
fileBasedRegistry?: boolean;
vectorizeBindToProd?: boolean;
imagesLocalMode?: boolean;
enableIpc?: boolean;
};
}
Expand Down Expand Up @@ -127,7 +126,6 @@ export async function unstable_dev(
testMode,
testScheduled,
vectorizeBindToProd,
imagesLocalMode,
// 2. options for alpha/beta products/libs
d1Databases,
enablePagesAssetsServiceBinding,
Expand Down Expand Up @@ -220,7 +218,6 @@ export async function unstable_dev(
port: options?.port ?? 0,
experimentalProvision: undefined,
experimentalVectorizeBindToProd: vectorizeBindToProd ?? false,
experimentalImagesLocalMode: imagesLocalMode ?? false,
enableIpc: options?.experimental?.enableIpc,
};

Expand Down
2 changes: 0 additions & 2 deletions packages/wrangler/src/api/integrations/platform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ async function getMiniflareOptionsFromConfig(
services: rawConfig.services,
serviceBindings: {},
migrations: rawConfig.migrations,
imagesLocalMode: false,
});

const persistOptions = getMiniflarePersistOptions(options.persist);
Expand Down Expand Up @@ -273,7 +272,6 @@ export function unstable_getMiniflareWorkerOptions(
services: [],
serviceBindings: {},
migrations: config.migrations,
imagesLocalMode: false,
});

// This function is currently only exported for the Workers Vitest pool.
Expand Down
2 changes: 0 additions & 2 deletions packages/wrangler/src/api/startDevWorker/ConfigController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ async function resolveDevConfig(
registry: input.dev?.registry,
bindVectorizeToProd: input.dev?.bindVectorizeToProd ?? false,
multiworkerPrimary: input.dev?.multiworkerPrimary,
imagesLocalMode: input.dev?.imagesLocalMode ?? false,
} satisfies StartDevWorkerOptions["dev"];
}

Expand Down Expand Up @@ -170,7 +169,6 @@ async function resolveBindings(
{
registry: input.dev?.registry,
local: !input.dev?.remote,
imagesLocalMode: input.dev?.imagesLocalMode,
name: config.name,
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export async function convertToConfigBundle(
services: bindings.services,
serviceBindings: fetchers,
bindVectorizeToProd: event.config.dev?.bindVectorizeToProd ?? false,
imagesLocalMode: event.config.dev?.imagesLocalMode ?? false,
testScheduled: !!event.config.dev.testScheduled,
};
}
Expand Down
4 changes: 0 additions & 4 deletions packages/wrangler/src/api/startDevWorker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ export interface StartDevWorkerInput {
/** Whether to use Vectorize mixed mode -- the worker is run locally but accesses to Vectorize are made remotely */
bindVectorizeToProd?: boolean;

/** Whether to use Images local mode -- this is lower fidelity, but doesn't require network access */
imagesLocalMode?: boolean;

/** Treat this as the primary worker in a multiworker setup (i.e. the first Worker in Miniflare's options) */
multiworkerPrimary?: boolean;
};
Expand Down Expand Up @@ -244,7 +241,6 @@ export type Binding =
| { type: "text_blob"; source: File }
| { type: "browser" }
| { type: "ai" }
| { type: "images" }
| { type: "version_metadata" }
| { type: "data_blob"; source: BinaryFile }
| ({ type: "durable_object_namespace" } & NameOmit<CfDurableObject>)
Expand Down
8 changes: 0 additions & 8 deletions packages/wrangler/src/api/startDevWorker/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,6 @@ export function convertCfWorkerInitBindingstoBindings(
output[binding] = { type: "ai", ...x };
break;
}
case "images": {
const { binding, ...x } = info;
output[binding] = { type: "images", ...x };
break;
}
case "version_metadata": {
const { binding, ...x } = info;
output[binding] = { type: "version_metadata", ...x };
Expand Down Expand Up @@ -270,7 +265,6 @@ export async function convertBindingsToCfWorkerInitBindings(
text_blobs: undefined,
browser: undefined,
ai: undefined,
images: undefined,
version_metadata: undefined,
data_blobs: undefined,
durable_objects: undefined,
Expand Down Expand Up @@ -326,8 +320,6 @@ export async function convertBindingsToCfWorkerInitBindings(
bindings.browser = { binding: name };
} else if (binding.type === "ai") {
bindings.ai = { binding: name };
} else if (binding.type === "images") {
bindings.images = { binding: name };
} else if (binding.type === "version_metadata") {
bindings.version_metadata = { binding: name };
} else if (binding.type === "durable_object_namespace") {
Expand Down
1 change: 0 additions & 1 deletion packages/wrangler/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ export const defaultWranglerConfig: Config = {
services: [],
analytics_engine_datasets: [],
ai: undefined,
images: undefined,
version_metadata: undefined,

/*====================================================*/
Expand Down
15 changes: 0 additions & 15 deletions packages/wrangler/src/config/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,21 +745,6 @@ export interface EnvironmentNonInheritable {
}
| undefined;

/**
* Binding to Cloudflare Images
*
* NOTE: This field is not automatically inherited from the top level environment,
* and so must be specified in every named environment.
*
* @default {}
* @nonInheritable
*/
images:
| {
binding: string;
}
| undefined;

/**
* Binding to the Worker Version's metadata
*/
Expand Down
14 changes: 2 additions & 12 deletions packages/wrangler/src/config/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ function normalizeAndValidateEnvironment(
rawEnv,
envName,
"browser",
validateNamedSimpleBinding(envName),
validateBrowserBinding(envName),
undefined
),
ai: notInheritable(
Expand All @@ -1543,16 +1543,6 @@ function normalizeAndValidateEnvironment(
validateAIBinding(envName),
undefined
),
images: notInheritable(
diagnostics,
topLevelEnv,
rawConfig,
rawEnv,
envName,
"images",
validateNamedSimpleBinding(envName),
undefined
),
pipelines: notInheritable(
diagnostics,
topLevelEnv,
Expand Down Expand Up @@ -2258,7 +2248,7 @@ const validateAssetsConfig: ValidatorFn = (diagnostics, field, value) => {
return isValid;
};

const validateNamedSimpleBinding =
const validateBrowserBinding =
(envName: string): ValidatorFn =>
(diagnostics, field, value, config) => {
const fieldPath =
Expand Down
1 change: 0 additions & 1 deletion packages/wrangler/src/deployment-bundle/bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export function getBindings(
wasm_modules: options?.pages ? undefined : config?.wasm_modules,
browser: config?.browser,
ai: config?.ai,
images: config?.images,
version_metadata: config?.version_metadata,
text_blobs: options?.pages ? undefined : config?.text_blobs,
data_blobs: options?.pages ? undefined : config?.data_blobs,
Expand Down
Loading

0 comments on commit 444a630

Please sign in to comment.