Devtool breaks UMD exports with webpack-dev-server
See original GitHub issueBug report
What is the current behavior?
After loading my bundle window.quickstarts = {}
.
If the current behavior is a bug, please provide the steps to reproduce.
webpack.config.js:
module.exports = {
mode: 'development',
devtool: 'inline-cheap-source-map',
entry: {
quickstarts: {
import: __dirname + '/entry.js',
filename: 'quickstarts.js',
library: {
name: 'quickstarts',
type: 'umd'
}
}
}
}
entry.js:
export function myExport() { console.log('some data'); }
The output at http://localhost:8080/quickstarts.js erroneously contains:
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
(() => {
"use strict";
var __webpack_exports__ = {}; // THIS SHOULDN'T BE HERE?!
/*!******************!*\
!*** ./entry.js ***!
\******************/
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "myExport": () => (/* binding */ myExport)
/* harmony export */ });
function myExport() { console.log('some data'); }
})();
Minimal Github repo: https://github.com/redallen/webpack-umd-bug
What is the expected behavior?
I expect __webpack_exports__
to not be defined in the IIFE scope so that it contains myExport
and then window.quickstarts
will contain it as well.
Other relevant information: webpack version:
"webpack": "^5.28.0",
"webpack-cli": "^4.5.0",
"webpack-dev-server": "^3.11.2"
Node.js version: v14.16.0 Operating System: linux
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Dev server breaks library entry type #4469 - GitHub
UMD is not exported while devServer inline is on. webpack#12793 (Also says fixed in wds 4). I don't really care about having hot...
Read more >DevServer - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >How to troubleshoot missing external libraries from Webpack ...
I am trying to create a reusable d3 library, building the code with Babel 7 and then bundling a JS file with Webpack...
Read more >Output
The top-level output key contains set of options instructing webpack on how and where it should output your bundles, assets and anything else...
Read more >配置 | webpack
This file should export the configuration object: ... "umd" - Export to AMD, CommonJS2 or as property in root. Default: "var". If output.library...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The beta release fixes it.
The release cycle surrounding webpack@5 and webpack-cli/webpack-dev-server has been rather confusing – I hope to see some version incompatibility notices in the future!
@ianks sorry, this message is not helpful, please provide example