Skip to content

feat: Add Prepend field to OnLoadResult for zero-cost text prepending#4392

Open
joelmoss wants to merge 1 commit intoevanw:mainfrom
joelmoss:onload_prepend
Open

feat: Add Prepend field to OnLoadResult for zero-cost text prepending#4392
joelmoss wants to merge 1 commit intoevanw:mainfrom
joelmoss:onload_prepend

Conversation

@joelmoss
Copy link
Copy Markdown

Add a Prepend *string field to both the public and internal OnLoadResult structs. When set, the text is prepended to the final file contents without requiring the plugin to read the file from disk. Multiple plugins can set Prepend and they concatenate in plugin order.

Similar to the banner option, but it instead allows you to add a banner or other text to a file that is specific to the file.

Also eliminates redundant os.ReadFile calls in plugins that only need to prepend text (like dirname), since esbuild already reads the file internally.

Add a Prepend *string field to both the public and internal OnLoadResult
structs. When set, the text is prepended to the final file contents without
requiring the plugin to read the file from disk. Multiple plugins can set
Prepend and they concatenate in plugin order.

Similar to the banner option, but it instead allows you to add a banner or other text to a file that
is specific to the file.

Also eliminates redundant os.ReadFile calls in plugins that only need to
prepend text (like dirname), since esbuild already reads the file internally.
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

Successfully merging this pull request may close these issues.

1 participant