You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 4, 2021. It is now read-only.
// CommonJS to ES modules test cases// Importingvarfoo=require('bar');// becomes importfoofrom'bar';require('bar')(foo);// becomesimporttempvarfrom'bar';tempvar(foo);varfoo=require('bar').foo;// becomesimport{foo}from'bar';// Exportingmodule.exports={//pojoname: 'todd',value: 'person'};//becomesexportvarname='todd';exportvarvalue='person';exportdefault{name, value};module.exports=function(){};// or anything not a pojo//becomesexportdefaultfunction(){};module.exports.name='todd';module.exports.value='person';// becomes exportvarname='todd';exportvarvalue='person';exportdefault{name, value};
I think this would cover all commonJS use cases but I'm not sure. And the last import example is a nice to have.
I know it's probably early for this but I worked up the test cases for imports and exports of how I think CommonJS to es modules might look.
https://gist.github.com/reconbot/5358ab4a532d2f253df0
I think this would cover all commonJS use cases but I'm not sure. And the last import example is a nice to have.