admin管理员组文章数量:1391969
I'm currently authoring a React project as well as an npm package that will be used by this project. My use-case of integrating the two includes providing a path to a React component in this project (e.g src/components/Comp1/Comp1_1.tsx
) and for the npm package to resolve that path and import that component.
Is that something that's possible? Or do npm packages can't have context of the modules/files you have authored in your project folder?
So if i have a React component residing in src/components/Comp1/Comp1_1.tsx
, i want my npm package to import it and return a new component based on it.
E.g, in my React project:
import plugin from 'my-library';
return (
<plugin path="src/components/Comp1/Comp1_1.tsx" />
)
Then, the implementation of plugin
is as follows:
const Comp1_1 = `React.lazy(() => import(${path})`
return (
<div>
<Comp1_1 />
</div>
)
Would that be possible for plugin
to resolve that Comp1_1
import?
本文标签:
版权声明:本文标题:javascript - Can you provide a project module import path to be resolved in a consumed npm library? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744775080a2624575.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论