Description
Describe the bug
I originally opened this issue in the Vitest repo but was told to come here.
I have an external package called @hex-insights/log
, when I import this package and try to instantiate any class in my app using Vitest I encounter the error (works fine with just Vite for dev server or build):
FAIL src/Components/GlobalErrorBoundary/test.tsx > GlobalErrorBoundary > Logger Test > should instantiate Logger
TypeError: Cannot call a class as a function
❯ d ../../node_modules/@hex-insights/log/dist/index.js:2:7764
❯ new t ../../node_modules/@hex-insights/log/dist/index.js:2:14712
❯ src/Components/GlobalErrorBoundary/test.tsx:44:21
Here is the source from the log package:
export class ASmallClass {
private secret = "I am a secret";
}
and in my test I have:
describe("Logger Test", () => {
it("should instantiate Logger", () => {
const myLogger = new ASmallClass();
expect(myLogger).toBeDefined();
});
});
Here is my vitest.config.ts
file:
/// <reference types="vitest" />
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [tsconfigPaths(), react()],
test: {
include: ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)", "**/test.[jt]s?(x)"],
environment: "jsdom",
server: {
debug: {
dumpModules: true,
},
},
css: {
modules: {
classNameStrategy: "non-scoped",
},
},
},
});
I've done some digging and found the issue has to do with the way vitest transforms modules.
Here is the original package from node_modules
:
import{getObjectKeys as t,isString as e,isObject as r,isArray as n,isNumber as i,isBoolean as o,getObjectEntries as a,sleep as u,deepCopyObject as c}from"@hex-insights/core";var s,l;function f(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function h(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?f(Object(r),!0).forEach((function(e){b(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function v(){v=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,a=Object.create(o.prototype),u=new P(n||[]);return i(a,"_invoke",{value:j(t,r,u)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",p="executing",y="completed",g={};function d(){}function m(){}function w(){}var b={};s(b,a,(function(){return this}));var k=Object.getPrototypeOf,x=k&&k(k(I([])));x&&x!==r&&n.call(x,a)&&(b=x);var O=w.prototype=d.prototype=Object.create(b);function E(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,o,a,u){var c=f(t[i],t,o);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,u)}))}u(c.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function j(e,r,n){var i=h;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var c=A(u,n);if(c){if(c===g)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var s=f(e,r,n);if("normal"===s.type){if(i=n.done?y:"suspendedYield",s.arg===g)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(i=y,n.method="throw",n.arg=s.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=f(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function F(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(typeof e+" is not iterable")}return m.prototype=w,i(O,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:m,configurable:!0}),m.displayName=s(w,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,s(t,c,"GeneratorFunction")),t.prototype=Object.create(O),t},e.awrap=function(t){return{__await:t}},E(L.prototype),s(L.prototype,u,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new L(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},E(O),s(O,c,"Generator"),s(O,a,(function(){return this})),s(O,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(F),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),F(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;F(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function p(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function y(t,e,r,n,i,o,a){try{var u=t[o](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,i)}function g(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){y(o,n,i,a,u,"next",t)}function u(t){y(o,n,i,a,u,"throw",t)}a(void 0)}))}}function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,p(n.key),n)}}function w(t,e,r){return e&&m(t.prototype,e),r&&m(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function b(t,e,r){return(e=p(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function k(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,u=[],c=!0,s=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){s=!0,i=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw i}}return u}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return x(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return x(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}(l=s||(s={})).regionalURLs={usWest1:"https://us-west-1.example.com","us-west-1":"https://us-west-1.example.com",euCentral1:"https://eu-central-1.example.com","eu-central-1":"https://eu-central-1.example.com"},l.paths={log:"/log"};var O,E,L=function(t){return t[t.Debug=100]="Debug",t[t.Info=200]="Info",t[t.Warn=300]="Warn",t[t.Error=400]="Error",t[t.Fatal=500]="Fatal",t}({});O=L||(L={}),E=b(b(b(b(b({},L.Debug,"DEBUG"),L.Info,"INFO"),L.Warn,"WARN"),L.Error,"ERROR"),L.Fatal,"FATAL"),O.addCustom=function(t,e){E[t]=e},O.toString=function(t){return E[t]},O.fromName=function(e){for(var r=t(E),n=0;n<r.length;n++){var i=r[n];if(E[i]===e)return Number(i)}return null};var j=function(){return w((function t(e){d(this,t),this.time=void 0,this.level=void 0,this.message=void 0,this.fields=void 0,this.logger=void 0,this.time=new Date,this.level=L.Info,this.message="",this.fields={},this.logger=e}),[{key:"setLevel",value:function(t){return this.level=t,this}},{key:"setMessage",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.message=e.map((function(t){return String(t)})).join(" ").trimEnd(),this}},{key:"setField",value:function(t,e){return this.fields[t]=e,this}},{key:"setFields",value:function(t){return this.fields=h(h({},this.fields),t),this}},{key:"debug",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Debug].concat(e))}},{key:"info",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Info].concat(e))}},{key:"warn",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Warn].concat(e))}},{key:"error",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Error].concat(e))}},{key:"fatal",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Fatal].concat(e))}},{key:"log",value:function(t){if(this.logger.isLevelEnabled(t)){this.setLevel(t);for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return this.setMessage.apply(this,r),this.logger.writeEntry(this)}}}])}(),A=function(){return w((function t(){d(this,t)}),[{key:"format",value:function(a){var u="".concat(a.time.toISOString()," ").concat(L.toString(a.level));""!==a.message&&(u+=" "+a.message);for(var c=t(a.fields).sort(),s=0;s<c.length;s++){var l=c[s],f=a.fields[l];e(f)?u+=" ".concat(l,'="').concat(f,'"'):r(f)||n(f)?u+=" ".concat(l,"=").concat(JSON.stringify(f)):i(f)||o(f)||null==f?u+=" ".concat(l,"=").concat(f):u+=" ".concat(l,'="').concat(f,'"')}return u+"\n"}}])}(),S="time",F="level",P="message",I=function(){return w((function t(){d(this,t)}),[{key:"format",value:function(t){for(var e={},r=a(t.fields),n=0;n<r.length;n++){var i=k(r[n],2),o=i[0],u=i[1],c=o;o!==S&&o!==F&&o!==P||(c="custom."+c),e[c]=u}return e[S]=t.time.toISOString(),e[F]=L.toString(t.level),e[P]=t.message,JSON.stringify(e)+"\n"}}])}();function N(){}function W(t){}function _(t){}function T(t){}function D(){}function G(t,e){}function C(t){}function M(){}function R(t,e){}function J(t){}function U(){}function Y(){}function B(){}function $(){}function q(){}function z(t){}function H(t,e,r){return K.apply(this,arguments)}function K(){return(K=g(v().mark((function t(e,r,n){var i,o;return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=0;case 1:if(!(i<n)){t.next=15;break}if(!(i>0)){t.next=5;break}return t.next=5,u(100*(Math.pow(2,i)+Math.random()));case 5:return t.prev=5,t.abrupt("return",e.write(r));case 9:t.prev=9,t.t0=t.catch(5),o=t.t0;case 12:i++,t.next=1;break;case 15:if(!o){t.next=17;break}throw o;case 17:case"end":return t.stop()}}),t,null,[[5,9]])})))).apply(this,arguments)}var Q=function(){return w((function t(){d(this,t)}),[{key:"write",value:function(t){console.log(t)}}])}(),V=function(){return w((function t(e){d(this,t),this.endpoint=void 0,this.endpoint=e}),[{key:"write",value:(t=g(v().mark((function t(e){return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e})});case 2:case"end":return t.stop()}}),t,this)}))),function(e){return t.apply(this,arguments)})}]);var t}(),X=function(){return w((function t(){d(this,t),this.writers=[],this.maxWriteAttempts=void 0,this.addWriters.apply(this,arguments),this.maxWriteAttempts=3}),[{key:"addWriter",value:function(t){this.writers.push(t)}},{key:"addWriters",value:function(){var t;(t=this.writers).push.apply(t,arguments)}},{key:"write",value:function(t){var e=this;return Promise.all(this.writers.map((function(r){try{return H(r,t,e.maxWriteAttempts)}catch(t){return}})))}}])}();function Z(t){return{write:t}}var tt=w((function t(){d(this,t),this.secret="I am a secret"})),et=function(){function t(){d(this,t),this.out=void 0,this.level=void 0,this.fields=void 0,this.formatter=void 0,this.maxWriteAttempts=3,this.out=new Q,this.level=L.Info,this.fields={},this.formatter=new A}return w(t,[{key:"setOutput",value:function(t){return this.out=t,this}},{key:"setLevel",value:function(t){return this.level=t,this}},{key:"setFormatter",value:function(t){return this.formatter=t,this}},{key:"copy",value:function(){var e=new t;return e.setOutput(this.out),e.setLevel(this.level),e.fields=c(this.fields),e.setFormatter(this.formatter),e}},{key:"getFields",value:function(){return this.fields}},{key:"setField",value:function(t,e){return this.fields[t]=e,this}},{key:"setFields",value:function(t){return this.fields=h(h({},this.fields),t),this}},{key:"newEntry",value:function(){var t=new j(this);return t.setFields(c(this.fields)),t}},{key:"withField",value:function(t,e){return this.newEntry().setField(t,e)}},{key:"withFields",value:function(t){return this.newEntry().setFields(t)}},{key:"debug",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Debug].concat(e))}},{key:"info",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Info].concat(e))}},{key:"warn",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Warn].concat(e))}},{key:"error",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Error].concat(e))}},{key:"fatal",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Fatal].concat(e))}},{key:"log",value:function(t){if(this.isLevelEnabled(t)){for(var e=this.newEntry(),r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return e.log.apply(e,[t].concat(n))}}},{key:"writeEntry",value:(e=g(v().mark((function t(e){var r;return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.prev=0,r=this.formatter.format(e),t.next=8;break;case 4:return t.prev=4,t.t0=t.catch(0),console.error("Error formatting log entry: ",t.t0),t.abrupt("return");case 8:return t.prev=8,t.next=11,H(this.out,r,this.maxWriteAttempts);case 11:t.next=16;break;case 13:t.prev=13,t.t1=t.catch(8),console.error("Error writing log: ",t.t1);case 16:case"end":return t.stop()}}),t,this,[[0,4],[8,13]])}))),function(t){return e.apply(this,arguments)})},{key:"isLevelEnabled",value:function(t){return t>=this.level}}]);var e}();export{s as API,V as APIWriter,tt as ASmallClass,Q as ConsoleWriter,j as Entry,I as JSONFormatter,L as Level,et as Logger,X as MultiWriter,A as TextFormatter,N as copyLogger,U as debug,$ as error,q as fatal,D as getFields,Y as info,z as log,M as newEntry,G as setField,C as setFields,T as setFormatter,_ as setLevel,W as setOutput,B as warn,R as withField,J as withFields,Z as writerFunc};
And here is the version that vitest uses (received from the output of test.server.debug.dumpModules: true
:
// /<path>/frontend/node_modules/@hex-insights/log/dist/index.js
const __vite_ssr_import_0__ = await __vite_ssr_import__("/@fs/<path>/frontend/node_modules/@hex-insights/core/dist/index.js", {"importedNames":["getObjectKeys","isString","isObject","isArray","isNumber","isBoolean","getObjectEntries","sleep","deepCopyObject"]});
var s,l;function f(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function h(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?f(Object(r),!0).forEach((function(e){b(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function v(){v=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,a=Object.create(o.prototype),u=new P(n||[]);return i(a,"_invoke",{value:j(t,r,u)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",p="executing",y="completed",g={};function d(){}function m(){}function w(){}var b={};s(b,a,(function(){return this}));var k=Object.getPrototypeOf,x=k&&k(k(I([])));x&&x!==r&&n.call(x,a)&&(b=x);var O=w.prototype=d.prototype=Object.create(b);function E(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,o,a,u){var c=f(t[i],t,o);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,u)}))}u(c.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function j(e,r,n){var i=h;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var c=A(u,n);if(c){if(c===g)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var s=f(e,r,n);if("normal"===s.type){if(i=n.done?y:"suspendedYield",s.arg===g)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(i=y,n.method="throw",n.arg=s.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=f(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function F(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(typeof e+" is not iterable")}return m.prototype=w,i(O,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:m,configurable:!0}),m.displayName=s(w,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,s(t,c,"GeneratorFunction")),t.prototype=Object.create(O),t},e.awrap=function(t){return{__await:t}},E(L.prototype),s(L.prototype,u,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new L(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},E(O),s(O,c,"Generator"),s(O,a,(function(){return this})),s(O,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(F),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),F(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;F(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function p(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function y(t,e,r,n,i,o,a){try{var u=t[o](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,i)}function g(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){y(o,n,i,a,u,"next",t)}function u(t){y(o,n,i,a,u,"throw",t)}a(void 0)}))}}function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,p(n.key),n)}}function w(t,e,r){return e&&m(t.prototype,e),r&&m(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function b(t,e,r){return(e=p(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function k(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,u=[],c=!0,s=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){s=!0,i=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw i}}return u}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return x(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return x(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}(l=s||(s={})).regionalURLs={usWest1:"https://us-west-1.api.log.hexinsights.dev","us-west-1":"https://us-west-1.api.log.hexinsights.dev",euCentral1:"https://eu-central-1.api.log.hexinsights.dev","eu-central-1":"https://eu-central-1.api.log.hexinsights.dev"},l.paths={log:"/log"};var O,E,L=function(t){return t[t.Debug=100]="Debug",t[t.Info=200]="Info",t[t.Warn=300]="Warn",t[t.Error=400]="Error",t[t.Fatal=500]="Fatal",t}({});O=L||(L={}),E=b(b(b(b(b({},L.Debug,"DEBUG"),L.Info,"INFO"),L.Warn,"WARN"),L.Error,"ERROR"),L.Fatal,"FATAL"),O.addCustom=function(t,e){E[t]=e},O.toString=function(t){return E[t]},O.fromName=function(e){for(var r=__vite_ssr_import_0__.getObjectKeys(E),n=0;n<r.length;n++){var i=r[n];if(E[i]===e)return Number(i)}return null};var j=function(){return w((function t(e){d(this,__vite_ssr_import_0__.getObjectKeys),this.time=void 0,this.level=void 0,this.message=void 0,this.fields=void 0,this.logger=void 0,this.time=new Date,this.level=L.Info,this.message="",this.fields={},this.logger=e}),[{key:"setLevel",value:function(t){return this.level=t,this}},{key:"setMessage",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.message=e.map((function(t){return String(t)})).join(" ").trimEnd(),this}},{key:"setField",value:function(t,e){return this.fields[t]=e,this}},{key:"setFields",value:function(t){return this.fields=h(h({},this.fields),t),this}},{key:"debug",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Debug].concat(e))}},{key:"info",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Info].concat(e))}},{key:"warn",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Warn].concat(e))}},{key:"error",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Error].concat(e))}},{key:"fatal",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Fatal].concat(e))}},{key:"log",value:function(t){if(this.logger.isLevelEnabled(t)){this.setLevel(t);for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return this.setMessage.apply(this,r),this.logger.writeEntry(this)}}}])}(),A=function(){return w((function t(){d(this,__vite_ssr_import_0__.getObjectKeys)}),[{key:"format",value:function(a){var u="".concat(a.time.toISOString()," ").concat(L.toString(a.level));""!==a.message&&(u+=" "+a.message);for(var c=__vite_ssr_import_0__.getObjectKeys(a.fields).sort(),s=0;s<c.length;s++){var l=c[s],f=a.fields[l];__vite_ssr_import_0__.isString(f)?u+=" ".concat(l,'="').concat(f,'"'):__vite_ssr_import_0__.isObject(f)||__vite_ssr_import_0__.isArray(f)?u+=" ".concat(l,"=").concat(JSON.stringify(f)):__vite_ssr_import_0__.isNumber(f)||__vite_ssr_import_0__.isBoolean(f)||null==f?u+=" ".concat(l,"=").concat(f):u+=" ".concat(l,'="').concat(f,'"')}return u+"\n"}}])}(),S="time",F="level",P="message",I=function(){return w((function t(){d(this,__vite_ssr_import_0__.getObjectKeys)}),[{key:"format",value:function(t){for(var e={},r=__vite_ssr_import_0__.getObjectEntries(t.fields),n=0;n<r.length;n++){var i=k(r[n],2),o=i[0],u=i[1],c=o;o!==S&&o!==F&&o!==P||(c="custom."+c),e[c]=u}return e[S]=t.time.toISOString(),e[F]=L.toString(t.level),e[P]=t.message,JSON.stringify(e)+"\n"}}])}();function N(){}function W(t){}function _(t){}function T(t){}function D(){}function G(t,e){}function C(t){}function M(){}function R(t,e){}function J(t){}function U(){}function Y(){}function B(){}function $(){}function q(){}function z(t){}function H(t,e,r){return K.apply(this,arguments)}function K(){return(K=g(v().mark((function t(e,r,n){var i,o;return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=0;case 1:if(!(i<n)){t.next=15;break}if(!(i>0)){t.next=5;break}return t.next=5,__vite_ssr_import_0__.sleep(100*(Math.pow(2,i)+Math.random()));case 5:return t.prev=5,t.abrupt("return",e.write(r));case 9:t.prev=9,t.t0=t.catch(5),o=t.t0;case 12:i++,t.next=1;break;case 15:if(!o){t.next=17;break}throw o;case 17:case"end":return t.stop()}}),__vite_ssr_import_0__.getObjectKeys,null,[[5,9]])})))).apply(this,arguments)}var Q=function(){return w((function t(){d(this,__vite_ssr_import_0__.getObjectKeys)}),[{key:"write",value:function(t){console.log(t)}}])}(),V=function(){return w((function t(e){d(this,t),this.endpoint=void 0,this.endpoint=e}),[{key:"write",value:(t=g(v().mark((function t(e){return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e})});case 2:case"end":return t.stop()}}),t,this)}))),function(e){return t.apply(this,arguments)})}]);var t}(),X=function(){return w((function t(){d(this,__vite_ssr_import_0__.getObjectKeys),this.writers=[],this.maxWriteAttempts=void 0,this.addWriters.apply(this,arguments),this.maxWriteAttempts=3}),[{key:"addWriter",value:function(t){this.writers.push(t)}},{key:"addWriters",value:function(){var t;(t=this.writers).push.apply(t,arguments)}},{key:"write",value:function(t){var e=this;return Promise.all(this.writers.map((function(r){try{return H(r,t,e.maxWriteAttempts)}catch(t){return}})))}}])}();function Z(t){return{write:t}}var tt=w((function t(){d(this,__vite_ssr_import_0__.getObjectKeys),this.secret="I am a secret"})),et=function(){function t(){d(this,t),this.out=void 0,this.level=void 0,this.fields=void 0,this.formatter=void 0,this.maxWriteAttempts=3,this.out=new Q,this.level=L.Info,this.fields={},this.formatter=new A}return w(t,[{key:"setOutput",value:function(t){return this.out=t,this}},{key:"setLevel",value:function(t){return this.level=t,this}},{key:"setFormatter",value:function(t){return this.formatter=t,this}},{key:"copy",value:function(){var e=new t;return e.setOutput(this.out),e.setLevel(this.level),e.fields=__vite_ssr_import_0__.deepCopyObject(this.fields),e.setFormatter(this.formatter),e}},{key:"getFields",value:function(){return this.fields}},{key:"setField",value:function(t,e){return this.fields[t]=e,this}},{key:"setFields",value:function(t){return this.fields=h(h({},this.fields),t),this}},{key:"newEntry",value:function(){var t=new j(this);return t.setFields(__vite_ssr_import_0__.deepCopyObject(this.fields)),t}},{key:"withField",value:function(t,e){return this.newEntry().setField(t,e)}},{key:"withFields",value:function(t){return this.newEntry().setFields(t)}},{key:"debug",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Debug].concat(e))}},{key:"info",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Info].concat(e))}},{key:"warn",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Warn].concat(e))}},{key:"error",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Error].concat(e))}},{key:"fatal",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.log.apply(this,[L.Fatal].concat(e))}},{key:"log",value:function(t){if(this.isLevelEnabled(t)){for(var e=this.newEntry(),r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return e.log.apply(e,[t].concat(n))}}},{key:"writeEntry",value:(e=g(v().mark((function t(e){var r;return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.prev=0,r=this.formatter.format(e),t.next=8;break;case 4:return t.prev=4,t.t0=t.catch(0),console.error("Error formatting log entry: ",t.t0),t.abrupt("return");case 8:return t.prev=8,t.next=11,H(this.out,r,this.maxWriteAttempts);case 11:t.next=16;break;case 13:t.prev=13,t.t1=t.catch(8),console.error("Error writing log: ",t.t1);case 16:case"end":return t.stop()}}),t,this,[[0,4],[8,13]])}))),function(t){return e.apply(this,arguments)})},{key:"isLevelEnabled",value:function(t){return t>=this.level}}]);var e}();
Object.defineProperty(__vite_ssr_exports__, "API", { enumerable: true, configurable: true, get(){ return s }});
Object.defineProperty(__vite_ssr_exports__, "APIWriter", { enumerable: true, configurable: true, get(){ return V }});
Object.defineProperty(__vite_ssr_exports__, "ASmallClass", { enumerable: true, configurable: true, get(){ return tt }});
Object.defineProperty(__vite_ssr_exports__, "ConsoleWriter", { enumerable: true, configurable: true, get(){ return Q }});
Object.defineProperty(__vite_ssr_exports__, "Entry", { enumerable: true, configurable: true, get(){ return j }});
Object.defineProperty(__vite_ssr_exports__, "JSONFormatter", { enumerable: true, configurable: true, get(){ return I }});
Object.defineProperty(__vite_ssr_exports__, "Level", { enumerable: true, configurable: true, get(){ return L }});
Object.defineProperty(__vite_ssr_exports__, "Logger", { enumerable: true, configurable: true, get(){ return et }});
Object.defineProperty(__vite_ssr_exports__, "MultiWriter", { enumerable: true, configurable: true, get(){ return X }});
Object.defineProperty(__vite_ssr_exports__, "TextFormatter", { enumerable: true, configurable: true, get(){ return A }});
Object.defineProperty(__vite_ssr_exports__, "copyLogger", { enumerable: true, configurable: true, get(){ return N }});
Object.defineProperty(__vite_ssr_exports__, "debug", { enumerable: true, configurable: true, get(){ return U }});
Object.defineProperty(__vite_ssr_exports__, "error", { enumerable: true, configurable: true, get(){ return $ }});
Object.defineProperty(__vite_ssr_exports__, "fatal", { enumerable: true, configurable: true, get(){ return q }});
Object.defineProperty(__vite_ssr_exports__, "getFields", { enumerable: true, configurable: true, get(){ return D }});
Object.defineProperty(__vite_ssr_exports__, "info", { enumerable: true, configurable: true, get(){ return Y }});
Object.defineProperty(__vite_ssr_exports__, "log", { enumerable: true, configurable: true, get(){ return z }});
Object.defineProperty(__vite_ssr_exports__, "newEntry", { enumerable: true, configurable: true, get(){ return M }});
Object.defineProperty(__vite_ssr_exports__, "setField", { enumerable: true, configurable: true, get(){ return G }});
Object.defineProperty(__vite_ssr_exports__, "setFields", { enumerable: true, configurable: true, get(){ return C }});
Object.defineProperty(__vite_ssr_exports__, "setFormatter", { enumerable: true, configurable: true, get(){ return T }});
Object.defineProperty(__vite_ssr_exports__, "setLevel", { enumerable: true, configurable: true, get(){ return _ }});
Object.defineProperty(__vite_ssr_exports__, "setOutput", { enumerable: true, configurable: true, get(){ return W }});
Object.defineProperty(__vite_ssr_exports__, "warn", { enumerable: true, configurable: true, get(){ return B }});
Object.defineProperty(__vite_ssr_exports__, "withField", { enumerable: true, configurable: true, get(){ return R }});
Object.defineProperty(__vite_ssr_exports__, "withFields", { enumerable: true, configurable: true, get(){ return J }});
Object.defineProperty(__vite_ssr_exports__, "writerFunc", { enumerable: true, configurable: true, get(){ return Z }});
That's a lot of minified code, so here are the important parts:
I'm dealing with the ASmallClass
class, which is defined as tt
and looks like this originally:
var tt=w((function t(){d(this,t),this.secret="I am a secret"}))
but from the vitest transformed version looks like this:
var tt=w((function t(){d(this,__vite_ssr_import_0__.getObjectKeys),this.secret="I am a secret"}))
Where d
(the thrower of the error) is:
function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}
Now, at the top of the original file I have:
import{getObjectKeys as t, ...}
So the issue is that t
in the d
call is getting replaced with the imported t
, which then causes d
to the throw the error. My guess is that vitest is incorrectly replacing all t
variables with __vite_ssr_import_0__.getObjectKeys
even though in this case t
should clearly be the locally defined t
function.
How can I fix this issue? Is it possible to disable the module transform? Is it possible to have the module transform work correctly?
Reproduction
It's hard to provide a reproduction because these packages are private and owned by my company.
Steps to reproduce
No response
System Info
System:
OS: macOS 13.3.1
CPU: (10) arm64 Apple M1 Pro
Memory: 70.11 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.11.0 - /opt/homebrew/opt/node@20/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 10.2.4 - /opt/homebrew/opt/node@20/bin/npm
Browsers:
Chrome: 123.0.6312.124
Safari: 16.4
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.