I'd be sad to see them go, they give me a warm safe feeling!

On Tuesday, January 12, 2016 at 9:52:41 AM UTC, Felix Küppers wrote:
>
> Thanks BJ and Devin for looking at this. I think it is ok to remove the 
> redundant closure then. It always looked ugly :)
>
> On 01/11/2016 11:36 PM, BJ wrote:
>
> Hi Devin,
> my plugin modules end up like this:
>
>     ( function ( module , exports , console , setInterval , clearInterval 
> , setTimeout , clearTimeout , Buffer , $tw , require ) { ( function ( ) { 
>     /*\
>     title: $:/core/modules/parsers/wikiparser/abstractwikiparser.js
>     type: application/javascript
>     module-type: global
>      
>     base class- individual wikiparser inherit from this class
>      
>     \*/ 
>     ( function ( ) { 
>      
>     /*jslint node: true, browser: true */ 
>     /*global $tw: false */ 
>     "use strict" ; 
>      
>     var AbstrWikiParser = function ( specifier ) { 
>        
>     exports [ "AbstrWikiParser" ] = AbstrWikiParser ; 
>      
>     } ) ( ) ; 
>      
>     ; } ) ( ) ; 
>     return exports ; 
>     } ) 
>
> so it looks like the IIFE is redundent.
>
> cheer
>
> BJ 
> On Monday, January 11, 2016 at 1:01:10 AM UTC, Devin Weaver wrote: 
>>
>> I was just curious about the use of IFE in the core plugins. Since using 
>> them as examples I felt the need to continue the style. However looking at 
>> how modules are handled in TiddlyWiki it seems that an IIFE might be 
>> redundant.
>>
>> For example:
>>
>> /*\
>> title: $:/plugins/my-plugin/plugin.js
>> type: application/javascript
>> module-type: startup
>>
>> An example startup plugin
>>
>> \*/
>> (function() {
>>
>>   exports.startup = function startup() {
>>     // Do stuff
>>   }
>>
>> })();
>>
>> Since TiddlyWiki wraps code in a sandbox in order to manage the exports 
>> variable would it not be scoped in it's own *context*? Wouldn't this 
>> wrapping mean the (function() {…})() is redundant?
>>
>> This became a point of question for me while I was using Babel 
>> <https://babeljs.io/> which transpiles ES2015 (ES6) modules into 
>> CommonJS (which the TiddlyWiki code *mostly* emulates). But unlike 
>> CoffeeScript it's output doesn't warp inside an IIFE. This is because Babel 
>> assumes that the files it outputs will be bundled with a module system like 
>> Browserify or AMD. TittleWiki is that bundling system using it's sandbox to 
>> evaluate plugin tiddlers.
>>
>> For completeness the above code would look like this in ES2015:
>>
>> /*\
>> title: $:/plugins/my-plugin/plugin.js
>> type: application/javascript
>> module-type: startup
>>
>> An example startup plugin
>>
>> \*/
>> export function startup() {
>>   // Do stuff
>> }
>>
>> Which outputs a file like:
>>
>> "use strict";
>>
>> Object.defineProperty(exports, "__esModule", {
>>   value: true
>> });
>> exports.startup = startup;
>> /*\
>> title: $:/plugins/my-plugin/plugin.js
>> type: application/javascript
>> module-type: startup
>>
>> An example startup plugin
>>
>> \*/
>> function startup() {
>>   // Do stuff
>> }
>>
>> So would this cause a startup function to be global? Or is the sandbox 
>> enough to prevent global pollution? And in the case of the later what is 
>> the benefit (if any) of wrapping the core code in IIFEs?
>>
>> -- 
> You received this message because you are subscribed to the Google Groups 
> "TiddlyWiki" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to tiddlywiki+...@googlegroups.com <javascript:>.
> To post to this group, send email to tiddl...@googlegroups.com 
> <javascript:>.
> Visit this group at https://groups.google.com/group/tiddlywiki.
> To view this discussion on the web visit 
> <https://groups.google.com/d/msgid/tiddlywiki/3c1d9e6a-0693-4c04-926d-527ac52dc98c%40googlegroups.com?utm_medium=email&utm_source=footer>
> https://groups.google.com/d/msgid/tiddlywiki/3c1d9e6a-0693-4c04-926d-527ac52dc98c%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/c3ab370e-d2f0-4a84-ad18-55eb22f5cb29%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to