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

Unexpected token error occured, when build .md contains multiple images #8630

Closed
1 task
retrorocket opened this issue Sep 22, 2023 · 2 comments · Fixed by #8633
Closed
1 task

Unexpected token error occured, when build .md contains multiple images #8630

retrorocket opened this issue Sep 22, 2023 · 2 comments · Fixed by #8633
Labels
needs triage Issue needs to be triaged

Comments

@retrorocket
Copy link

retrorocket commented Sep 22, 2023

Astro Info

Astro                    v3.1.2
Node                     v18.17.1
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             build-ogimages
                         algolia-queries
                         @astrojs/react
                         @astrojs/sitemap
                         @astrojs/tailwind
                         auto-import
                         @astrojs/mdx

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When I run astro build or astro dev a Markdown with multiple images using astro:assets,
I get an Unexpected token (Note that you need plugins to import files that are not JavaScript).

For example, writing the following Markdown will result in an error.

---
title: 'Error Example post'
description: 'Lorem ipsum dolor sit amet'
pubDate: 'Sep 22 2023'
heroImage: '/blog-placeholder-3.jpg'
---

# This is error.

![test](../../assets/blog-placeholder-about.jpg)
![test](../../assets/blog-placeholder-2.jpg)

error log

Unexpected token (Note that you need plugins to import files that are not JavaScript)
file: /home/projects/withastro-astro-mzqz2y/src/content/blog/error-example.md:7:71
5:         
6:         import { getImage } from "astro:assets";
7:         import Astro__3EGYC from "../../assets/blog-placeholder-about.jpg";,import Astro__Zc2aCS from "../../assets/b...
                                                                              ^
8: 
9:         const images = async function() {
 error   Unexpected token (Note that you need plugins to import files that are not JavaScript)
  File:
    /home/projects/withastro-astro-mzqz2y/src/content/blog/error-example.md:7:71
  Code:
    5:         
    6:         import { getImage } from "astro:assets";
    7:         import Astro__3EGYC from "../../assets/blog-placeholder-about.jpg";,import Astro__Zc2aCS from "../../assets/b...
                                                                                  ^
    8: 
    9:         const images = async function() {
  Stacktrace:
RollupError: Unexpected token (Note that you need plugins to import files that are not JavaScript)
    at error (/home/projects/withastro-astro-mzqz2y/node_modules/rollup/dist/es/shared/node-entry.js:2312:30)
    at Module.error (/home/projects/withastro-astro-mzqz2y/node_modules/rollup/dist/es/shared/node-entry.js:13765:16)
    at Module.tryParse (/home/projects/withastro-astro-mzqz2y/node_modules/rollup/dist/es/shared/node-entry.js:14496:25)
    at Module.setSource (/home/projects/withastro-astro-mzqz2y/node_modules/rollup/dist/es/shared/node-entry.js:14097:39)
    at ModuleLoader.addModuleSource (/home/projects/withastro-astro-mzqz2y/node_modules/rollup/dist/es/shared/node-entry.js:24669:20)

  Cause:
SyntaxError: Unexpected token (7:71)
    at pp$4.raise (file:///home/projects/withastro-astro-mzqz2y/node_modules/rollup/dist/es/shared/node-entry.js:21641:13)
    at pp$9.unexpected (file:///home/projects/withastro-astro-mzqz2y/node_modules/rollup/dist/es/shared/node-entry.js:18849:8)
    at pp$5.parseExprAtomDefault (file:///home/projects/withastro-astro-mzqz2y/node_modules/rollup/dist/es/shared/node-entry.js:21010:8)
    at pp$5.parseExprAtom (file:///home/projects/withastro-astro-mzqz2y/node_modules/rollup/dist/es/shared/node-entry.js:21005:17)
    at pp$5.parseExprSubscripts (file:///home/projects/withastro-astro-mzqz2y/node_modules/rollup/dist/es/shared/node-entry.js:20789:19)
    at pp$5.parseMaybeUnary (file:///home/projects/withastro-astro-mzqz2y/node_modules/rollup/dist/es/shared/node-entry.js:20755:17)
    at pp$5.parseExprOps (file:///home/projects/withastro-astro-mzqz2y/node_modules/rollup/dist/es/shared/node-entry.js:20682:19)
    at pp$5.parseMaybeConditional (file:///home/projects/withastro-astro-mzqz2y/node_modules/rollup/dist/es/shared/node-entry.js:20665:19)
    at pp$5.parseMaybeAssign (file:///home/projects/withastro-astro-mzqz2y/node_modules/rollup/dist/es/shared/node-entry.js:20632:19)
    at pp$5.parseExpression (file:///home/projects/withastro-astro-mzqz2y/node_modules/rollup/dist/es/shared/node-entry.js:20595:19)

example

https://stackblitz.com/edit/withastro-astro-mzqz2y
-> npm install && npm run build

What's the expected result?

Markdown containing multiple images should render without error.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-mzqz2y

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Sep 22, 2023
@Princesseuh
Copy link
Member

That's my fault, I'm dumb 🤦‍♀️ Will fix, sorry for the inconvenience

@retrorocket
Copy link
Author

retrorocket commented Sep 22, 2023

@Princesseuh
Thanks for fixing it!
Build completed successfully with 6e1bec0.

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

Successfully merging a pull request may close this issue.

2 participants