javascript - AMD Module Shaping: How to load only one JS function? -


many javascript libraries have builder tool allow "shape" features of library depend on, both in terms of download bandwidth cost client , in terms of isolating functionality need.

for example, many things in sugar.js, don't need or want katakana , hiragana character set handling. trivial example, want able "shape" sugar.js export string.isblank().

is there tool available me? there ongoing effort ecmascript committee in future version of javascript? higher-level languages typescript , coffeescript, offer hidden support such "shaping"? can such "shaping" in c# .net dlls via monolinker.

basically, looks me amd handles loader aspect of modern compiler, not handle linker aspect. builders jquery , dojo work specific module, , aren't true linkers, builders.

update: google closure compiler compiler takes javascript input , produces javascript output. advanced compilation , externs documentation suggests there api call this:

if putting these export statements seems tedious, can use function exporting you. see closure library functions goog.exportsymbol() , goog.exportproperty() examples of exporting functions.

however, seems pretty convoluted, , makes me directly dependent on google closure compiler. @ point, looking info future standards ecmascript committee, regards commonjs, , wisdom people have thought problem , attempted tackle it. fellow typescript developers; don't want have create declare files in typescript sugar.js, use google closure compiler against typescript compiler output. sounds impossibly complex , hard debug.

unfortunately, there's nothing built javascript "shaping", , want compiler anyway, since 1 of roles serves automate "shaping" @ many levels (not methods).

the closure compiler mature , open source (jquery minified using closure compiler). if you're going begin annotating js code compiler, might one.

there huge number of side benefits of using compiler, btw. reduce file sizes (and interpretation/run time) great deal more shaping included libraries. , while you're developing produce lot of helpful messages catch bugs early.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -