-
-
Save philipwalton/f7087b287be1af14bda41bcf35b6c3cc to your computer and use it in GitHub Desktop.
| { | |
| "presets": [ | |
| [ | |
| "@babel/preset-env", | |
| { | |
| "useBuiltIns": "usage", | |
| "corejs": "3.38.1" | |
| } | |
| ] | |
| ], | |
| "exclude": "**/core-js" | |
| } |
| console.log([1, 2, 3].at(-1)); |
| var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},e=function(t){return t&&t.Math===Math&&t},n=e("object"==typeof globalThis&&globalThis)||e("object"==typeof window&&window)||e("object"==typeof self&&self)||e("object"==typeof t&&t)||e("object"==typeof t&&t)||function(){return this}()||Function("return this")(),r={},o=function(t){try{return!!t()}catch(t){return!0}},i=!o((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),u=!o((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})),c=u,a=Function.prototype.call,f=c?a.bind(a):function(){return a.apply(a,arguments)},l={},s={}.propertyIsEnumerable,p=Object.getOwnPropertyDescriptor,y=p&&!s.call({1:2},1);l.f=y?function(t){var e=p(this,t);return!!e&&e.enumerable}:s;var b,v,g=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},h=u,d=Function.prototype,m=d.call,w=h&&d.bind.bind(m,m),O=h?w:function(t){return function(){return m.apply(t,arguments)}},S=O,j=S({}.toString),P=S("".slice),E=o,T=function(t){return P(j(t),8,-1)},F=Object,C=O("".split),I=E((function(){return!F("z").propertyIsEnumerable(0)}))?function(t){return"String"===T(t)?C(t,""):F(t)}:F,M=function(t){return null==t},k=M,x=TypeError,A=function(t){if(k(t))throw new x("Can't call method on "+t);return t},L=I,_=A,z=function(t){return L(_(t))},D="object"==typeof document&&document.all,N=void 0===D&&void 0!==D?function(t){return"function"==typeof t||t===D}:function(t){return"function"==typeof t},R=N,W=function(t){return"object"==typeof t?null!==t:R(t)},G=n,B=N,U=function(t,e){return arguments.length<2?(n=G[t],B(n)?n:void 0):G[t]&&G[t][e];var n},X=O({}.isPrototypeOf),$=n.navigator,q=$&&$.userAgent,K=n,V=q?String(q):"",Y=K.process,H=K.Deno,J=Y&&Y.versions||H&&H.version,Q=J&&J.v8;Q&&(v=(b=Q.split("."))[0]>0&&b[0]<4?1:+(b[0]+b[1])),!v&&V&&(!(b=V.match(/Edge\/(\d+)/))||b[1]>=74)&&(b=V.match(/Chrome\/(\d+)/))&&(v=+b[1]);var Z=v,tt=o,et=n.String,nt=!!Object.getOwnPropertySymbols&&!tt((function(){var t=Symbol("symbol detection");return!et(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&Z&&Z<41})),rt=nt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ot=U,it=N,ut=X,ct=Object,at=rt?function(t){return"symbol"==typeof t}:function(t){var e=ot("Symbol");return it(e)&&ut(e.prototype,ct(t))},ft=String,lt=N,st=function(t){try{return ft(t)}catch(t){return"Object"}},pt=TypeError,yt=function(t){if(lt(t))return t;throw new pt(st(t)+" is not a function")},bt=M,vt=f,gt=N,ht=W,dt=TypeError,mt={exports:{}},wt=n,Ot=Object.defineProperty,St=function(t,e){try{Ot(wt,t,{value:e,configurable:!0,writable:!0})}catch(n){wt[t]=e}return e},jt=n,Pt=St,Et="__core-js_shared__",Tt=mt.exports=jt[Et]||Pt(Et,{});(Tt.versions||(Tt.versions=[])).push({version:"3.38.1",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Ft=mt.exports,Ct=Ft,It=function(t,e){return Ct[t]||(Ct[t]=e||{})},Mt=A,kt=Object,xt=function(t){return kt(Mt(t))},At=xt,Lt=O({}.hasOwnProperty),_t=Object.hasOwn||function(t,e){return Lt(At(t),e)},zt=O,Dt=0,Nt=Math.random(),Rt=zt(1..toString),Wt=function(t){return"Symbol("+(void 0===t?"":t)+")_"+Rt(++Dt+Nt,36)},Gt=It,Bt=_t,Ut=Wt,Xt=nt,$t=rt,qt=n.Symbol,Kt=Gt("wks"),Vt=$t?qt.for||qt:qt&&qt.withoutSetter||Ut,Yt=function(t){return Bt(Kt,t)||(Kt[t]=Xt&&Bt(qt,t)?qt[t]:Vt("Symbol."+t)),Kt[t]},Ht=f,Jt=W,Qt=at,Zt=function(t,e){var n=t[e];return bt(n)?void 0:yt(n)},te=function(t,e){var n,r;if("string"===e&>(n=t.toString)&&!ht(r=vt(n,t)))return r;if(gt(n=t.valueOf)&&!ht(r=vt(n,t)))return r;if("string"!==e&>(n=t.toString)&&!ht(r=vt(n,t)))return r;throw new dt("Can't convert object to primitive value")},ee=TypeError,ne=Yt("toPrimitive"),re=function(t,e){if(!Jt(t)||Qt(t))return t;var n,r=Zt(t,ne);if(r){if(void 0===e&&(e="default"),n=Ht(r,t,e),!Jt(n)||Qt(n))return n;throw new ee("Can't convert object to primitive value")}return void 0===e&&(e="number"),te(t,e)},oe=at,ie=function(t){var e=re(t,"string");return oe(e)?e:e+""},ue=W,ce=n.document,ae=ue(ce)&&ue(ce.createElement),fe=function(t){return ae?ce.createElement(t):{}},le=fe,se=!i&&!o((function(){return 7!==Object.defineProperty(le("div"),"a",{get:function(){return 7}}).a})),pe=i,ye=f,be=l,ve=g,ge=z,he=ie,de=_t,me=se,we=Object.getOwnPropertyDescriptor;r.f=pe?we:function(t,e){if(t=ge(t),e=he(e),me)try{return we(t,e)}catch(t){}if(de(t,e))return ve(!ye(be.f,t,e),t[e])};var Oe={},Se=i&&o((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),je=W,Pe=String,Ee=TypeError,Te=function(t){if(je(t))return t;throw new Ee(Pe(t)+" is not an object")},Fe=i,Ce=se,Ie=Se,Me=Te,ke=ie,xe=TypeError,Ae=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,_e="enumerable",ze="configurable",De="writable";Oe.f=Fe?Ie?function(t,e,n){if(Me(t),e=ke(e),Me(n),"function"==typeof t&&"prototype"===e&&"value"in n&&De in n&&!n[De]){var r=Le(t,e);r&&r[De]&&(t[e]=n.value,n={configurable:ze in n?n[ze]:r[ze],enumerable:_e in n?n[_e]:r[_e],writable:!1})}return Ae(t,e,n)}:Ae:function(t,e,n){if(Me(t),e=ke(e),Me(n),Ce)try{return Ae(t,e,n)}catch(t){}if("get"in n||"set"in n)throw new xe("Accessors not supported");return"value"in n&&(t[e]=n.value),t};var Ne=Oe,Re=g,We=i?function(t,e,n){return Ne.f(t,e,Re(1,n))}:function(t,e,n){return t[e]=n,t},Ge={exports:{}},Be=i,Ue=_t,Xe=Function.prototype,$e=Be&&Object.getOwnPropertyDescriptor,qe=Ue(Xe,"name"),Ke={EXISTS:qe,PROPER:qe&&"something"===function(){}.name,CONFIGURABLE:qe&&(!Be||Be&&$e(Xe,"name").configurable)},Ve=N,Ye=Ft,He=O(Function.toString);Ve(Ye.inspectSource)||(Ye.inspectSource=function(t){return He(t)});var Je,Qe,Ze,tn=Ye.inspectSource,en=N,nn=n.WeakMap,rn=en(nn)&&/native code/.test(String(nn)),on=Wt,un=It("keys"),cn=function(t){return un[t]||(un[t]=on(t))},an={},fn=rn,ln=n,sn=W,pn=We,yn=_t,bn=Ft,vn=cn,gn=an,hn="Object already initialized",dn=ln.TypeError,mn=ln.WeakMap;if(fn||bn.state){var wn=bn.state||(bn.state=new mn);wn.get=wn.get,wn.has=wn.has,wn.set=wn.set,Je=function(t,e){if(wn.has(t))throw new dn(hn);return e.facade=t,wn.set(t,e),e},Qe=function(t){return wn.get(t)||{}},Ze=function(t){return wn.has(t)}}else{var On=vn("state");gn[On]=!0,Je=function(t,e){if(yn(t,On))throw new dn(hn);return e.facade=t,pn(t,On,e),e},Qe=function(t){return yn(t,On)?t[On]:{}},Ze=function(t){return yn(t,On)}}var Sn={set:Je,get:Qe,has:Ze,enforce:function(t){return Ze(t)?Qe(t):Je(t,{})},getterFor:function(t){return function(e){var n;if(!sn(e)||(n=Qe(e)).type!==t)throw new dn("Incompatible receiver, "+t+" required");return n}}},jn=O,Pn=o,En=N,Tn=_t,Fn=i,Cn=Ke.CONFIGURABLE,In=tn,Mn=Sn.enforce,kn=Sn.get,xn=String,An=Object.defineProperty,Ln=jn("".slice),_n=jn("".replace),zn=jn([].join),Dn=Fn&&!Pn((function(){return 8!==An((function(){}),"length",{value:8}).length})),Nn=String(String).split("String"),Rn=Ge.exports=function(t,e,n){"Symbol("===Ln(xn(e),0,7)&&(e="["+_n(xn(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(e="get "+e),n&&n.setter&&(e="set "+e),(!Tn(t,"name")||Cn&&t.name!==e)&&(Fn?An(t,"name",{value:e,configurable:!0}):t.name=e),Dn&&n&&Tn(n,"arity")&&t.length!==n.arity&&An(t,"length",{value:n.arity});try{n&&Tn(n,"constructor")&&n.constructor?Fn&&An(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var r=Mn(t);return Tn(r,"source")||(r.source=zn(Nn,"string"==typeof e?e:"")),t};Function.prototype.toString=Rn((function(){return En(this)&&kn(this).source||In(this)}),"toString");var Wn=Ge.exports,Gn=N,Bn=Oe,Un=Wn,Xn=St,$n={},qn=Math.ceil,Kn=Math.floor,Vn=Math.trunc||function(t){var e=+t;return(e>0?Kn:qn)(e)},Yn=function(t){var e=+t;return e!=e||0===e?0:Vn(e)},Hn=Yn,Jn=Math.max,Qn=Math.min,Zn=Yn,tr=Math.min,er=function(t){var e=Zn(t);return e>0?tr(e,9007199254740991):0},nr=function(t){return er(t.length)},rr=z,or=function(t,e){var n=Hn(t);return n<0?Jn(n+e,0):Qn(n,e)},ir=nr,ur=function(t){return function(e,n,r){var o=rr(e),i=ir(o);if(0===i)return!t&&-1;var u,c=or(r,i);if(t&&n!=n){for(;i>c;)if((u=o[c++])!=u)return!0}else for(;i>c;c++)if((t||c in o)&&o[c]===n)return t||c||0;return!t&&-1}},cr={includes:ur(!0),indexOf:ur(!1)},ar=_t,fr=z,lr=cr.indexOf,sr=an,pr=O([].push),yr=function(t,e){var n,r=fr(t),o=0,i=[];for(n in r)!ar(sr,n)&&ar(r,n)&&pr(i,n);for(;e.length>o;)ar(r,n=e[o++])&&(~lr(i,n)||pr(i,n));return i},br=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],vr=yr,gr=br.concat("length","prototype");$n.f=Object.getOwnPropertyNames||function(t){return vr(t,gr)};var hr={};hr.f=Object.getOwnPropertySymbols;var dr=U,mr=$n,wr=hr,Or=Te,Sr=O([].concat),jr=dr("Reflect","ownKeys")||function(t){var e=mr.f(Or(t)),n=wr.f;return n?Sr(e,n(t)):e},Pr=_t,Er=jr,Tr=r,Fr=Oe,Cr=o,Ir=N,Mr=/#|\.prototype\./,kr=function(t,e){var n=Ar[xr(t)];return n===_r||n!==Lr&&(Ir(e)?Cr(e):!!e)},xr=kr.normalize=function(t){return String(t).replace(Mr,".").toLowerCase()},Ar=kr.data={},Lr=kr.NATIVE="N",_r=kr.POLYFILL="P",zr=kr,Dr=n,Nr=r.f,Rr=We,Wr=function(t,e,n,r){r||(r={});var o=r.enumerable,i=void 0!==r.name?r.name:e;if(Gn(n)&&Un(n,i,r),r.global)o?t[e]=n:Xn(e,n);else{try{r.unsafe?t[e]&&(o=!0):delete t[e]}catch(t){}o?t[e]=n:Bn.f(t,e,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return t},Gr=St,Br=function(t,e,n){for(var r=Er(e),o=Fr.f,i=Tr.f,u=0;u<r.length;u++){var c=r[u];Pr(t,c)||n&&Pr(n,c)||o(t,c,i(e,c))}},Ur=zr,Xr={},$r=yr,qr=br,Kr=Object.keys||function(t){return $r(t,qr)},Vr=i,Yr=Se,Hr=Oe,Jr=Te,Qr=z,Zr=Kr;Xr.f=Vr&&!Yr?Object.defineProperties:function(t,e){Jr(t);for(var n,r=Qr(e),o=Zr(e),i=o.length,u=0;i>u;)Hr.f(t,n=o[u++],r[n]);return t};var to,eo=U("document","documentElement"),no=Te,ro=Xr,oo=br,io=an,uo=eo,co=fe,ao="prototype",fo="script",lo=cn("IE_PROTO"),so=function(){},po=function(t){return"<"+fo+">"+t+"</"+fo+">"},yo=function(t){t.write(po("")),t.close();var e=t.parentWindow.Object;return t=null,e},bo=function(){try{to=new ActiveXObject("htmlfile")}catch(t){}var t,e,n;bo="undefined"!=typeof document?document.domain&&to?yo(to):(e=co("iframe"),n="java"+fo+":",e.style.display="none",uo.appendChild(e),e.src=String(n),(t=e.contentWindow.document).open(),t.write(po("document.F=Object")),t.close(),t.F):yo(to);for(var r=oo.length;r--;)delete bo[ao][oo[r]];return bo()};io[lo]=!0;var vo=Yt,go=Object.create||function(t,e){var n;return null!==t?(so[ao]=no(t),n=new so,so[ao]=null,n[lo]=t):n=bo(),void 0===e?n:ro.f(n,e)},ho=Oe.f,mo=vo("unscopables"),wo=Array.prototype;void 0===wo[mo]&&ho(wo,mo,{configurable:!0,value:go(null)});var Oo=xt,So=nr,jo=Yn,Po=function(t){wo[mo][t]=!0};(function(t,e){var n,r,o,i,u,c=t.target,a=t.global,f=t.stat;if(n=a?Dr:f?Dr[c]||Gr(c,{}):Dr[c]&&Dr[c].prototype)for(r in e){if(i=e[r],o=t.dontCallGetSet?(u=Nr(n,r))&&u.value:n[r],!Ur(a?r:c+(f?".":"#")+r,t.forced)&&void 0!==o){if(typeof i==typeof o)continue;Br(i,o)}(t.sham||o&&o.sham)&&Rr(i,"sham",!0),Wr(n,r,i,t)}})({target:"Array",proto:!0},{at:function(t){var e=Oo(this),n=So(e),r=jo(t),o=r>=0?r:n+r;return o<0||o>=n?void 0:e[o]}}),Po("at"),console.log([1,2,3].at(-1)); |
| core-js/modules/es.array.at.js | |
| core-js/internals/export.js | |
| core-js/internals/to-object.js | |
| core-js/internals/length-of-array-like.js | |
| core-js/internals/to-integer-or-infinity.js | |
| core-js/internals/add-to-unscopables.js | |
| core-js/internals/global-this.js | |
| core-js/internals/object-get-own-property-descriptor.js | |
| core-js/internals/create-non-enumerable-property.js | |
| core-js/internals/define-built-in.js | |
| core-js/internals/define-global-property.js | |
| core-js/internals/copy-constructor-properties.js | |
| core-js/internals/is-forced.js | |
| core-js/internals/require-object-coercible.js | |
| core-js/internals/to-length.js | |
| core-js/internals/math-trunc.js | |
| core-js/internals/well-known-symbol.js | |
| core-js/internals/object-create.js | |
| core-js/internals/object-define-property.js | |
| core-js/internals/descriptors.js | |
| core-js/internals/object-property-is-enumerable.js | |
| core-js/internals/create-property-descriptor.js | |
| core-js/internals/function-call.js | |
| core-js/internals/to-property-key.js | |
| core-js/internals/to-indexed-object.js | |
| core-js/internals/ie8-dom-define.js | |
| core-js/internals/has-own-property.js | |
| core-js/internals/is-callable.js | |
| core-js/internals/make-built-in.js | |
| core-js/internals/own-keys.js | |
| core-js/internals/is-null-or-undefined.js | |
| core-js/internals/fails.js | |
| core-js/internals/symbol-constructor-detection.js | |
| core-js/internals/use-symbol-as-uid.js | |
| core-js/internals/shared.js | |
| core-js/internals/uid.js | |
| core-js/internals/an-object.js | |
| core-js/internals/enum-bug-keys.js | |
| core-js/internals/html.js | |
| core-js/internals/hidden-keys.js | |
| core-js/internals/object-define-properties.js | |
| core-js/internals/document-create-element.js | |
| core-js/internals/v8-prototype-define-bug.js | |
| core-js/internals/shared-key.js | |
| core-js/internals/to-primitive.js | |
| core-js/internals/is-symbol.js | |
| core-js/internals/indexed-object.js | |
| core-js/internals/function-bind-native.js | |
| core-js/internals/function-uncurry-this.js | |
| core-js/internals/inspect-source.js | |
| core-js/internals/internal-state.js | |
| core-js/internals/get-built-in.js | |
| core-js/internals/function-name.js | |
| core-js/internals/object-get-own-property-names.js | |
| core-js/internals/object-get-own-property-symbols.js | |
| core-js/internals/environment-v8-version.js | |
| core-js/internals/shared-store.js | |
| core-js/internals/is-object.js | |
| core-js/internals/object-keys.js | |
| core-js/internals/ordinary-to-primitive.js | |
| core-js/internals/get-method.js | |
| core-js/internals/object-is-prototype-of.js | |
| core-js/internals/classof-raw.js | |
| core-js/internals/weak-map-basic-detection.js | |
| core-js/internals/object-keys-internal.js | |
| core-js/internals/is-pure.js | |
| core-js/internals/environment-user-agent.js | |
| core-js/internals/a-callable.js | |
| core-js/internals/array-includes.js | |
| core-js/internals/try-to-string.js | |
| core-js/internals/to-absolute-index.js |
I'm happy to update the example to better reflect typical configurations. The configuration I used relied on as many defaults as possible (for the reasons stated in my article). Here's what was in my babel.config.json file:
{
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"corejs": "3.38.1"
}
]
]
}That being said, I do want this example to be reflective of typical Babel and core-js usage, and I agree that typical usage does exclude node_modules, so I will update it.
It seems, this is your mistake. At least,
core-jsshould be excluded from transpiling for avoiding circular dependencies.
I disagree with this. I don't think it should matter whether a developer excludes core-js dependencies, especially considering the default Babel behavior is to not to exclude any dependencies.
I haven't looked into why Babel is adding additional dependencies when processing core-js polyfills, but it seems problematic to me that Babel, while processing core-js dependencies, is identifying that it needs to add additional polyfills, given that core-js is entirely authored in ES5. Though I guess that is a Babel issue and not a core-js issue.
@zloirock I updated this gist and the article. The output is now 11,217 bytes minified and includes 71 dependencies.
It seems, this is your mistake. At least,
core-jsshould be excluded from transpiling for avoiding circular dependencies. I'm not sure even that your bundle works at all.