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

Exits with errors if no <Image /> is present. #195

Closed
spudunk opened this issue Aug 22, 2022 · 9 comments · Fixed by #204
Closed

Exits with errors if no <Image /> is present. #195

spudunk opened this issue Aug 22, 2022 · 9 comments · Fixed by #204

Comments

@spudunk
Copy link

spudunk commented Aug 22, 2022

Describe the bug
A clear and concise description of what the bug is.
next-export-optimize-images fails if no is present

To Reproduce
Steps to reproduce the behavior:

  1. run create-next-app
  2. setup next-export-optimize-images according to documentation, including new export script
  3. clear index page so it is blank, remove all images from the project
  4. run "npm run export" or npx next-export-optimize-images
  5. See error

Expected behavior
Should not break build process but successfully optimize 0 / 0 assets

Desktop (please complete the following information):

  • OS: macOS arm64
  • Browser: Chrome
  • Version: any
@dc7290
Copy link
Owner

dc7290 commented Aug 22, 2022

@spudunk
Thanks.

Surely that should work fine.
Could you please share the error message?

@spudunk
Copy link
Author

spudunk commented Aug 26, 2022

I started a fresh NextJS project with TypeScript enabled and am unable to reproduce the issue.
It still exists in the project I initially found it in, which I added TypeScript after the project had been initialized.

Pretty long and ugly so pasting here: error.txt

Since I'm unable to reproduce it in new projects, feel free to disregard if you don't have time. I'd love to jump in and help improve but I'm afraid my skills aren't quite there yet.

@dc7290
Copy link
Owner

dc7290 commented Aug 26, 2022

@spudunk
From the errors I'm seeing, it looks like you're using an API route that can't be used with next export!
https://nextjs.org/docs/advanced-features/static-html-export#unsupported-features
This library only allows image components to be used with next export, so API routes are out of scope...

@spudunk
Copy link
Author

spudunk commented Aug 26, 2022

That's weird. I've created a branch with an appended error.txt file.
optimize-image-bug
This branch should produce the error.

I ran it again after deleting the API folder and have the same issue. I just commented out the components in index.js to disable all the images and reproduce the error.

Also, before deleting the API folder I had successful builds when some Images were used.

@dc7290
Copy link
Owner

dc7290 commented Aug 26, 2022

@spudunk

I see.
That is certainly weird.

Thanks for providing the repository.
I will take a look at it.

@spudunk
Copy link
Author

spudunk commented Aug 27, 2022

While working on another project, a new boilerplate, I didn't have the issue initially, but after adding a few components I got the error again.
Here's the repo for that project, it's cleaner and maybe easier to debug: static-boilerplate

I'm probably doing something dumb but I'd really appreciate your feedback.

@dc7290
Copy link
Owner

dc7290 commented Aug 27, 2022

@spudunk

The cause of the error was found.
As it turns out, there was an omission in the processing of cases where the image component was not used.
The error will stop occurring when a PR is released to correct the problem.

Until then, please use

  • Using the image component
  • Remove withExportImage from next.config.js
    Please take the following measures.

@dc7290
Copy link
Owner

dc7290 commented Aug 27, 2022

@spudunk

There was nothing wrong with your code, sir!

github-actions bot pushed a commit that referenced this issue Aug 27, 2022
## [1.6.2](v1.6.1...v1.6.2) (2022-08-27)

### Bug Fixes

* 🐛 Processing when the image component is not used ([a3dd7b3](a3dd7b3)), closes [#195](#195)
@github-actions
Copy link

🎉 This issue is included in version v1.6.2.

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

Successfully merging a pull request may close this issue.

2 participants