question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Output IIFE not working

See original GitHub issue

Bug report

What is the current behavior?

Setting output mode to IIFE doesn’t work. It creates a compilation error.

image

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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
Micka33commented, Jun 16, 2020

Hopefully, I found this issue after only 10min of google search.

Is there a way to get the same behaviour with webpack@4?

1reaction
Richacinascommented, Apr 15, 2020

Ok thanks! would be good to have any mention to that in the docs.

https://webpack.js.org/configuration/output/#outputiife

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found