2gis / slot

JavaScript фреймворк, позволяющий быстро и просто создавать модульные изоморфные приложения.
http://2gis.github.io/slot
BSD 2-Clause "Simplified" License
86 stars 10 forks source link

Misleading limitations of app.invoke #209

Open bardt opened 9 years ago

bardt commented 9 years ago

App invoke method have some limitations on usage with code minification such as uglify.js. Internally, it only instruments first function in module, satisfying some requirements. The instrumentation itself is adding an array of argument-to-inject names into module.exports._args. If some function requirements are not met, code will work until it is minified. So, there is inconsistency between development and production use cases.

We need to do one of the following:

  1. Add more documentation on invoke method
  2. Rework it to be more reliable
  3. Warn users if invoked function is going to break after minification
bardt commented 9 years ago

Here is an example code, which will break after minification:

myOwnPrivateModule.js
---
function translate(text, $i18n) {
    return $i18n._t(text);
}

module.exports = function(slot, $regionManager, $i18n, $appState) {
    return { ....... }
}