Some relevant background I think - https://stackoverflow.com/questions/51860043/javascript-es6-typeerror-class-constructor-client-cannot-be-invoked-without-ne
I just upgraded esbuild and servie and noticed this.
Uncaught TypeError: Class constructor Response2 cannot be invoked without 'new'
at new XhrResponse2 (xhr.js:52)
at XMLHttpRequest.ondone (xhr.js:150)
import {
Response,
} from "servie/dist/browser";
export class XhrResponse extends Response implements XhrResponseOptions {
url: string;
constructor(body: CreateBody, options: XhrResponseOptions) {
super(body, options);
this.url = options.url;
}
}
function ondone() {
const res = new XhrResponse(
type === "text" ? xhr.responseText : xhr.response,
{
status: xhr.status === 1223 ? 204 : xhr.status,
statusText: xhr.statusText,
headers: parseXhrHeaders(xhr.getAllResponseHeaders()),
omitDefaultHeaders: true,
url: xhr.responseURL,
}
);
req.signal.emit("responseStarted");
req.signal.emit("responseEnded");
return resolve(res);
}
md5-2b0884dd52b113d322af13cc6413ad86
var XhrResponse = /** @class */ (function (_super) {
__extends(XhrResponse, _super);
function XhrResponse(body, options) {
var _this = _super.call(this, body, options) || this;
_this.url = options.url;
return _this;
}
return XhrResponse;
}(browser_1.Response));
exports.XhrResponse = XhrResponse;
function ondone() {
var res = new XhrResponse(type === "text" ? xhr.responseText : xhr.response, {
status: xhr.status === 1223 ? 204 : xhr.status,
statusText: xhr.statusText,
headers: parseXhrHeaders(xhr.getAllResponseHeaders()),
omitDefaultHeaders: true,
url: xhr.responseURL,
});
req.signal.emit("responseStarted");
req.signal.emit("responseEnded");
return resolve(res);
}
Sorry, I don't understand. It sounds like you're having trouble with some classes that are compiled from ES6 to ES5. But esbuild doesn't support compiling to ES5, so this doesn't sound like a problem with esbuild. I also looked at the latest distributed code for servie and it looks like they are ES6 classes that are not transpiled to ES5.
Are you post-processing the output of esbuild into ES5 with another tool? Or are you pre-processing the input to esbuild into ES5 with another tool?
I'm going to close this since it doesn't seem like a bug in esbuild (as described above). Feel free to provide more information if you believe otherwise.
Most helpful comment
Sorry, I don't understand. It sounds like you're having trouble with some classes that are compiled from ES6 to ES5. But esbuild doesn't support compiling to ES5, so this doesn't sound like a problem with esbuild. I also looked at the latest distributed code for servie and it looks like they are ES6 classes that are not transpiled to ES5.
Are you post-processing the output of esbuild into ES5 with another tool? Or are you pre-processing the input to esbuild into ES5 with another tool?