使用Angular6创建节点模块应该很容易。 Documentation告诉您这些步骤:
ng generate library YOUR-LIBRARY
ng build YOUR-LIBRARY --prod
cd dist/YOUR-LIBRARY && npm publish
例如,这将在angular.json
内添加一个新项目,在/projects
内创建一个新目录,然后将您的包编译/转换为/dist/YOUR-LIBRARY
。太好了,但是我找不到在package.json
目录中指定导出的dist
的配置方法。
我尝试在package.json
内修改/projects
,但对分布式package.json
没有任何影响。
总看起来像:
{
"name": "YOUR-LIBRARY",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^6.0.0-rc.0 || ^6.0.0",
"@angular/core": "^6.0.0-rc.0 || ^6.0.0"
},
"main": "bundles/nls-guilloche.umd.js",
"module": "fesm5/nls-guilloche.js",
"es2015": "fesm2015/nls-guilloche.js",
"esm5": "esm5/nls-guilloche.js",
"esm2015": "esm2015/nls-guilloche.js",
"fesm5": "fesm5/nls-guilloche.js",
"fesm2015": "fesm2015/nls-guilloche.js",
"typings": "nls-guilloche.d.ts",
"metadata": "nls-guilloche.metadata.json",
"sideEffects": false,
"dependencies": {
"tslib": "^1.9.0"
}
}
我什至不能更改版本标签或添加任何信息。当然,手动操作会起作用,但这不是解决方案,可以吗?
答案 0 :(得分:2)
从 Angular 12.x 开始,每个库都有一个 Train score: [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0.]
生成,该文件是复制到输出目录中的文件(在您的情况下为 package.json
)。
它在生成时看起来像这样:
dist/