Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for banner and footer #531

Closed
wants to merge 1 commit into from
Closed

Add support for banner and footer #531

wants to merge 1 commit into from

Conversation

Gelio
Copy link
Contributor

@Gelio Gelio commented Nov 15, 2020

This PR is an attempt to fix #482.

It adds support for banner and footer options, that allow for prepending/appending a user-provided string to each output file.
Similar to rollup's options.

I do not have full confidence that I have done everything correctly, as this is my first ever PR in go, which I began learning yesterday 😅

Things I did (hopefully correctly):

  • add Banner and Footer options to configs
  • add emitting those in the linker
  • take account of the banner in the sourcemap
  • add test cases for sourcemaps when banner and footer are specified
  • add end-to-end test cases when banner and footer are specified
  • add handling those options in the JS service

I'm looking for any feedback you have 🙂

Example

test.js:

console.log('hello world');
14:11 $ ./esbuild test.js --sourcemap --banner="/* Hello world */" --footer="/* footer */"
/* Hello world */
console.log("hello world");
/* footer */
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidGVzdC5qcyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiY29uc29sZS5sb2coJ2hlbGxvIHdvcmxkJyk7XG4iXSwKICAibWFwcGluZ3MiOiAiO0FBQUEsUUFBUSxJQUFJOyIsCiAgIm5hbWVzIjogW10KfQo=

Sourcemap visualization

@evanw
Copy link
Owner

evanw commented Nov 16, 2020

Thanks for doing this. I haven't tested this extensively but this looks great as far as I can tell. Thanks for adding tests too. I can't think of anything else that would need to be integrated at the moment. I'll take care of documentation on the website.

@evanw
Copy link
Owner

evanw commented Nov 16, 2020

Closing this PR. GitHub's merge UI just broke over the weekend so I had to merge manually, and it didn't end up closing this PR.

@evanw evanw closed this Nov 16, 2020
evanw added a commit that referenced this pull request Nov 16, 2020
@Gelio
Copy link
Contributor Author

Gelio commented Nov 16, 2020

Thanks for merging and taking care of the cleanup 👍 I'm glad and excited I could contribute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] banner and footer
2 participants