ca7ir
ca7ir2w ago

Bundling for lower targets than ESNext?

Is there a way to change the esbuild target in https://github.com/get-convex/convex-backend/blob/fde777b69781d15c3c67eb2dc61549968f9150b5/npm-packages/convex/src/bundler/debugBundle.ts#L38 ? I've tried using the TS 5.2 dispose functionality and that ends up with an actual using keyword in the bundled code, which then cannot be parsed?
Failed to analyze myFunctions.js: Uncaught SyntaxError: Unexpected identifier 'e'
Failed to analyze myFunctions.js: Uncaught SyntaxError: Unexpected identifier 'e'
const def = () => {
return {
[Symbol.dispose]() {
console.log("disposed");
},
};
};

export const test = action({
args: {},
handler: () => {
using _ = def();
},
});
const def = () => {
return {
[Symbol.dispose]() {
console.log("disposed");
},
};
};

export const test = action({
args: {},
handler: () => {
using _ = def();
},
});
excerpt from myFunctions.js:
var Tr = /* @__PURE__ */ n(() => ({
[Symbol.dispose]() {
console.log("disposed");
}
}), "def"), zs = ke({
args: {},
handler: /* @__PURE__ */ n(() => {
using e = Tr();
}, "handler")
var Tr = /* @__PURE__ */ n(() => ({
[Symbol.dispose]() {
console.log("disposed");
}
}), "def"), zs = ke({
args: {},
handler: /* @__PURE__ */ n(() => {
using e = Tr();
}, "handler")
I hardcoded the target to es2020 (locally in the convex cli in node_modules) and re-bundled & pushed the function which.. "worked", though wondering if there's an 'easy'/intended option to do that. with es2020:
var un = /* @__PURE__ */ n(() => ({
[Symbol.dispose]() {
console.log("disposed");
}
}), "def"), $i = xt({
args: {},
handler: /* @__PURE__ */ n(() => {
var e = [];
try {
let t = At(e, un());
} catch (r) {
var o = r, s = !0;
} finally {
Et(e, o, s);
}
}, "handler")
var un = /* @__PURE__ */ n(() => ({
[Symbol.dispose]() {
console.log("disposed");
}
}), "def"), $i = xt({
args: {},
handler: /* @__PURE__ */ n(() => {
var e = [];
try {
let t = At(e, un());
} catch (r) {
var o = r, s = !0;
} finally {
Et(e, o, s);
}
}, "handler")
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?