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

Give plugins access to build options #373

Closed
eulores opened this issue Sep 8, 2020 · 4 comments
Closed

Give plugins access to build options #373

eulores opened this issue Sep 8, 2020 · 4 comments

Comments

@eulores
Copy link

eulores commented Sep 8, 2020

I am writing a plugin to compile Imba code. The plugin needs to be able to resolve files with .imba extension.

Therefore, .imba needs to be added to resolveExtensions when triggering the build process.
Right now the whole array gets overwritten:
resolveExtensions: [".tsx", ".ts", ".jsx", ".mjs", ".cjs", ".js", ".json", ".imba"]

I propose to let plugins return a string or an array of additional extensions to add to resolveExtensions.

export interface LoaderResult {
  errors?: PartialMessage[];
  warnings?: PartialMessage[];

  contents?: string | Uint8Array;
  loader?: Loader;
  resolveExtensions?: string | Uint8Array;
}
@eulores
Copy link
Author

eulores commented Sep 8, 2020

I fear I made a bad proposal.
Probably better to add another function (addExtension) to the Plugin interface.

@evanw
Copy link
Owner

evanw commented Sep 12, 2020

I think other bundler plugin APIs give plugins the ability to modify the user-specified options object. I think that should be sufficient for this and other use cases. Something like addExtension doesn't seem sufficient because it wouldn't necessarily let you specify the exact resolution order.

@eulores
Copy link
Author

eulores commented Sep 13, 2020

Having the ability to modify the options object from within the plugin would indeed be perfect!
Right now I did not find that possibility. Am I missing something?
Thanks!

@evanw evanw changed the title [plugin] resolveExtensions should be appendable by plugins Give plugins access to build options Feb 19, 2021
@evanw evanw closed this as completed in d790be4 Mar 20, 2021
@evanw
Copy link
Owner

evanw commented Mar 20, 2021

Support for this is in the latest release. Documentation is here: https://esbuild.github.io/plugins/#build-options.

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 a pull request may close this issue.

2 participants