Comments (5)
Hi @NicolasRoehm,
The noscript tags should work properly now. Check out version 0.15.0
from next-image-export-optimizer.
Hi @NicolasRoehm,
Thanks for the bug report. I looked, and I know at least why this noscript img tag is not being generated.
This is how the export is taking place. I need to use the dynamic function with SSR off as there is a hydration error otherwise. When I would export the ExportedImage component directly, the noscript img tag would be generated but the hydration error occurs.
const DynamicExportedImage = dynamic(() => Promise.resolve(ExportedImage), {
ssr: false,
});
export default function (props: ExportedImageProps) {
const isStaticImage = typeof props.src === "object";
const width = (isStaticImage && props.width) || (props.src as any).width;
const height = (isStaticImage && props.height) || (props.src as any).height;
return isStaticImage ? (
<div style={isStaticImage ? { aspectRatio: width / height } : {}}>
<DynamicExportedImage {...props} />
</div>
) : (
<DynamicExportedImage {...props} />
);
}
I have to find a workaround for the hydration error. I think it happs because the environment variables are not accessible on the server side inside an imported module like the ExportedImage component.
from next-image-export-optimizer.
Hi @Niels-IO,
I've been playing with React & Next for only 2 weeks, so I'm not able to help much here.
Do you think something like this might help bypass the ssr:false
vercel/next.js#35773 (comment) ?
from next-image-export-optimizer.
Hi @NicolasRoehm,
I played around, but I cannot get around one issue: The ExportedImage component is a compiled commonjs file, and for the first server render, the process.env is undefined. One solution would be that I can export the ExportedImage component as an ES module and let Next.js compile the source. Unfortunately, I have had no luck in getting this to work for now.
from next-image-export-optimizer.
Using something like https://github.com/martpie/next-transpile-modules ?
About environment variables, I see a lot of NextJs plugins uses their own module.exports = {}
in a dedicated config file instead of the next.config.js
. I don't know if it can help
from next-image-export-optimizer.
Related Issues (20)
- Allow setting sharp's limitInputPixels option
- Allow setting sharp's limitInputPixels option
- Allow setting sharp's limitInputPixels option
- Allow setting sharp's limitInputPixels option
- Allow setting sharp's limitInputPixels option
- Allow setting sharp's limitInputPixels option
- issue with Node < 16 HOT 1
- Error: Qualified path resolution failed: we looked for the following paths, but none could be accessed HOT 2
- Support ref for ExportedImage component HOT 2
- Converted animated images lose animation HOT 4
- module is not defined in ES module scope HOT 4
- Next config env should be string, not json value HOT 3
- Error when no public/images folder exists HOT 1
- Support server components HOT 1
- Server side module in app directory HOT 1
- Cannot find module 'next-image-export-optimizer' from '...' HOT 9
- Can't use requrie in a esm project
- No images are generated when distDir is not 'out' HOT 7
- Is there a clean way to not use imageSizes/deviceSizes at all? HOT 1
- nextImageExportOptimizer still exists after setting of custom folder HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-image-export-optimizer.