Skip to content

Document webpack change: add exportsFields and conditionNames options #3785

@webpack-bot

Description

@webpack-bot

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": []
              }
        }
   }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions