Transform API to support legal comment extraction
Feature request
For the Transform API to support legalComments: 'external' and return a legalComments property with a string of legal comments extracted.
Context
We're trying to support legalComments: 'external' | 'linked' in esbuild-loader, but it seems much more complicated than expected (overriding legalComments to eof, slow/unsafe regex comments extraction, sourcemap compatible code manipulation with magic-string, etc.).
I could see supporting external, but linked is supposed to have the JavaScript reference the generated output file name and the transform API has no output files. Implementing linked is best done by the caller IMO since the caller will put the returned JavaScript string in an output file, and can then append a comment with the correct file name for the associated comment file. This same rationale is applied for source maps and the transform API too (you can't use linked in that case either).
Gotcha, that makes sense. Updated the feature request to external instead of linked.
Thank you @evanw !