Skip to content

Misleading documentation on externals type or potential bug #4148

Closed
@dmitrysteblyuk

Description

@dmitrysteblyuk

The documentation makes us believe that this example:

module.exports = {
  //...
  externals: {
    jquery: 'jQuery'
  }
};

will result in jquery imports to be replaced with jQuery variable:

In other words, when a string is provided it will be treated as root (defined above and below).
root: The library should be available as a global variable (e.g. via a script tag).

However it's not exactly true.
The default type of externals is defined by externalsType option. Which is by default defined as follows:

https://github.com/webpack/webpack/blob/master/lib/config/defaults.js#L189-L198

So for example in case of commonjs library target import $ from 'jquery'; will be transformed to require("jQuery").

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