Question - should import {fs} from 'fs'
be supported for CommonJS module loading from ES6?
If it is to be supported, we would effectively define the fs
module object in the ES6 registry to look something like the following:
var fs = require('fs');
var _fs = {};
Object.keys(fs).forEach((p) => _fs[p] = fs[p]);
_fs.default = fs;
new Module(_fs) // this is taken to be the module in the registry
This way I can import from the CommonJS module with default and named export syntax:
import fs from 'fs';
import {readFile} from 'fs';
We can choose to support this or not. But it would be great to get agreement.
I don't understand the
(p) => _fs[p] = fs[p]
part. Why not just: