Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported input '[object Object]' of type object when also providing options of type object #263

Open
dmachaj opened this issue Dec 23, 2024 · 0 comments

Comments

@dmachaj
Copy link

dmachaj commented Dec 23, 2024

I'm trying to add eleventy-img to an existing project to handle some image sizing tasks. The project works fine prior to this, including CI builds via GitHub Actions. However, simply including this plugin breaks the build so that I cannot produce my site. This break occurs regardless of whether I specify options or not (options copied from https://www.11ty.dev/docs/plugins/image/#eleventy-transform).

Operating System: Windows 11 23H2 (22631.4602)
Node version: node-v22.12.0-win-x64

package.json

{
  "name": "11ty",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "npx @11ty/eleventy --config=sample/.eleventy.js",
    "serve": "npx @11ty/eleventy --config=sample/.eleventy.js --serve"
  },
  "keywords": [],
  "author": "username",
  "license": "UNLICENSED",
  "private": true,
  "devDependencies": {
    "@11ty/eleventy": "^3.0.0",
    "@11ty/eleventy-img": "^5.0.0",
    "@11ty/eleventy-plugin-rss": "^2.0.2"
  },
  "dependencies": {
    "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
    "@fontsource/eb-garamond": "^5.1.1",
    "@fontsource/work-sans": "^5.1.0",
    "photoswipe": "^5.4.4"
  }
}

sample/.eleventy.js

const imagePlugin = require("@11ty/eleventy-img");

module.exports = function (eleventyConfig) {
  eleventyConfig.setInputDirectory("sample");
  eleventyConfig.setOutputDirectory("sample/_site");

  // also breaks just as much with this line only
  // eleventyConfig.addPlugin(imagePlugin);

  eleventyConfig.addPlugin(imagePlugin, {
    // which file extensions to process
    extensions: "html",

    // Add any other Image utility options here:

    // optional, output image formats
    formats: ["webp", "jpeg"],
    // formats: ["auto"],

    // optional, output image widths
    widths: ["auto", "400"],

    // optional, attributes assigned on <img> override these values.
    defaultAttributes: {
      loading: "lazy",
      decoding: "async",
      sizes: "auto",
    },
  });
};

Error output:

eleventy-sample>npm run build

> [email protected] build
> npx @11ty/eleventy --config=sample/.eleventy.js

[11ty] Eleventy Error (CLI):
[11ty] 1. Error processing the `queueImage` plugin (via EleventyPluginError)
[11ty] 2. Unsupported input '[object Object]' of type object when also providing options of type object
[11ty]
[11ty] Original error stack trace: Error: Unsupported input '[object Object]' of type object when also providing options of type object
[11ty]     at Sharp._createInputDescriptor (C:\Users\username\AppData\Local\Temp\eleventy-sample\node_modules\sharp\lib\input.js:75:11)
[11ty]     at new Sharp (C:\Users\username\AppData\Local\Temp\eleventy-sample\node_modules\sharp\lib\constructor.js:361:29)
[11ty]     at Sharp (C:\Users\username\AppData\Local\Temp\eleventy-sample\node_modules\sharp\lib\constructor.js:178:12)
[11ty]     at Image.resize (C:\Users\username\AppData\Local\Temp\eleventy-sample\node_modules\@11ty\eleventy-img\img.js:539:22)
[11ty]     at C:\Users\username\AppData\Local\Temp\eleventy-sample\node_modules\@11ty\eleventy-img\img.js:870:16
[11ty]     at async run (C:\Users\username\AppData\Local\Temp\eleventy-sample\node_modules\p-queue\dist\index.js:163:29)
(node:30036) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

I tried manually modifying eleventy-img\img.js:539 to call console.log with the input that is being resized. Sure enough it is not an image it is a big JSON blob containing the entire eleventy configuration for this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant