egoist / tsup

The simplest and fastest way to bundle your TypeScript libraries.
https://tsup.egoist.dev
MIT License
8.95k stars 217 forks source link

Support banner and footer esbuild options? #451

Closed iCrawl closed 2 years ago

iCrawl commented 2 years ago

https://esbuild.github.io/api/#banner https://esbuild.github.io/api/#footer

Not sure if there's a nice way to dynamically forward any kind of options esbuild supports so this doesn't have to be updated all the time.

Use case: https://github.com/evanw/esbuild/issues/946#issuecomment-814703190

egoist commented 2 years ago

You can use a esbuild plugin to modify build options: https://esbuild.github.io/plugins/#build-options

and pass the plugin to tsup.config.ts:

import type { Options } from 'tsup'

export const tsup: Options = {
  esbuildPlugins: [yourPlugin]
}
github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 5.6.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

egoist commented 2 years ago

Now you can directly use footer and banner options in tsup.config.ts

loynoir commented 2 years ago

Just a notice for new searchers come in.

A bit different from esbuild.

https://github.com/egoist/tsup/discussions/505

topLevelCreateRequire(import\.meta.url)

result in

topLevelCreateRequire(import.meta.url)

https://github.com/evanw/esbuild/issues/946#issuecomment-814703190

topLevelCreateRequire(import.meta.url)

result in

topLevelCreateRequire("file:///path/to/tsup.config.ts")
loynoir commented 2 years ago

@egoist I think instead of

topLevelCreateRequire("file:///path/to/tsup.config.ts")

should be rewritten to

topLevelCreateRequire("file:///path/to/package.json")