我有一个问题,你如何通过提供模块的名称,而不是npm生态系统中的模块那样的路径,使你的定制模块在你的项目中成为全局帐户并导入它
import CustomModule from "custom-modules";
我有一个问题,你如何通过提供模块的名称,而不是npm生态系统中的模块那样的路径,使你的定制模块在你的项目中成为全局帐户并导入它
import CustomModule from "custom-modules";
我找了一会儿才找到答案.你必须在包装中添加出口商品.json,以便将它们与包中提供的名称或路径一起使用.json.例如
{
"name": "my-mod",
"exports": {
".": "./lib/index.js",
"./lib": "./lib/index.js",
"./lib/index": "./lib/index.js",
"./lib/index.js": "./lib/index.js",
"./feature": "./feature/index.js",
"./feature/index.js": "./feature/index.js",
"./package.json": "./package.json"
}
}
你可以点击Here查看更多细节