Skip to content

Avoid data duplication #130

@cany748

Description

@cany748

Clear and concise description of the problem

If we return a lot of data from a macro (for example, due to the use of fetch) and use it in different ones, then the data will constantly be duplicated.

Now I have to use two files to avoid duplication of data. Example:

/* src/config/data.ts */
import { data as $data, data2 as $data2 } from "../macros/data" with { type: "macro" };

export const data = $data;
export const data2 = $data2;
/* src/macros/data.ts */
import { $fetch } from "ofetch";

const { data, data2 } = await $fetch("https://example.app/items/");

export { data, data2 };

Suggested solution

It is possible to create a virtual module instead of directly replacing data in the AST in certain scenarios. For example, if the macro does not return functions

Alternative

I will be happy to consider any alternative solutions to my problem.

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions