Skip to content

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

Description

@huseeiin

Duplicates

  • I have searched the existing issues

Latest version

  • 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 🌎

Metadata

Metadata

Assignees

No one assigned

    Labels

    Start 1.xStart 2.xtargeting SolidStart 2.x versionsbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions