I'm using webpack to bundle some simple JS files / modules.
The webpack output (unminified) looks like:
(self["webpackChunktest-project"] = self["webpackChunktest-project"] || []).push([[179],{
/***/ 4:
/***/ (() => {
// ...
// <MY BUNDLED CODE HERE>
// ...
/***/ })
},
/******/ __webpack_require__ => { // webpackRuntimeModules
/******/ "use strict";
/******/
/******/ var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
/******/ var __webpack_exports__ = (__webpack_exec__(4));
/******/ }
]);
As you can see, it wraps my code in some webpack modularization logic.
Is there any way to remove this wrapper logic? I'd love to just produce a pure JS file as an output without the boilerplate wrapper.
NOTE: Because I set optimzation.runtimeChunk to true (see config below), webpack creates a separate runtime file (not shown here), and the minimally wrapped JS file shown above.
Webpack Config
Here is the webpack.config.js:
const path = require('path');
const webpack = require('webpack');
const DIST_DIR = path.resolve(__dirname, 'dist');
const SRC_DIR = path.resolve(__dirname, 'src');
module.exports = {
mode: 'production',
optimization: {
minimize: false,
runtimeChunk: true
},
output: {
path: DIST_DIR
},
resolve: {
extensions: ['.js'],
modules: [SRC_DIR, 'node_modules']
},
resolveLoader: {
modules: ['node_modules']
},
entry: `${SRC_DIR}/test.js`,
module: {},
plugins: []
};