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

Figure out a way to have a virtual module import another virtual module #29

Closed
NullVoxPopuli opened this issue Feb 25, 2024 · 1 comment

Comments

@NullVoxPopuli
Copy link
Contributor

NullVoxPopuli commented Feb 25, 2024

Right now, folks have to do this in their apps:

await this.docs.setup({
  apiDocs: await import('kolay/api-docs:virtual'),
  manifest: await import('kolay/manifest:virtual'),
  resolve: {
    'my-library': await import('my-library'),
    'something-else': await import('something-else'),
  },
});

This isn't great because:

  • it's a bit of ceramony
  • two imports instead of one
  • two minimum properties, ideal would be 0 (resolve is optional)
previously issues that are now non issues

If we can shorten this down to a single import, the whole thing could be:

import { setupKolay } from 'kolay/setup'; // a virtual module

// ...
const manifest = await setupKolay({
  resolve: {
    'my-library': await import('my-library'),
    'something-else': await import('something-else'),
  },
});

which, I think, makes more sense, and kolay/setup is easy to provide type definitions for.

But, so far, a virtual module cannot import another virtual module, because plugins' resolve hooks are only used when resolving from the consuming app and a virtual module is kind of in a void of its own.

@NullVoxPopuli
Copy link
Contributor Author

Potentially possible after: unjs/unplugin#374

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

No branches or pull requests

1 participant