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

Library exports #3986

Open
tmisirpash opened this issue Nov 25, 2024 · 2 comments
Open

Library exports #3986

tmisirpash opened this issue Nov 25, 2024 · 2 comments

Comments

@tmisirpash
Copy link

In Webpack, it's possible to use output.library.export to choose the export of the namespace object that will be exposed as a library. For example, if my file is

export function namedExport(): string {
    return "namedExport";
}

export default function defaultExport(): string {
    return "defaultExport";
}

I can add

library: {
    name: 'MyLibrary',
    type: 'var',
    export: 'default',
},

and my bundle will not include the named export. Is there something similar that can be done in esbuild with the iife format?

@hyrious
Copy link

hyrious commented Nov 25, 2024

You can use the banner and footer options to wrap the final iife bundle. For example: (try)

globalName: '_mod',
footer: 'var MyLibrary = _mod.default; _mod = void 0;'

@tmisirpash
Copy link
Author

Thanks for the nice example. This is almost what I need -- my main issue is that the bundle would still contain the named exports.

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

No branches or pull requests

2 participants