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

Document webpack change: add exportsFields and conditionNames options #3785

Open
webpack-bot opened this issue Jun 17, 2020 · 2 comments
Open

Comments

@webpack-bot
Copy link

A pull request by @vankop was merged and maintainers requested a documentation change.

See pull request: webpack/webpack#10953


What kind of change does this PR introduce?
closes #9509
exports field feature support

Did you add tests for your changes?

Yes

Does this PR introduce a breaking change?

No

What needs to be documented once your changes are merged?

Webpack now supports exports field entrypoint.

Regarding to conditional exports webpack core supports the following conditions:

  • "import" - matched when the package is loaded via import or import()
  • "require" - matched when the package is loaded via require()
  • "node" - matched when options.target is node or electron environment
  • "electron" - matched when options.target is electron environment
  • "browser" - matched when options.target is web environment
  • "worker" - matched when options.target === "webworker"
  • "development" - matched when options.mode === "development"
  • "webpack"
  • "default"

Added some parameters to options.resolve option:

  • options.resolve.conditionNames a list of exports field condition names, default list described above in "conditional exports" section
  • options.resolve.exportsFields a list of exports fields in description files, default is ["exports"]
  • options.resolve.byDependency extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm".
    This option allows to define specific resolving to each dependency category, e.g. disallow extensions for esm:
module.exports = {
   resolve: {
        byDependency: {
              "esm": {
                     "extensions": []
              }
        }
   }
};
@sokra
Copy link
Member

sokra commented Jun 17, 2020

I started on some documentation here: https://gist.github.com/sokra/e032a0f17c1721c71cfced6f14516c62

@benmccann
Copy link

benmccann commented Jan 30, 2023

The exportsFields documentation is extremely lacking. Questions I have include:

  • What is the default value for this field?
  • Will the value I supply override the default or be merged with the default?
  • If the conditions I supply are merged with the default, will the new values will take precedence over the default values? What's the answer to this question for mainFields?
  • If I specify something like import here will that cause it to always be applied or to be applied conditionally only when import is being used?
  • If the conditions I supply override the default, an example would be helpful because I guess I would need to check process.env.NODE_ENV to set production or development appropriately and that would be easy to overlook from the current docs

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

3 participants