feat: implement postBanner and postFooter#7487
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements the postBanner and postFooter hooks for Rolldown, which provide a way to add code to the top and bottom of bundled files after minification. This addresses issues #6790 and #3338, where content added via the regular banner and footer hooks could be removed during minification unless formatted as legal comments.
The implementation follows the existing pattern used for banner, footer, intro, and outro hooks, with the key difference that postBanner and postFooter are applied after the minification step to ensure the content persists in the final output.
Key Changes
- Added
postBannerandpostFooteras new output options and plugin hooks that execute after minification - The final output order is:
postBanner→banner→intro→ [code] →outro→footer→postFooter - Comprehensive test coverage including function tests, plugin tests, and CLI tests
Reviewed changes
Copilot reviewed 52 out of 62 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tasks/generator/src/generators/hook_usage.rs | Updated hook kind array size and added post_banner/post_footer entries |
| packages/rolldown/tests/fixtures/plugin/post-footer/* | Plugin-level tests for postFooter with function, string, and object variants |
| packages/rolldown/tests/fixtures/plugin/post-banner/* | Plugin-level tests for postBanner with function, string, and object variants |
| packages/rolldown/tests/fixtures/function/post-footer/* | Output option tests for postFooter including async, minification, and combined pre/post usage |
| packages/rolldown/tests/fixtures/function/post-banner/* | Output option tests for postBanner including async, minification, and combined pre/post usage |
| packages/rolldown/tests/cli/snapshots/cli-e2e.test.ts.snap | Updated CLI help output to include postBanner and postFooter options |
| packages/rolldown/src/utils/validator.ts | Added schema validation and CLI descriptions for postBanner/postFooter |
| packages/rolldown/src/utils/bindingify-output-options.ts | Wired up bindingification for postBanner/postFooter output options |
| packages/rolldown/src/plugin/index.ts | Added postBanner/postFooter to AddonHooks type definition |
| packages/rolldown/src/plugin/generated/hook-usage.ts | Generated hook usage tracking for postBanner/postFooter |
| packages/rolldown/src/plugin/bindingify-plugin.ts | Integrated bindingification for postBanner/postFooter plugin hooks |
| packages/rolldown/src/plugin/bindingify-output-hooks.ts | Implemented bindingification logic for postBanner/postFooter hooks |
| packages/rolldown/src/options/output-options.ts | Added TypeScript type definitions for postBanner/postFooter |
| packages/rolldown/src/options/normalized-output-options.ts | Added normalized versions with lazy property getters |
| packages/rolldown/src/constants/plugin.ts | Registered postBanner/postFooter in plugin hook name enumerations |
| packages/rolldown/src/binding.d.cts | Updated TypeScript binding definitions for Rust-JS interop |
| docs/options/output.md | Added documentation for postBanner/postFooter options with usage examples and ordering clarification |
| crates/rolldown_testing/_config.schema.json | Updated JSON schema to include postBanner/postFooter |
| crates/rolldown_plugin/src/pluginable.rs | Added trait methods for postBanner/postFooter hooks |
| crates/rolldown_plugin/src/plugin_driver/output_hooks.rs | Implemented driver methods to execute postBanner/postFooter hooks across plugins |
| crates/rolldown_plugin/src/plugin_driver/hook_orders.rs | Added hook ordering for postBanner/postFooter |
| crates/rolldown_plugin/src/plugin.rs | Added default trait implementations for postBanner/postFooter hooks |
| crates/rolldown_plugin/src/generated/hook_usage.rs | Generated bitflags for postBanner/postFooter hook usage tracking |
| crates/rolldown_common/src/types/instantiated_chunk.rs | Added post_banner/post_footer fields to InstantiatedChunk struct |
| crates/rolldown_common/src/inner_bundler_options/types/normalized_bundler_options.rs | Added postBanner/postFooter to normalized bundler options |
| crates/rolldown_common/src/inner_bundler_options/mod.rs | Added postBanner/postFooter to bundler options with serialization support |
| crates/rolldown_binding/src/utils/normalize_binding_options.rs | Normalized postBanner/postFooter options for Rust |
| crates/rolldown_binding/src/types/binding_normalized_options.rs | Exposed postBanner/postFooter getters on normalized options |
| crates/rolldown_binding/src/options/plugin/js_plugin.rs | Implemented JS plugin integration for postBanner/postFooter hooks |
| crates/rolldown_binding/src/options/plugin/binding_plugin_options.rs | Added binding types for postBanner/postFooter plugin hooks |
| crates/rolldown_binding/src/options/binding_output_options/mod.rs | Added and reorganized postBanner/postFooter in binding output options |
| crates/rolldown/src/utils/prepare_build_context.rs | Wired postBanner/postFooter into build context preparation |
| crates/rolldown/src/stages/generate_stage/render_chunk_to_assets.rs | Invokes post_banner_footer processing after minification |
| crates/rolldown/src/stages/generate_stage/post_banner_footer.rs | New module implementing the post-minification banner/footer application logic |
| crates/rolldown/src/stages/generate_stage/mod.rs | Registered post_banner_footer module |
| crates/rolldown/src/ecmascript/ecma_generator.rs | Computes postBanner/postFooter values and stores them in InstantiatedChunk |
| crates/rolldown/src/css/css_generator.rs | Explicitly sets postBanner/postFooter to None for CSS chunks |
| crates/rolldown/src/asset/asset_generator.rs | Explicitly sets postBanner/postFooter to None for asset chunks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/rolldown/tests/fixtures/function/post-banner/with-minify/_config.ts
Show resolved
Hide resolved
packages/rolldown/tests/fixtures/function/post-footer/with-minify/_config.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 52 out of 62 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/rolldown/tests/fixtures/function/post-footer/async-function/_config.ts
Show resolved
Hide resolved
packages/rolldown/tests/fixtures/function/post-footer/function/_config.ts
Show resolved
Hide resolved
crates/rolldown/src/stages/generate_stage/post_banner_footer.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 52 out of 62 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 52 out of 62 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/rolldown/tests/fixtures/plugin/post-banner-with-obj/_config.ts
Outdated
Show resolved
Hide resolved
✅ Deploy Preview for rolldown-rs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
763723b to
c95328d
Compare
|
Thank you for the fix! I don't know what should I do:
Detailscommit 763723b961d4744482795449f0435e6960a578ca
Author: sevenc-nanashi <[email protected]>
Date: Mon Dec 15 13:55:03 2025 +0900
fix: use undefined as a fallback
diff --git a/packages/rolldown/src/utils/bindingify-output-options.ts b/packages/rolldown/src/utils/bindingify-output-options.ts
index 9eda27dab..b800e7671 100644
--- a/packages/rolldown/src/utils/bindingify-output-options.ts
+++ b/packages/rolldown/src/utils/bindingify-output-options.ts
@@ -106,7 +106,7 @@ function bindingifyAddon(
if (typeof configAddon === 'function') {
return configAddon(transformRenderedChunk(chunk));
}
- return configAddon || '';
+ return configAddon || undefined;
};
}
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 37 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 37 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
73776ec to
cfb91c6
Compare
Merge activity
You must have a Graphite account in order to use the merge queue. Create an account and try again using this link |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 37 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]> Signed-off-by: Nanashi. <[email protected]>
d81ad1a to
35fa0bd
Compare
|
@sevenc-nanashi Thank you! |
Addresses review feedback from #7487 requesting tests with static string values for `postBanner` and `postFooter` options, in addition to the existing function-based tests. ## Changes - Added `function/post-banner/string/` test fixture with static string `postBanner` - Added `function/post-footer/string/` test fixture with static string `postFooter` ## Example Existing tests use functions: ```ts postBanner: () => '/* banner */', ``` New tests verify static strings work: ```ts postBanner: '/* banner */', ``` <!-- START COPILOT CODING AGENT SUFFIX --> <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > Read #7487 (comment) and add tests </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
## [1.0.0-beta.55] - 2025-12-17 ### 🚀 Features - add validation errors for incompatible `inlineDynamicImports` options (#7539) by @Copilot - rolldown_plugin_vite_reporter: truncate long importer lists in ineffective dynamic import warnings (#7528) by @Copilot - export `memfs` from `rolldown/experimental` for browser builds (#7490) by @Copilot - implement `postBanner` and `postFooter` (#7487) by @sevenc-nanashi - port getLogFilter helper from Rollup for advanced log filtering (#6890) by @taearls - dev: initialize `rolldown_plugin_lazy_compilation` (#7488) by @hyf0 - enable `experimental.transform_hires_sourcemap: 'boundary'` by default (#7478) by @sapphi-red - apply merge CJS namespace optimizations more generally (#7475) by @sapphi-red ### 🐛 Bug Fixes - avoid panic on invalid values for `output.exports`, `output.format`, `output.hash_characters` (#7542) by @sapphi-red - handle `__proto__` export for module namespace correctly (#7534) by @sapphi-red - handle `__proto__` export correctly (#7533) by @sapphi-red - rolldown_plugin_vite_resolve: acquire resolver lock before package json resolution (#7524) by @sapphi-red - disable syntax transform optimization for `minify: 'dce-only'` (#7520) by @sapphi-red - arrow function expression keep names (#7519) by @IWANABETHATGUY - skip symbols that are imported from other module when deconflicting module symbols (#7510) by @IWANABETHATGUY - preserve class names in assignment expressions with keepNames option (#7491) by @IWANABETHATGUY - accessor with decorators should be kept (#7499) by @Copilot - rolldown_plugin_vite_reporter: support `Infinity` for chunk_limit (#7497) by @shulaoda - change filename template validation errors from UNHANDLEABLE_ERROR to INVALID_OPTION (#7472) by @Copilot - `no entry found for key` error when merging CJS namespace exports (#7474) by @sapphi-red - generate output with syntax error when wrapped esm module using tla syntax (#7468) by @IWANABETHATGUY ### 🚜 Refactor - dev: rename `experimental.hmr` to `experimental.devMode` (#7527) by @hyf0 - pass addon option to rust as it is (#7526) by @hyf0 - remove unused stmtinfo meta flag (#7518) by @IWANABETHATGUY ### 📚 Documentation - clarify `closeBundle` behavior (#7525) by @sapphi-red ### 🧪 Testing - add tests for static string postBanner and postFooter (#7516) by @Copilot - disable pluginTimings in Rust integration tests to avoid snapshot noise (#7485) by @shulaoda - port Rollup JSX tests to `crates/rolldown/tests/rollup` (#7480) by @sapphi-red - re-triage some esbuild JSX preserve tests (#7479) by @sapphi-red - disable pluginTimings by default to avoid snapshot noise (#7471) by @shulaoda ### ⚙️ Miscellaneous Tasks - mark feature that will not be supported as ignored in rollup test status (#7535) by @sapphi-red - support `banner`/`footer`/`intro`/`outro` for config variants (#7532) by @sapphi-red - `dce/dce_of_decorators` esbuild test is now passing (#7531) by @sapphi-red - deps: update github-actions (major) (#7495) by @renovate[bot] - deps: update npm packages (#7493) by @renovate[bot] - add a check to verify failedReasons are updated (#7521) by @sapphi-red - deps: update test262 submodule for tests (#7523) by @sapphi-red - deps: update taiki-e/install-action action to v2.63.2 (#7496) by @renovate[bot] - deps: update oxc apps (#7511) by @renovate[bot] - deps: update oxc to v0.103.0 (#7513) by @camc314 - fix format in `.github/instructions/bug-investigation.instructions.md` (#7506) by @sapphi-red - add instructions for REPL decoding (#7502) by @sapphi-red - deps: update github-actions (#7492) by @renovate[bot] - deps: cargo-shear v1.9.0 (#7483) by @Boshen - deps: update dependency oxlint-tsgolint to v0.9.0 (#7484) by @renovate[bot] - deps: update dependency oxlint-tsgolint to v0.8.6 (#7470) by @renovate[bot] - add syntax validation for test output chunks that are not executed (#7466) by @IWANABETHATGUY - deps: update dependency rust to v1.92.0 (#7467) by @renovate[bot] - deps: update test262 submodule for tests (#7457) by @sapphi-red ### ❤️ New Contributors * @sevenc-nanashi made their first contribution in [#7487](#7487) * @taearls made their first contribution in [#6890](#6890) Co-authored-by: shulaoda <[email protected]>
This PR closes #6790 (and old my issue, #3338).
As I couldn't distinguish hooks related code and non hooks related code, I copied everyremoved in c95328d .footerandheadercode.