Output IIFE not working
See original GitHub issueBug report
What is the current behavior?
Setting output mode to IIFE doesn’t work. It creates a compilation error.

If the current behavior is a bug, please provide the steps to reproduce.
module.exports = {
entry: 'index.js',
output: {
path: '/dist',
filename: '[name].bundle.js',
publicPath: '/',
iife: true
}
};
What is the expected behavior?
I expect Webpack to put my bundle inside my dist folder and have this bundle wrapped in a self called function.
Other relevant information: webpack version: 4.39.3 Node.js version: 12.14.0 Operating System: Ubuntu 18.04 LTS Additional tools:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Why iife not working in a simple example? - Stack Overflow
That is because JS is parsing the IIFE as an argument call for the function, do it like this with an added semi-colon....
Read more >Problem Solved By IIFE. Don't expose your variables globally
when you run it the output will be the image and you see the person object it will be the last assigned value....
Read more >rollup-plugin-iife - npm
Start using rollup-plugin-iife in your project by running `npm i rollup-plugin-iife`. There is 1 other project in the npm registry using ...
Read more >rollup-plugin-iife - npm Package Health Analysis - Snyk
Currently (rollup@0.65), rollup doesn't support code splitting with IIFE output. This plugin would transform ES module output into IIFEs.
Read more >How to Bundle JavaScript With Rollup — Step-by-Step Tutorial
format — Rollup supports several output formats. Since we're running in the browser, we want to use an immediately-invoked function expression (IIFE).
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 Free
Top 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

Hopefully, I found this issue after only 10min of google search.
Is there a way to get the same behaviour with webpack@4?
Ok thanks! would be good to have any mention to that in the docs.
https://webpack.js.org/configuration/output/#outputiife