webpack.js.org icon indicating copy to clipboard operation
webpack.js.org copied to clipboard

Default export conditions are not documented

Open webJose opened this issue 10 months ago • 4 comments

Feature to document

Default export conditions that webpack allows, and any specifics around them. For example, if the list changes depending on anything.

Author(s)

No idea.

Additional information

https://github.com/webpack/webpack.js.org/blob/main/src/content/configuration/resolve.mdx

The document explains well pretty much everything, except the exact contents of the default conditions.

[ ] I am willing to work on this issue and submit a pull request.

webJose avatar Feb 26 '25 06:02 webJose

Do you mean conditionNames?

alexander-akait avatar Feb 26 '25 11:02 alexander-akait

Hello. Yes. For example, Vite's documentation says: The default allowed conditions are: import, module, browser, default, and production/development based on current mode.

webJose avatar Feb 26 '25 15:02 webJose

@webJose Yeah, we can improve it, but it is complex than just list, there is our default setup - https://github.com/webpack/webpack/blob/main/lib/config/defaults.js#L1540

So it is based on:

  • mode
  • target
  • dependency, i.e. is it require/import/@import url(...)/etc

alexander-akait avatar Feb 27 '25 10:02 alexander-akait

Thanks for pointing them out. I think they are important for NPM package developers, so they can understand how to best provide code for browser, or server, or electron, etc.

webJose avatar Feb 27 '25 15:02 webJose