eight04 / rollup-plugin-iife

Convert ES modules into IIFEs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any compiling option to prepend 'use strict' at the very top of the iife wrapper ?

myarcane opened this issue Β· comments

Hello there πŸ‘‹ ,

Thanks a lot for the plugin πŸ‘ .

Is there any compiling option to be able to prepend 'use strict'; at the very top of the iife wrapper ?

(function() {
  'use strict';
  ...
})();
commented

Does output.intro work?
https://rollupjs.org/guide/en/#outputintrooutputoutro

Maybe we should add this feature by default since ES modules run in strict mode?

Thank you for the tip. It works indeed πŸ’― .

I struggled a bit though because our project uses rollup-plugin-closure-compiler to minify the bundle. And actually this plugin checks if the original output is esm to decide whether or not it should remove use strict πŸ‘‰ https://github.com/ampproject/rollup-plugin-closure-compiler/blob/bfb50ab320a9ae07b4b4db969e307893df0f0b4a/src/transformers/chunk/strict.ts#L43
This is done by the plugin in the rollup transform hook so basically it was removing the use strict added by the intro.

Thankfully they added a non documented 😒 option to be able to keep it in the latest version of the plugin https://github.com/ampproject/rollup-plugin-closure-compiler/blob/bfb50ab320a9ae07b4b4db969e307893df0f0b4a/src/transformers/chunk/strict.ts#L37

Yes ! I think it would make sense to add it by default πŸ‘