Пробовали ли вы с режимом производства. С текущей настройкой. Я вижу вывод желаний.
// foo. js
import bar from './bar'
export default function print() {
console.log(bar())
console.log(bar())
console.log(bar())
}
// bar. js
export default function bar() {
return "THIS IS TEST"
}
// webpack.config. js
const path = require('path');
module.exports = {
mode: "production",
entry: './src/foo.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'foo.bundle.js'
}
};
// Версия
"webpack": "^ 4.42.0", "webpack-cli": "^ 3.3.11"
// Вывод
([function(e,t,n){"use strict";function r(){console.log("THIS IS TEST"),console.log("THIS IS TEST"),console.log("THIS IS TEST")}n.r(t),n.d(t,"default",(function(){return r}))}]);