solid-start icon indicating copy to clipboard operation
solid-start copied to clipboard

[Bug?]: unplugin-macros doesn't work

Open huseeiin opened this issue 5 months ago • 3 comments

Duplicates

  • [x] I have searched the existing issues

Latest version

  • [x] I have tested the latest version

Current behavior 😯

lib/test.ts:

export function getRandom() {
  return Math.random();
}

export const buildTime = Date.now();

routes/test.ts:

import { buildTime, getRandom } from "../lib/test.ts" with { type: "macro" };

export function GET() {
  return getRandom();
}

console.log(buildTime);

when you go to /test you'll see a different value every time.

Expected behavior 🤔

its supposed to be the same value every time, since its a macro.

config:

import Macros from "unplugin-macros/vite";
import { defineConfig } from "@solidjs/start/config";

export default defineConfig({
  vite: {
    plugins: [Macros()],
  },
});

Steps to reproduce 🕹

i couldn't reproduce in vinxi. this bug is only in solidstart.

Context 🔦

No response

Your environment 🌎


huseeiin avatar Jul 10 '25 12:07 huseeiin