dy / settings-panel

Control panel for app, demo or tests
https://dy.github.io/settings-panel/
MIT License
70 stars 3 forks source link

Strictify modules for Webpack compatibility #8

Closed RanzQ closed 8 years ago

RanzQ commented 8 years ago

Added 'strictify' transform to include 'use strict'; in every module. For some reason this solves a problem with eval in Webpack dev mode.

After this, settings-panel works with ify-loader.

dy commented 8 years ago

Hi @RanzQ, thanks for the commit and research!

I am questioned a bit though about the solution. It adds extra production transform and a dependency, which is no-good for performance and deps number, and all that just for a few lines of code. Also I am not sure if all of my code is strict and all the following code will be strict, therefore I should add linter or some checker to ensure that. I would rather go for explicit adding use strict directives. I am not very contented with the brfs actually, but I don’t see an easier way to include index.css into package. You can try browserify -g strictify global transform by the way.

dy commented 8 years ago

I have made an update with 'use strict'; statements, please check 1.8.12.

RanzQ commented 8 years ago

@dfcreative Adding dependencies that do such small things is not cool, you're right. Your solution is fine too (tested and works). I'm using ES6 with Babel myself, so strict mode is automatic. I don't know a case when one should not use strict.

dy commented 8 years ago

@RanzQ completely agreed. I find it wearisome though declaring 'use strict' each and other time, we already have enough of boilerplate code in js, but it appeared that it gives bonuses like validity checks etc. I found 4 errors by that in settings-panel.

dy commented 8 years ago

Funny enough, first gotcha of strict mode - prohibited declaration of function within if/else block. That broke settings-panel in mobile safari.