aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/bun.js/transpiler.test.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/bun.js/transpiler.test.js b/test/bun.js/transpiler.test.js
index 83d30f3b1..76356d90f 100644
--- a/test/bun.js/transpiler.test.js
+++ b/test/bun.js/transpiler.test.js
@@ -995,6 +995,14 @@ export var ComponentThatHasSpreadCausesDeopt = jsx(Hello, {
});
it("macros can return a Response body", () => {
+ // "promiseReturningCtx" is this:
+ // export function promiseReturningCtx(expr, ctx) {
+ // return new Promise((resolve, reject) => {
+ // setTimeout(() => {
+ // resolve(ctx);
+ // }, 1);
+ // });
+ // }
var object = Response.json({ hello: "world" });
const input = `
@@ -1014,6 +1022,34 @@ export function foo() {
expect(bunTranspiler.transformSync(input, object).trim()).toBe(output);
});
+ it("macros get dead code eliminated", () => {
+ var object = Response.json({
+ big: {
+ object: {
+ beep: "boop",
+ huge: 123,
+ },
+ blobby: {
+ beep: "boop",
+ huge: 123,
+ },
+ },
+ dead: "hello world!",
+ });
+
+ const input = `
+import {promiseReturningCtx} from 'inline';
+
+export const {dead} = promiseReturningCtx();
+`.trim();
+
+ const output = `
+export const { dead } = { dead: "hello world!" };
+`.trim();
+
+ expect(bunTranspiler.transformSync(input, object).trim()).toBe(output);
+ });
+
it("rewrite string to length", () => {
expectPrinted_(
`export const foo = "a".length + "b".length;`,