How Does Sage 9 Enqueue jQuery?

In Sage’s webpack configuration, jQuery is included under externals.

Per webpack’s documentation:

The externals configuration option provides a way of excluding dependencies from the output bundles. Instead, the created bundle relies on that dependency to be present in the consumer’s environment.

In other words, webpack is told to not bundle up jQuery, but import 'jquery' in main.js makes the jquery object/variable available to other things in main.js.

6 Likes