Skip to content

Commit

Permalink
bump: 2.1.7, reducing the size of the final bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-logan committed Jul 25, 2024
1 parent 5a9653b commit 6fc87c2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ jestTestFile.js
BackupCopia
.eslintrc.js
jest.config.js
*.js
*.mjs
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ Feel free to find bugs and report them to me. Your feedback is highly appreciate
jsDelivr:

```bash
https://cdn.jsdelivr.net/npm/multiform-validator@2.1.3/dist/bundle.min.js
https://cdn.jsdelivr.net/npm/multiform-validator@2.1.7/dist/cjs/index.min.js
```

```html
<script src="https://cdn.jsdelivr.net/npm/multiform-validator@2.1.3/dist/bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/multiform-validator@2.1.7/dist/cjs/index.min.js"></script>
```

unpkg:

```bash
https://unpkg.com/multiform-validator@2.1.3/dist/bundle.js
https://unpkg.com/multiform-validator@2.1.7/dist/cjs/index.js
```

```html
<script src="https://unpkg.com/multiform-validator@2.1.3/dist/bundle.js"></script>
<script src="https://unpkg.com/multiform-validator@2.1.7/dist/cjs/index.js"></script>
```

### Example of use with CDN

```html
<script src="https://cdn.jsdelivr.net/npm/multiform-validator@2.1.3/dist/bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/multiform-validator@2.1.7/dist/cjs/index.min.js"></script>
<script>
const emailResult = isEmail("123456");
const cpfResult = cpfIsValid("123456");
Expand Down
6 changes: 3 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import passwordStrengthTester from "./src/passwordStrengthTester";
import validateSurname from "./src/validateSurname";
import validateName from "./src/validateName";
import validateTextarea from "./src/validateTextarea";
import { ValidateFunctions, IsValidFunctions } from "./src/types";
import isValidImage from "./src/isValidImage";
import isValidAudio from "./src/isValidAudio";
import isValidPdf from "./src/isValidPdf";
import isValidVideo from "./src/isValidVideo";
import isValidTxt from "./src/isValidTxt";
import type { ValidateFunctions, IsValidFunctions } from "./src/types";

export {
cpfIsValid,
Expand Down Expand Up @@ -64,11 +64,11 @@ export {
validateName,
validateSurname,
validateTextarea,
ValidateFunctions,
IsValidFunctions,
isValidImage,
isValidAudio,
isValidPdf,
isValidVideo,
isValidTxt,
};

export type { ValidateFunctions, IsValidFunctions };
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "multiform-validator",
"version": "2.1.6",
"version": "2.1.7",
"description": "Javascript library made to validate, several form fields, such as: email, phone, password, cpf etc.",
"main": "./dist/index.js",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./types/index.d.ts",
"unpkg": "./dist/bundle.js",
"unpkg": "./dist/cjs/index.js",
"scripts": {
"test": "jest --coverage",
"test:file": "jest tests/src/isDecimal.test --watch",
Expand Down
7 changes: 4 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */

/* Modules */
"module": "commonjs" /* Specify what module code is generated. */,
"module": "NodeNext" /* Specify what module code is generated. */,
// "rootDir": "./src", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
Expand Down Expand Up @@ -55,7 +55,7 @@
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"outDir": "./dist/esm" /* Specify an output folder for all emitted files. */,
"removeComments": true /* Disable emitting comments. */,
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
Expand Down Expand Up @@ -104,7 +104,8 @@

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
"moduleResolution": "NodeNext"
},
"include": ["src/**/*", "index.ts", ".eslintrc.js"]
}
10 changes: 6 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
const path = require("path");

module.exports = {
const commonjsWebpackConfig = {
mode: "production", // production mode
entry: "./index.ts", // entry point of your application
output: {
filename: "bundle.js", // output file name
filename: "cjs/index.js", // output file name
path: path.resolve(__dirname, "dist"), // output folder
libraryTarget: "umd", // this allows your module to be used via require() and as a global
globalObject: "this", // this ensures that 'this' is 'window' in a browser environment
},
module: {
rules: [
{
test: /\.tsx?$/,
test: /\.ts?$/,
use: "ts-loader",
exclude: /node_modules/,
},
Expand All @@ -21,4 +21,6 @@ module.exports = {
resolve: {
extensions: [".ts"],
},
};
}

module.exports = [commonjsWebpackConfig]; // export the webpack config

0 comments on commit 6fc87c2

Please sign in to comment.