Skip to content

alias glob is not working as expected #395

@zrosenbauer

Description

@zrosenbauer

Environment

TypeScript & Node.js

Reproduction

source code: https://github.com/zrosenbauer/viteval/blob/main/packages/cli/src/commands/data/command.ts

Describe the bug

I'm unable to have the globs recognized in the alias. I think this is due to the underlying pathe library not supporting glob.

I tested this directly in the jiti codebase by adding a new test & fixture.

Here is example of what SHOULD work:

import { defineDataset } from 'viteval/dataset';
import testData from '#/data';

export default defineDataset({
  name: 'example',
  data: async () => {
    console.log('TEST DATA', testData);
    return [
      {
        input: 'Generate a random number between 0 and 100',
        expected: 1,
        ...testData,
      },
      {
        input: 'Generate a random number between 0 and 100',
        expected: 2,
      },
      {
        input: 'Generate a random number between 0 and 100',
        expected: 3,
      },
    ];
  },
});
    const jiti = createJiti(`file:${path.dirname(configFilePath)}`, {
      fsCache: false,
      moduleCache: false,
      interopDefault: true,
      sourceMaps: true,
      alias: {
        "#/*": "./src/*"        
      },
      // tryNative: true,
      transformOptions: {
        // retainLines: true,
        // filename: '',
        ts: true,
      },
    });

It does work (sort of) if I remove the glob. I'll probably open a PR in my lib to hack/fix while this is being resolved.

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions