packages/rolldown/src/options/docs/output-footer.md
:::warning
When using output.footer with minification enabled, the footer content may be stripped out unless it is formatted as a legal comment. To ensure your footer persists through minification, do either:
output.postFooter instead, which is added after minification, or/*! (e.g., /*! My footer */)@license (e.g., /* @license My footer */)@preserve (e.g., /* @preserve My footer */)//! (for single-line comments)The latter way's behavior is controlled by the output.legalComments option, which defaults to 'inline' and preserves these special comment formats.
:::
module.exports for CJS output with all named exports as propertiesexport default {
output: {
format: 'cjs',
exports: 'named',
footer: (chunk) => {
if (chunk.isEntry) {
return `
module.exports = exports.default;
module.exports.default = module.exports;
module.exports.foo = module.exports.default.foo;`;
}
return '';
},
},
};