Skip to content

NMinhNguyen/webpack-umd-with-var-externals-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This example demonstrates what I believe is an issue with using var externals in a UMD build.

I have added two externals: one for lodash and a custom var external as follows:

module.exports = {
  /* ... */
  externals: {
    lodash: {
      commonjs: 'lodash',
      commonjs2: 'lodash',
      amd: 'lodash',
      root: '_'
    },
    foobar: 'var foo.bar'
  }
};

The output bundle contains things like require("foo.bar"), define(["lodash", "foo.bar"], factory), and the foo.bar external has a corresponding __WEBPACK_EXTERNAL_MODULE_2__. However, upon inspecting the bundle, you can see that __WEBPACK_EXTERNAL_MODULE_2__ is in fact unused, and there is a different module that is used and simply exports

/* 2 */
/***/ (function(module, exports) {

module.exports = foo.bar;

/***/ })

This makes we wonder if it's possible to not output WEBPACK_EXTERNAL_MODULE_2__ as that would solve the problem with the invalid (as well as unused) require("foo.bar").

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published