You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve confidence and developer velocity when referencing public assets
Provide build time errors for invalid references instead of runtime
Non-Goals
Background
This feature would be extremely useful for anyone referencing static public assets in their next/image components instead of importing the images directly, as such, with dynamic image referencing from data, or in MDX content, where directly importing images into the MDX file can bloat the serverless function size and exceed the maximum 300mb limit.
The current alternative is to write your own local script that generates the types.
Proposal
This feature should be implemented by scanning the directories and files within the public directory and forming a type union of relative image paths to use on the src property of the next/image component.
This type should also be exported so that users can easily extend the next/image functionality with their own wrapper image components, which is quite common.
I also believe this should run on next typegen and during the dev server start, similar to the current Page and Route Helpers @bgub merged in v15.5, and watch the public directory for any changes while the dev server is running to re-generate types, just like the route types.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
Background
This feature would be extremely useful for anyone referencing static public assets in their next/image components instead of importing the images directly, as such, with dynamic image referencing from data, or in MDX content, where directly importing images into the MDX file can bloat the serverless function size and exceed the maximum 300mb limit.
The current alternative is to write your own local script that generates the types.
Proposal
This feature should be implemented by scanning the directories and files within the public directory and forming a type union of relative image paths to use on the
src
property of the next/image component.This type should also be exported so that users can easily extend the next/image functionality with their own wrapper image components, which is quite common.
I also believe this should run on
next typegen
and during the dev server start, similar to the current Page and Route Helpers @bgub merged in v15.5, and watch the public directory for any changes while the dev server is running to re-generate types, just like the route types.Beta Was this translation helpful? Give feedback.
All reactions