1.0.2 • Published 8 years ago
ra-wtf v1.0.2
Creating and publishing an Angular package
Extract your module to ./lib/[packageName]/src folder,
Create a ./lib/[packageName]/public_api.ts file
export * from "./src/moduleName.module;Create lib/[packageName]/package.json file
{
"name": "moduleNAme",
"version": "1.0.0",
"license": "MIT",
"private": false,
"author": {
"name": "name",
"email": "email"
},
"description": "description",
"repository": {
"type": "git",
"url": "github repo url"
},
"peerDependencies": {
"@angular/core": "^5.2.0"
}
}Create lib/[packageName]/ng-package.json file
{
"$schema": "./../../node_modules/ng-packagr/ng-package.schema.json",
"lib": {
"entryFile": "public_api.ts"
}
}Create a lib/[packageName]/readme.md file
Add scripts to ./package.json
"pack": "ng-packagr -p lib/[packageName]/ng-package.json""publish": "npm publish lib/[packageName]/dist"
Testing
- Insert the following code snippet to
src/test.ts
const contextLib = require.context('./../lib/', true, /\.spec\.ts$/);
contextLib.keys().map(contextLib);- Modify
src/tsconfig.spec.jsonas follows
"include": [
"**/*.spec.ts",
"**/*.d.ts",
"./../lib/**/*.spec.ts",
"./../lib/**/*.d.ts"
]To create and publish:
ng test- update the version number
npm run packnpm run publish