Search code examples
webpackwebpack-plugin

What is this style of webpack syntax: imports?this=>global!exports?global.fetch


I am looking through a webpack config that contains the following code:

new webpack.ProvidePlugin({
  fetch: 'imports?this=>global!exports?global.fetch!whatwg-fetch',
}),

I see from the webpack docs that ProvidePlugin replaces the value on the left (fetch) with the modules on the right wherever it finds it, with no import necessary.

I can follow the examples in the docs, for example

new webpack.ProvidePlugin({
  $: 'jquery',
  jQuery: 'jquery'
})

loads in the jquery module wherever $ or jQuery is encountered in the code. But my code doesn't look like a js module, so what it is doing?


Solution

  • It turns out this is imports-loader and exports-loader syntax: https://webpack.js.org/loaders/imports-loader/.