Loose idea on "try import"

Michał Wadas michalwadas at gmail.com
Fri Mar 1 11:04:58 UTC 2019


try import fs from 'fs'
   else import fs from 'fs-polyfill'
   else import fs from 'another-fs-polyfill'
   else do nothing; // Not sure about syntax

try import {watchDirectory} from 'fs'
   else import {watchDirectory} from 'fs-polyfill'
   else if(process.os === 'ExoticSystem') import {watchDirectory} from
   else throw Error('Your OS doesn\'t support watching directories');


   - Optional dependencies
   - Polyfills


   - This can prevent loading modules before execution if presence of
   modules can't be proved statically
   - else-if requires execution before loading module - can be dropped

I don't have enough time and knowledge about modules to write actual
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190301/af097aed/attachment.html>

More information about the es-discuss mailing list