nitro icon indicating copy to clipboard operation
nitro copied to clipboard

auto-import dirs need to pass source directory

Open danielroe opened this issue 3 years ago • 1 comments

Environment

latest stackblitz

Reproduction

https://stackblitz.com/edit/github-cwdzfl-mboy5z

Describe the bug

Everything else is resolved relative to srcDir but we need to add this to any auto-imports directories explicitly. It's actually resolved relative to process.cwd which is not ideal:

https://github.com/unjs/unimport/blob/aa5a354f918707368e82f8f54a5836c2d7d4d7fb/src/scan-dirs.ts#L20

Would be nice to pass srcDir through from nitro and respect it in unimport plugin options:

https://github.com/unjs/unimport/blob/0dd6b1a0962875e875bac9278b7b0c88236b2d22/src/unplugin.ts#L54-L56

wdyt @pi0, @antfu?

Additional context

No response

Logs

No response

danielroe avatar Aug 29 '22 11:08 danielroe

A generic way to pass global cwd option would be nice (cwd in unjs packages like c12 and unimport is equal to srcDir). I think we could solve it before hand by explicitly passing it from nitro presets as normalized option.

pi0 avatar Aug 29 '22 11:08 pi0