You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My use case: I'm an author of pluginA and I have to rely on some esbuild options to provide consistent output (as an example, absWorkingDir value affects source maps generation, entrypoints style affects metafile analysis, etc.).
Obvious and well documented solution is to use https://esbuild.github.io/plugins/#build-options. But, those options can be mutated by other plugins, so in the following setup build.initialOptions available inside pluginA is... incorrect:
plugins: [pluginA(),pluginB()// hahaha, absWorkingDir will be changed 👿 ]
Changing the order can help only in limited situations: what if plugin count > 2 (5, 10, 20...)? What if pluginB also need actual settings which can mutated by pluginA? It looks like a circular dependency.
Is it possible to get actual options now? Or it's need to add something like build.getFinalOptions()to the API?
The text was updated successfully, but these errors were encountered:
I'm confused. Can't you just access build.initialOptions in your plugin? Something like this:
constesbuild=require('esbuild')constpluginA=()=>({name: 'pluginA',setup(build){build.onStart(()=>{console.log(build.initialOptions)})}})constpluginB=()=>({name: 'pluginB',setup(build){build.initialOptions.absWorkingDir='/'}})esbuild.build({plugins: [pluginA(),pluginB()// hahaha, absWorkingDir will be changed 👿]})
You just need to wait until setup is complete. One way to do that is with onStart. I suppose it could be a problem if some plugin continues to mutate build.initialOptions over time. But esbuild doesn't attempt to defend against plugins that are actively trying to break things.
My use case: I'm an author of
pluginA
and I have to rely on some esbuild options to provide consistent output (as an example,absWorkingDir
value affects source maps generation,entrypoints
style affects metafile analysis, etc.).Obvious and well documented solution is to use https://esbuild.github.io/plugins/#build-options. But, those options can be mutated by other plugins, so in the following setup
build.initialOptions
available insidepluginA
is... incorrect:Changing the order can help only in limited situations: what if plugin count > 2 (5, 10, 20...)? What if
pluginB
also need actual settings which can mutated bypluginA
? It looks like a circular dependency.Is it possible to get actual options now? Or it's need to add something like
build.getFinalOptions()
to the API?The text was updated successfully, but these errors were encountered: