rollup/rollup

Provide format info in output.chunkFileNames callback

huozhi opened this issue · 1 comments

Feature Use Case

When I use split chunks sometimes I need generate the chunk file extension based on the format, for instance if the chunk format is es I want to output .js as extension but when the format is cjs I'd like to output the chunk with .cjs extension.

Current it provide [format] in string template which as "es" or "cjs" value, but if you use callback it cannot get this. I cannot generate different different chunk file name based on the format now.

Feature Proposal

Suggest the add format or the output options as the 2nd argument for chunkFileNames callback so you can generate the different chunk file name based on the format

Example

chunkFileNames(chunkInfo, output) {
  return (output.format == 'es') ? '[name]-[hash].js' : '[name]-[hash].cjs'
}

Realize we could just use access the output options from the same context, close as it's already resolved