diff --git a/README.md b/README.md index 5226a70..58e7e57 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ Another issue is that of form validation. As a fan of functional programming, I Many modern applications need to be internationalized, and this can be an issue in form libraries. I18n has been considered from the start in the design of the API, with the aim of seamless integration with existing solutions. +In modern JavaScript development bundle size is always a concern - currently form-and-function weights in at just 3.54KB gzipped (14.87KB uncompressed). + ## Examples There are several examples in the `demo` folder of this repository. They can be run locally by cloning this repository, installing dependencies and running `yarn start`. If anything is unclear then raise an issue, or tweet me @bigalreturns diff --git a/package.json b/package.json index faed9e1..29761ed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "form-and-function", - "version": "0.0.3", + "version": "0.1.0", "main": "dist/form-and-function.cjs.js", "module": "dist/form-and-function.esm.js", "browser": "dist/form-and-function.umd.js", @@ -25,6 +25,7 @@ "rimraf": "^2.6.2", "rollup": "^0.55.0", "rollup-plugin-typescript": "^0.8.1", + "rollup-plugin-uglify": "^3.0.0", "semantic-ui-css": "^2.2.12", "semantic-ui-react": "^0.77.2", "typescript": "^2.8.2" @@ -37,8 +38,7 @@ "build-demo": "react-scripts-ts build", "test": "react-scripts-ts test --env=jsdom", "eject": "react-scripts-ts eject", - "remove-rollup-ts": - "rimraf node_modules/rollup-plugin-typescript/node_modules/typescript", + "remove-rollup-ts": "rimraf node_modules/rollup-plugin-typescript/node_modules/typescript", "prepublish": "yarn build" } } diff --git a/rollup.config.js b/rollup.config.js index 0feea7c..78aa11c 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,6 +1,7 @@ import pkg from "./package.json"; import typescript from "rollup-plugin-typescript"; import ts from "typescript"; +import uglify from "rollup-plugin-uglify"; export default [ { @@ -18,8 +19,11 @@ export default [ } } ], - plugins: typescript({ - typescript: ts - }) + plugins: [ + typescript({ + typescript: ts + }), + uglify() + ] } ]; diff --git a/src/lib/Field.tsx b/src/lib/Field.tsx index 06ce2a0..245a7d8 100644 --- a/src/lib/Field.tsx +++ b/src/lib/Field.tsx @@ -2,7 +2,7 @@ import * as React from "react"; import { EventHandler, SyntheticEvent } from "react"; import { FormState } from "./Form"; import { StateEngine } from "./stateEngine"; -import { FieldResult, isInvalidResult } from "./validation"; +import { FieldResult, isInvalidResult } from "./validation/index"; import { FieldValue } from "./Form"; /** diff --git a/src/lib/Form.tsx b/src/lib/Form.tsx index 5e5bae5..9c711c2 100644 --- a/src/lib/Form.tsx +++ b/src/lib/Form.tsx @@ -9,10 +9,9 @@ import { isInvalidResult, Validator, isCovalidateResult, - invalidFn, CovalidatedFieldResult, InvalidFieldResult -} from "./validation"; +} from "./validation/index"; export type FieldValue = string | boolean | number; diff --git a/src/lib/index.ts b/src/lib/index.ts index cfbf945..9369a40 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -1,4 +1,4 @@ -import * as validation from "./validation"; +import * as validation from "./validation/index"; export * from "./Field"; export * from "./Form"; diff --git a/src/lib/tsconfig.build.json b/src/lib/tsconfig.build.json index ad74d89..ccc54b5 100644 --- a/src/lib/tsconfig.build.json +++ b/src/lib/tsconfig.build.json @@ -1,7 +1,7 @@ { "compilerOptions": { "outDir": "../../dist/modules", - "module": "es2015", + "module": "esnext", "target": "es5", "lib": ["es2017", "dom"], "sourceMap": true, @@ -14,7 +14,6 @@ "noImplicitAny": true, "strictNullChecks": true, "suppressImplicitAnyIndexErrors": true, - "noUnusedLocals": true, "declaration": true }, "exclude": [ diff --git a/yarn.lock b/yarn.lock index 8a2409f..2afe686 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4847,6 +4847,12 @@ rollup-plugin-typescript@^0.8.1: tippex "^2.1.1" typescript "^1.8.9" +rollup-plugin-uglify@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-uglify/-/rollup-plugin-uglify-3.0.0.tgz#a34eca24617709c6bf1778e9653baafa06099b86" + dependencies: + uglify-es "^3.3.7" + rollup-pluginutils@^1.3.1: version "1.5.2" resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-1.5.2.tgz#1e156e778f94b7255bfa1b3d0178be8f5c552408" @@ -5546,7 +5552,7 @@ typescript@^1.8.9: version "1.8.10" resolved "https://registry.yarnpkg.com/typescript/-/typescript-1.8.10.tgz#b475d6e0dff0bf50f296e5ca6ef9fbb5c7320f1e" -typescript@^2.6.2: +typescript@^2.6.2, typescript@^2.8.2: version "2.6.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4" @@ -5554,6 +5560,13 @@ ua-parser-js@^0.7.9: version "0.7.17" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac" +uglify-es@^3.3.7: + version "3.3.9" + resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.9.tgz#0c1c4f0700bed8dbc124cdb304d2592ca203e677" + dependencies: + commander "~2.13.0" + source-map "~0.6.1" + uglify-js@3.3.x, uglify-js@^3.0.13: version "3.3.7" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.3.7.tgz#28463e7c7451f89061d2b235e30925bf5625e14d"