fix(plugin/twind): load configuration as module (#705)
This commit loads the Twind configuration as an actual module rather than evaluating it on the server and then serializing. This allows usage of unserializable plugin functions. Co-authored-by: Elias Sjögreen <eliassjogreen1@gmail.com>
This commit is contained in:
co-authored by
Elias Sjögreen
parent
8e9658cae5
commit
1b3c9f2569
+7
-2
@@ -7,9 +7,14 @@ export type { Options };
|
||||
export default function twind(options: Options): Plugin {
|
||||
const sheet = virtualSheet();
|
||||
setup(options, sheet);
|
||||
const main = `data:application/javascript,import hydrate from "${
|
||||
new URL("./twind/main.ts", import.meta.url).href
|
||||
}";
|
||||
import options from "${options.selfURL}";
|
||||
export default function(state) { hydrate(options, state); }`;
|
||||
return {
|
||||
name: "twind",
|
||||
entrypoints: { "main": new URL("./twind/main.ts", import.meta.url).href },
|
||||
entrypoints: { "main": main },
|
||||
render(ctx) {
|
||||
sheet.reset(undefined);
|
||||
const res = ctx.render();
|
||||
@@ -28,7 +33,7 @@ export default function twind(options: Options): Plugin {
|
||||
mappings.push([key, value]);
|
||||
}
|
||||
}
|
||||
const state = [options, precedences, mappings];
|
||||
const state = [precedences, mappings];
|
||||
scripts.push({ entrypoint: "main", state });
|
||||
}
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user