esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

Load separate builds based on the environment

Open ad1992 opened this issue 2 years ago • 3 comments

I have two separate ESM builds for development and production, is there a way to communicate which build should be loaded based on env ? eg webpack supports an exports field, is there something similar in esbuild as well ?

The reason I am having separate builds is the dev build has source maps and is unminified where as prod build is minified.

ad1992 avatar Dec 28 '23 12:12 ad1992

The exports field is not just for Webpack, esbuild supports it too. For example: https://esbuild.github.io/api/#conditions. Did you try it?

evanw avatar Dec 28 '23 14:12 evanw

Hi @evanw yes I tried with the exports field, it loads the separate builds however the source maps aren't loaded for the dev build, do I need to specify in exports for sourcemaps?

On other side, any plans to move the docs to docusaurus or something similar so you get the features like searching, version etc out of the box ?

ad1992 avatar Dec 29 '23 06:12 ad1992

the source maps aren't loaded for the dev build, do I need to specify in exports for sourcemaps?

There's no way to answer this without a way to reproduce the issue, sorry. The instructions you deleted when you created this issue said this:

When reporting a bug or requesting a feature, please do the following:

  • Provide a way to reproduce the issue. The best way to do this is to demonstrate the issue on the playground (https://esbuild.github.io/try/) and paste the URL here. A link to a minimal code sample with instructions for how to reproduce the issue may also work. Issues without a way to reproduce them may be closed.

Source maps are supposed to be automatically picked up based on the presence of the //# sourceMappingURL= comment somewhere in the source code. I can only investigate why it's not working if I have something to investigate.

On other side, any plans to move the docs to docusaurus or something similar so you get the features like searching, version etc out of the box ?

I currently have no plans to do that. Everything is deliberately on one page so you can use your browser's built-in search feature to search through the documentation.

evanw avatar Dec 29 '23 18:12 evanw

I'm closing this issue because a way to produce it was not provided. We can reopen it later if there's more information.

evanw avatar Jan 18 '24 23:01 evanw