gobwas/dm.js

In Node, CJS loader trying to require file first

Closed this issue · 2 comments

It need to try to load it via fs first, then fallback to require (maybe, just when there is no fs module, like in browserified context).

if (fs && fs.readFile) {
            return self.async.promise(function(resolve, reject) {
                // define path here
                fs.readFile(path, function(err, src) {
                    if (err) {
                        reject(err);
                    } else {
                        resolve(src);
                    }
                });
            });
        } else {
            return this.require(path, options);
        }

Urgently closed in 0.2.2 version.