#use plugin with macro

1 messages · Page 1 of 1 (latest)

frozen kettle
#

I met an issue where plugin is not loaded(no effect) when building with macros.

The plugin register

build.onLoad({filter: /\.email.svelte$/})
build.onResolve({filter:/\.email.svelte&email$/})

bunfig.toml

preload = ["./src/loadPlugin.ts"]

loadPlugin.ts

console.log("loading")

plugin(svelteEmailBunPlugin)

code

import * as Email from "./Test.email.svelte&email"

import {render} from "svelte/server";


export function prerender() {
    const r = render(Email.default, {
        props: {
            name: "world",
            message: "hello"
        }
    })

    return r.body //  r.css
}
import {prerender} from "./prerenderTest.ts" with {type: "macro"}
console.log(prerender())

Bun throws error

Error importing macro
error: Cannot find module "./Test.email.svelte&email"

It looks like plugin is not taking effect while build with macro.
The code works fine without with {type: "macro"}, however I'd like to have the email string at build time instead of runtime.

hollow mauve
#

but macro is a build time thing

#

so you need to use plugins at build time

#

but this is likely a bug

frozen kettle
hollow mauve
frozen kettle
#

maybe the plugin is not loaded during macro build time?

hollow mauve
frozen kettle
hollow mauve
frozen kettle
hollow mauve
#

so basically the plugin get loaded after the macro

hollow mauve
frozen kettle
#

with macro doesn't work

hollow mauve
#

¯_(ツ)_/¯

frozen kettle
#

But the plugin is loaded before the build

#

I added everywhere, preload, before Bun.build, the plugins array

#

Is this expected behavior or bug?

hollow mauve
#

¯_(ツ)_/¯

hollow mauve
frozen kettle
#

So I just can't do that?