Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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