Skip to content

Instantly share code, notes, and snippets.

View iamakulov's full-sized avatar

Ivan Akulov iamakulov

View GitHub Profile
@iamakulov
iamakulov / index.md
Last active May 22, 2020 15:28
Fixing babel-plugin-add-module-exports in Webpack 2

babel-plugin-add-module-exports generates an incorrect bundle if you use ES modules in the latest versions of Webpack 2 (at least in 2.1.0-beta.27 and .28). Here’s what to do.

1. Remove the plugin:

{
  "plugins": [
-   "add-module-exports"
  ]
}
@iamakulov
iamakulov / index.js
Last active August 14, 2021 06:14
Webpack’s externals work with local paths too
// my-app/webpack.config.js
{
externals: {
'jquery': 'jQuery',
/* ↑ With this line, Webpack will replace every
* import $ from 'jquery';
*
* in your code with approximately
* const $ = window.jQuery;
*