fix(form): import of validator causes error if not installed

This commit is contained in:
Ayo 2022-10-23 23:23:23 +02:00
parent 66ba7fa292
commit 715eaaa408
3 changed files with 11 additions and 4 deletions

8
package-lock.json generated
View file

@ -10478,8 +10478,11 @@
}, },
"packages/form": { "packages/form": {
"name": "@astro-reactive/form", "name": "@astro-reactive/form",
"version": "0.4.6", "version": "0.5.0",
"license": "MIT", "license": "MIT",
"dependencies": {
"@astro-reactive/validator": "^0.1.0"
},
"devDependencies": { "devDependencies": {
"@types/chai": "^4.3.3", "@types/chai": "^4.3.3",
"@types/eslint": "^8.4.6", "@types/eslint": "^8.4.6",
@ -10513,7 +10516,7 @@
}, },
"packages/validator": { "packages/validator": {
"name": "@astro-reactive/validator", "name": "@astro-reactive/validator",
"version": "0.0.5", "version": "0.1.0",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@types/chai": "^4.3.3", "@types/chai": "^4.3.3",
@ -10732,6 +10735,7 @@
"@astro-reactive/form": { "@astro-reactive/form": {
"version": "file:packages/form", "version": "file:packages/form",
"requires": { "requires": {
"@astro-reactive/validator": "^0.1.0",
"@types/chai": "^4.3.3", "@types/chai": "^4.3.3",
"@types/eslint": "^8.4.6", "@types/eslint": "^8.4.6",
"@types/mocha": "^10.0.0", "@types/mocha": "^10.0.0",

View file

@ -51,7 +51,7 @@ export class FormControl {
this._placeholder = placeholder; this._placeholder = placeholder;
this._validators = validators; this._validators = validators;
// dynamic import of the validator package // TODO: implement independence, form should not import validator
import('@astro-reactive/validator').then((validator) => { import('@astro-reactive/validator').then((validator) => {
if (validator) { if (validator) {
this.validate = validator.validate; this.validate = validator.validate;

View file

@ -54,5 +54,8 @@
"peerDependencies": { "peerDependencies": {
"astro": "^1.5.0" "astro": "^1.5.0"
}, },
"license": "MIT" "license": "MIT",
"dependencies": {
"@astro-reactive/validator": "^0.1.0"
}
} }