Skip to content

Commit

Permalink
feat(package): implement Angular Package format
Browse files Browse the repository at this point in the history
This allows for better support of various lib consumers (including Ivy use case)

BREAKING CHANGE:
* `ng-recaptcha/forms` entry point has been removed. `RecaptchaFormsModule` and `RecaptchaValueAccessorDirective` should now be imported directly from `ng-recaptcha`
* `tslib` is now a package dependency to ensure minimum possible bundle size. If your project doesn't yet have a dependency on `tslib`, run `npm install -D tslib@^1.9.0` (or `yarn add -D tslib@^1.9.0` if you use yarn)
  • Loading branch information
DethAriel committed Jun 4, 2019
1 parent a270b04 commit 71340c4
Show file tree
Hide file tree
Showing 12 changed files with 2,178 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.DS_Store

# compiled sources
/dist
/*.js
/*.d.ts
/recaptcha/**/*.js
Expand Down
4 changes: 4 additions & 0 deletions demo-all/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"scripts": {
"serve": "http-server ./dist -a localhost -p 9000 -c-1",
"generate": "ts-node index.ts",
"clean:v6": "cd v6 && yarn clean",
"clean:v7": "cd v7 && yarn clean",
"clean:v8": "cd v8 && yarn clean",
"clean:all": "yarn clean:v6 && yarn clean:v7 && yarn clean:v8",
"install:v6": "cd v6 && yarn latest",
"install:v7": "cd v7 && yarn latest",
"install:v8": "cd v8 && yarn latest",
Expand Down
3 changes: 1 addition & 2 deletions demo-all/v-all/src/app/examples/forms/forms-demo.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';

import { RecaptchaModule } from 'ng-recaptcha';
import { RecaptchaFormsModule } from 'ng-recaptcha/forms';
import { RecaptchaFormsModule, RecaptchaModule } from 'ng-recaptcha';

import { PAGE_SETTINGS } from '../../demo-wrapper/demo-wrapper.component';
import { DemoWrapperModule } from '../../demo-wrapper/demo-wrapper.module';
Expand Down
4 changes: 3 additions & 1 deletion demo-all/v6/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3996,7 +3996,9 @@ next-tick@^1.0.0:
ng-recaptcha@../../ng-recaptcha-latest.tgz:
version "4.3.0-beta.1"
resolved "../../ng-recaptcha-latest.tgz#ea657bc417100a8f8a4161cdc9ac8fac5d06dfbb79582231dc49406580197289dc83f2466e8dd5845ade0b41842124be6c9c87a9a912dace5d7be69f622e6011"
integrity sha1-e7jOG8zXemUzgqFKvpSQpeGkIuI=
integrity sha1-i7fxsPv9o+OBxFS4EPPgzDQpepg=
dependencies:
tslib "^1.9.0"
optionalDependencies:
"@types/grecaptcha" "^2.0.33"

Expand Down
4 changes: 3 additions & 1 deletion demo-all/v7/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3812,7 +3812,9 @@ neo-async@^2.5.0:
ng-recaptcha@../../ng-recaptcha-latest.tgz:
version "4.3.0-beta.1"
resolved "../../ng-recaptcha-latest.tgz#ea657bc417100a8f8a4161cdc9ac8fac5d06dfbb79582231dc49406580197289dc83f2466e8dd5845ade0b41842124be6c9c87a9a912dace5d7be69f622e6011"
integrity sha1-e7jOG8zXemUzgqFKvpSQpeGkIuI=
integrity sha1-i7fxsPv9o+OBxFS4EPPgzDQpepg=
dependencies:
tslib "^1.9.0"
optionalDependencies:
"@types/grecaptcha" "^2.0.33"

Expand Down
4 changes: 3 additions & 1 deletion demo-all/v8/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3890,7 +3890,9 @@ neo-async@^2.5.0:
ng-recaptcha@../../ng-recaptcha-latest.tgz:
version "4.3.0-beta.1"
resolved "../../ng-recaptcha-latest.tgz#ea657bc417100a8f8a4161cdc9ac8fac5d06dfbb79582231dc49406580197289dc83f2466e8dd5845ade0b41842124be6c9c87a9a912dace5d7be69f622e6011"
integrity sha1-e7jOG8zXemUzgqFKvpSQpeGkIuI=
integrity sha1-i7fxsPv9o+OBxFS4EPPgzDQpepg=
dependencies:
tslib "^1.9.0"
optionalDependencies:
"@types/grecaptcha" "^2.0.33"

Expand Down
2 changes: 0 additions & 2 deletions forms.ts

This file was deleted.

3 changes: 3 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ export { RECAPTCHA_SETTINGS, RecaptchaSettings } from './recaptcha/recaptcha-set

export { RecaptchaV3Module } from './recaptcha/recaptcha-v3.module';
export { OnExecuteData, ReCaptchaV3Service, RECAPTCHA_V3_SITE_KEY } from './recaptcha/recaptcha-v3.service';

export { RecaptchaFormsModule } from './recaptcha/recaptcha-forms.module';
export { RecaptchaValueAccessorDirective } from './recaptcha/recaptcha-value-accessor.directive';
16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
"description": "Angular component for Google reCAPTCHA",
"scripts": {
"demo": "yarn demo:serve",
"demo:clean": "cd demo-all && yarn clean:all",
"demo:serve": "cd demo && yarn start",
"demo:build": "cd demo && yarn build",
"demo:publish": "yarn demo:publish-gh-pages",
"demo:publish-gh-pages": "gh-pages -d demo/dist/ng-recaptcha",
"pack-latest": "yarn clean && yarn transpile && mv \"$(npm pack)\" ng-recaptcha-latest.tgz",
"transpile": "ngc -p ./tsconfig.json",
"clean": "del-cli './{recaptcha/,index,forms}*.{js,d.ts,js.map,metadata.json}' 'ng-recaptcha-*.tgz'",
"pack-latest": "yarn clean && yarn transpile && cd dist && mv \"$(npm pack)\" ../ng-recaptcha-latest.tgz",
"transpile": "ng-packagr -p ./tsconfig.json",
"clean": "del-cli 'ng-recaptcha-*.tgz' && yarn demo:clean",
"changelog": "conventional-changelog --preset angular --infile CHANGELOG.md --same-file",
"github-release": "conventional-github-releaser --preset angular",
"prepare-release": "npm whoami && yarn build && npm version $1",
Expand All @@ -35,9 +36,17 @@
],
"author": "Ruslan Arkhipau <[email protected]>",
"license": "MIT",
"ngPackage": {
"lib": {
"entryFile": "index.ts"
}
},
"optionalDependencies": {
"@types/grecaptcha": "^2.0.33"
},
"dependencies": {
"tslib": "^1.9.0"
},
"peerDependencies": {
"@angular/core": "^6.0.0 || ^7.0.0 || ^8.0.0"
},
Expand All @@ -56,6 +65,7 @@
"del-cli": "^0.2.1",
"gh-pages": "^0.12.0",
"husky": "^0.13.3",
"ng-packagr": "^5.2.0",
"npm-run-all": "^4.1.2",
"rxjs": "^6.1.0",
"tslint": "~5.7.0",
Expand Down
8 changes: 6 additions & 2 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"lib": [ "es2015", "dom" ],
"stripInternal": true
"lib": [
"es2015",
"dom"
],
"stripInternal": true,
"skipLibCheck": true,
}
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "./tsconfig.base.json",
"exclude": [
"node_modules",
"dist",
"demo-all",
"demo",
"demo-v7",
Expand Down
Loading

0 comments on commit 71340c4

Please sign in to comment.