unjs/unimport

Support import `dirs` within core

pi0 opened this issue · 2 comments

pi0 commented

Describe the feature

While working on unjs/nitro#866 i noticed that dirs option is only supported for unimport plugin but not unimport core and for generating types, it should be manually integrated with scanDirExports and modifyDynamicImports (there might be better ways no ideas).

it would be nice if we support it built-in to avoid workaround.

Reproduction: https://stackblitz.com/edit/node-x74ruz?file=index.mjs,utils%2Ftest.ts

(PS: Small unrelated bug i found generateTypeDeclarations is not stripping .ts from paths resulting into ts issues)

Additional information

  • Would you be willing to help implement this feature?
antfu commented

Small unrelated bug i found generateTypeDeclarations is not stripping .ts from paths resulting into ts issues

Can you share some examples? It seems to work for me:

const localA: typeof import('<root>/playground/composables/index')['localA']
const localBAlias: typeof import('<root>/playground/composables/index')['localBAlias']
const multiplier: typeof import('<root>/playground/composables/index')['multiplier']
const nested: typeof import('<root>/playground/composables/nested/index')['default']

pi0 commented

Thanks for the feat 🚀

Can you share some examples?

Right seems working now on stackblitz. It was strangely happening on nitro will recheck and ping you if happened again.