Closed m-shaka closed 1 year ago
Thanks for the suggestion!
I understand your use case and am in favor of the proposed change. Maybe selfReferencingLookhole
could have true as the default value.
Thank you! Please let me know if there's anything I can help with.
I have a feeling that testing is a bit difficult because it depends on package.json of this plugin itself 🤔
You can add the exports
field to package.json, but it may have an impact on the users
Released in v2.1.0 🎁
I changed the name to treatSelfReferenceAs
which takes internal
and external
.
The default value is external
where self referencing is treated as if external import so you can import without restrictions.
As this concerns the API design of this plugin, I will start from this proposal. As a new feature, I would like to add selfReferencingLoophole via the
exports
field in the package.json.Let me explain in details with a specific use case. In the component library I am currently developing, I am writing Storybook stories only for the public API. In the package.json, I have specified the exports as follows, and I use them in Storybook like
import { SomeComponent } from 'my-library/components'
. (This is called as self-referencing in the Node.js document)Currently, I have to manually add the
@public
comment tag to all the members exported from src/components/index.ts. This is because I have set thedefaultImportability
to'package'
, and I place story files in a'stories'
directory which is a sibling directory of'src'
.However, since
src/components/index.ts
is intended as the public API, the task of adding comment tags feels excessively cumbersome. It would be greatly appreciated if, as an option, we could have self-referencing automatically treated as public.