Skip to content

Vue Image Embedding Fails in .vue Files with @parcel/[email protected] #10124

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

Open
TobiasSchikora opened this issue Mar 25, 2025 · 4 comments
Open

Comments

@TobiasSchikora
Copy link

TobiasSchikora commented Mar 25, 2025

🐛 bug report

When using @parcel/transformer-vue in versions later than 2.13.3, images referenced in .vue files are rendered as [object Object] in the HTML output. This issue does not occur when images are loaded outside Vue (e.g., directly in index.html).

Steps to Reproduce

  • Use @parcel/transformer-vue v2.14.0 or higher.
  • Reference an image asset in a .vue file (e.g., <img src="./image.png">).
  • Build the project.

Workaround

Pin dependencies to v2.13.3.

🎛 Configuration

{
  "parcel": "2.14.3",
  "@parcel/transformer-vue": "2.14.3",
  "@parcel/resolver-glob": "2.14.3"
}

🤔 Expected Behavior

Image paths are correctly resolved and rendered in the HTML.

😯 Current Behavior

[object Object] is output instead of the image path.

🔦 Context

May be related to changes in asset handling or serialization in newer versions of the Vue transformer.

@TobiasSchikora TobiasSchikora changed the title Vue Image Embedding Fails in .vue Files with @parcel/transformer-vue v2.13.4+ Vue Image Embedding Fails in .vue Files with @parcel/transformer-vue v2.14.0+ Mar 25, 2025
@TobiasSchikora TobiasSchikora changed the title Vue Image Embedding Fails in .vue Files with @parcel/transformer-vue v2.14.0+ Vue Image Embedding Fails in .vue Files with @parcel/[email protected] Mar 25, 2025
@shepmaster
Copy link

This may be beyond Vue — I have a React setup and am seeing something similar:

import image from "./assets/test-pattern.jpg";
console.log(image)
import * as styles from "./TestPattern.module.css";

const TestPattern: React.FC = () => (
  <img className={styles.container} src={image} />
);

export default TestPattern;

This logs image as the empty object {} and the HTML contains [object Object]:

<img class="ySmK_a_container e4Rufq_-expand" src="[object Object]">

This code has been working fine for years, so it certainly feels like some recent change somewhere.

@shepmaster
Copy link

Ah, I found #10116 (comment) (where this issue came from!), which suggests changing the import to use url: in import statements. Sorry for the noise.

@TobiasSchikora
Copy link
Author

To avoid any misunderstandings: I'm not talking about imported image files that I then reference in the templates, but rather image URLs that I specify directly in the templates - without any imports.

For example, if I have something like this in a .vue file:

<img src="../img/test.png">

Previously, the image would load correctly, but now it just shows [object Object].

Importing works fine if I prepend url:, but I don’t want to have to import every single image reference in my vue components, especially since it used to work without imports. Something must have broken here.

@TobiasSchikora
Copy link
Author

Any updates on this?

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

2 participants