<div dir="ltr"><div dir="ltr">honestly this look like an `or` would've been great as reserved <div><br></div><div><div><span style="font-family:monospace,monospace">try import fs from 'fs'</span></div><div><span style="font-family:monospace,monospace"> or import fs from 'fs-polyfill'</span></div><div><span style="font-family:monospace,monospace"> or import fs from 'another-fs-polyfill'</span></div><div><span style="font-family:monospace,monospace"> catch optional, and triggered only if previous 3 imports failed</span></div><div><span style="font-family:monospace,monospace"> finally optionally do something;</span></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 1, 2019 at 12:05 PM Michał Wadas <<a href="mailto:michalwadas@gmail.com">michalwadas@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Syntax:<br><div><span style="font-family:monospace,monospace"><br></span></div><div><span style="font-family:monospace,monospace">try import fs from 'fs'</span></div><div><span style="font-family:monospace,monospace">   else import fs from 'fs-polyfill'</span></div><div><span style="font-family:monospace,monospace">   else import fs from 'another-fs-polyfill'</span></div><div><span style="font-family:monospace,monospace">   else do nothing; // Not sure about syntax</span></div><div><span style="font-family:monospace,monospace"><br></span></div><div><div><span style="font-family:monospace,monospace"><br></span></div><div><span style="font-family:monospace,monospace">try import {watchDirectory} from 'fs'</span></div><div><span style="font-family:monospace,monospace">   else import <span style="font-family:monospace,monospace">{watchDirectory}</span> from 'fs-polyfill'</span></div><div><span style="font-family:monospace,monospace">   else if(process.os === 'ExoticSystem') import <span style="font-family:monospace,monospace">{watchDirectory}</span> from 'another-fs-polyfill'</span></div><div><span style="font-family:monospace,monospace">   else throw Error('Your OS doesn\'t support watching directories');<br></span></div><span style="font-family:monospace,monospace"></span></div><div><br></div><div>Usages:</div><div><ul><li>Optional dependencies</li><li>Polyfills</li></ul><div>Problems:<br><ul><li>This can prevent loading modules before execution if presence of modules can't be proved statically</li><li>else-if requires execution before loading module - can be dropped</li></ul></div></div><div><br></div><div>I don't have enough time and knowledge about modules to write actual proposal.<br></div></div>
_______________________________________________<br>
es-discuss mailing list<br>
<a href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a><br>
<a href="https://mail.mozilla.org/listinfo/es-discuss" rel="noreferrer" target="_blank">https://mail.mozilla.org/listinfo/es-discuss</a><br>
</blockquote></div>