Encountering a peculiar error while trying to create an IIFE method in the main.js file. Follow these steps to reproduce the issue, open the command prompt
vue init webpack-simple test
cd test
npm install test
npm run dev
Open the main.js file and insert the following method at the end
(function test() {
console.log('test');
})();
This will result in the following error being displayed on the console
Uncaught TypeError: (intermediate value) is not a function
at eval (eval at <anonymous> (build.js:978), <anonymous>:13:3)
at Object.<anonymous> (build.js:978)
at __webpack_require__ (build.js:660)
at fn (build.js:84)
at Object.<anonymous> (build.js:1378)
at __webpack_require__ (build.js:660)
at build.js:709
at build.js:712
If I change the test to a regular function and call it like test(), then no error is thrown. Why does this issue arise specifically when using an IIFE?