Files
bun.sh/test/bake/dev/import-meta-inline-negative.test.ts
Zack Radisic f4339df16b SSG stuff (#20998)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2025-07-20 22:37:50 -07:00

41 lines
1.2 KiB
TypeScript

import { expect, test } from "bun:test";
import { bunEnv, bunExe, tempDirWithFiles } from "harness";
test("import.meta properties are NOT inlined without bake framework", async () => {
const dir = tempDirWithFiles("import-meta-no-inline", {
"index.ts": `
console.log("dir:", import.meta.dir);
console.log("dirname:", import.meta.dirname);
console.log("file:", import.meta.file);
console.log("path:", import.meta.path);
console.log("url:", import.meta.url);
`,
});
// Run without bundling - should show actual values
await using proc = Bun.spawn({
cmd: [bunExe(), "index.ts"],
env: bunEnv,
cwd: dir,
});
const [stdout, stderr, exitCode] = await Promise.all([
new Response(proc.stdout).text(),
new Response(proc.stderr).text(),
proc.exited,
]);
expect(exitCode).toBe(0);
expect(stderr).toBe("");
// When not bundled, these properties should resolve to actual values
expect(stdout).toContain("dir:");
expect(stdout).toContain("dirname:");
expect(stdout).toContain("file:");
expect(stdout).toContain("path:");
expect(stdout).toContain("url:");
// The values should NOT be inlined - they should be the actual runtime values
expect(stdout).not.toContain("undefined");
});