Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enhance transform and evalModule to support async callbacks #364

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

productdevbook
Copy link

@productdevbook productdevbook commented Feb 10, 2025

close: #363

In some setups like Unimport, we need to modify the source to add imports at the beginning of each content. Since sourceTransformer is empty every time the eval mode transform runs, I store and cache it to reuse later.

Example code:

  const jiti = createJiti(test.options.rootDir, {
    fsCache: false,
    moduleCache: false,
    debug: true,
    alias: test.options.alias,
  })


  const test = await jiti.evalModule(
    injectedResult.code,
    {
      filename: path,
      async: true,
      conditions: test.options.conditions,

    },
    async (data, name) => {
      return (await test.unimport!.injectImports(data, name)).code
    },
  )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unimport support
1 participant