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';
...
})();
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 π