@std/esm
Version:
Enable ES modules in Node today!
1 lines • 1.54 kB
JavaScript
;const{existsSync:e,mkdirSync:t,readFileSync:r,unlinkSync:n,writeFileSync:c}=require("fs"),{Script:o}=require("vm"),{createHash:u}=require("crypto"),{inspect:l}=require("util"),{resolve:a}=require("path"),i=module.constructor.length>1,{versions:s}=process,d=s.chakracore,_=s.v8||d,f=process.version,{defineProperty:p}=Reflect,{freeze:m}=Object,{runInNewContext:h,runInThisContext:y}=o.prototype,q=require("module"),b=new q(module.id,null),g=i?require:e=>b.require(e);function v(){const t=a(__dirname,"node_modules"),r=D(f+"\0"+_)+".blob",n=a(t,".cache"),c=a(n,r),u=j(c),l=a(__dirname,"esm.js"),i=new o("(function(require,module,__shared__){"+j(l,"utf8")+"\n})",{__proto__:null,cachedData:u,filename:l,produceCachedData:!0});let s=!1,p=null;const{cachedDataRejected:m}=i;if(i.cachedDataProduced&&!m?(s=!u,p=i.cachedData):u&&m&&(s=!0),s)if(p){let r=!1;e(t)?r=!0:w(t)&&w(n)&&(r=!0),r&&C(c,p)}else k(c);const q={__proto__:null,filename:l};return d?y.call(i,q):h.call(i,{__proto__:null,global:global},q)}function x(){return F(g,b,__shared__),b.exports}function S(e,t){return x()(e,t)}function D(e){return u("md5").update(e).digest("hex")}function w(e){try{return t(e),!0}catch(e){}return!1}function j(e,t){try{return r(e,t)}catch(e){}}function k(e){try{return n(e)}catch(e){}}function C(e,t){try{return c(e,t)}catch(e){}}b.filename=__filename,b.parent=module.parent;const F=v(),I=l.custom||"inspect";let __shared__;__shared__=x(),__shared__.global=global,p(S,I,{__proto__:null,value:()=>"@std/esm enabled"}),m(S),module.exports=S;