esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

Transform API to support legal comment extraction

Open privatenumber opened this issue 3 years ago • 2 comments

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.).

privatenumber avatar Jul 15 '22 01:07 privatenumber

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).

evanw avatar Jul 15 '22 02:07 evanw

Gotcha, that makes sense. Updated the feature request to external instead of linked.

privatenumber avatar Jul 15 '22 03:07 privatenumber

Thank you @evanw !

privatenumber avatar Dec 20 '22 02:12 privatenumber