Support `legalComments: "linked"`
Feature request
Hi authors, thank you for creating this excellent tool! I can receive significant performance benefits for building speed. 😄
I wish wonderful if esbuild-loader could support legalComments: "linked" because it could further reduce the size of comments. Also, linking comments is the default behavior of Webpack.
Unfortunately, legalComments: "linked" causes build errors. 😢
Cannot transform with linked or external legal comments
Why?
By default, Webpack supports minification with linked license files. So, I think it's useful for many people that esbuild-loader can follow the behavior.
For details, see my reproduction repository: https://github.com/ybiquitous/esbuild-loader-legal-comments
Here are the build outputs on the repo. The default.* files below are by the Webpack default configuration:
$ ls dist/
default.js eof.js
default.js.LICENSE.txt linked.js
$ head -1 dist/default.js
/*! For license information please see default.js.LICENSE.txt */
$ head -2 dist/default.js.LICENSE.txt
/*!
Copyright (c) 2018 Jed Watson.
I'm unfamiliar with esbuild and don't know the error details, but I will help if there is anything I can.
Feel free to close the issue if there would be some difficulties. Thanks.
Alternatives
No response
Additional context
No response
esbuild doesn't support linked in the Transform API, but I think we can work around this by changing it to eof and extracting the comments out with magic-string and emitting it as an asset.
PR welcome!
FYI esbuild has added support for extracting legal comments in the Transform API in https://github.com/evanw/esbuild/releases/tag/v0.16.10
Thank you! 🎉