aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/transpiler.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'integration/bunjs-only-snippets/transpiler.test.js')
-rw-r--r--integration/bunjs-only-snippets/transpiler.test.js40
1 files changed, 37 insertions, 3 deletions
diff --git a/integration/bunjs-only-snippets/transpiler.test.js b/integration/bunjs-only-snippets/transpiler.test.js
index 34ec9f4aa..16956abfe 100644
--- a/integration/bunjs-only-snippets/transpiler.test.js
+++ b/integration/bunjs-only-snippets/transpiler.test.js
@@ -6,6 +6,11 @@ describe("Bun.Transpiler", () => {
define: {
"process.env.NODE_ENV": JSON.stringify("development"),
},
+ macro: {
+ react: {
+ bacon: `${import.meta.dir}/macro-check.js`,
+ },
+ },
platform: "browser",
});
@@ -56,7 +61,7 @@ describe("Bun.Transpiler", () => {
import {keepSecondArgument} from 'macro:${
import.meta.dir
}/macro-check.js';
-
+
export default keepSecondArgument("Test failed", "Test passed");
`);
expect(out.includes("Test failed")).toBe(false);
@@ -66,12 +71,12 @@ describe("Bun.Transpiler", () => {
expect(out.includes("keepSecondArgument")).toBe(false);
});
- it("sync supports macros", async () => {
+ it("sync supports macros", () => {
const out = transpiler.transformSync(`
import {keepSecondArgument} from 'macro:${
import.meta.dir
}/macro-check.js';
-
+
export default keepSecondArgument("Test failed", "Test passed");
`);
expect(out.includes("Test failed")).toBe(false);
@@ -80,6 +85,35 @@ describe("Bun.Transpiler", () => {
expect(out.includes("keepSecondArgument")).toBe(false);
});
+ it("sync supports macros remap", () => {
+ const out = transpiler.transformSync(`
+ import {createElement, bacon} from 'react';
+
+ export default bacon("Test failed", "Test passed");
+ export function hi() { createElement("hi"); }
+ `);
+
+ expect(out.includes("Test failed")).toBe(false);
+ expect(out.includes("Test passed")).toBe(true);
+
+ expect(out.includes("bacon")).toBe(false);
+ expect(out.includes("createElement")).toBe(true);
+ });
+
+ it("macro remap removes import statement if its the only used one", () => {
+ const out = transpiler.transformSync(`
+ import {bacon} from 'react';
+
+ export default bacon("Test failed", "Test passed");
+ `);
+
+ expect(out.includes("Test failed")).toBe(false);
+ expect(out.includes("Test passed")).toBe(true);
+
+ expect(out.includes("bacon")).toBe(false);
+ expect(out.includes("import")).toBe(false);
+ });
+
it("removes types", () => {
expect(code.includes("ActionFunction")).toBe(true);
expect(code.includes("LoaderFunction")).toBe(true);