-
-
Notifications
You must be signed in to change notification settings - Fork 204
V2 - better modules support #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e53074d
224c6d1
29cae66
1cfeb80
098d385
aeae4db
13f2d48
c5ef172
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Original source: https://github.com/preactjs/preact/blob/master/config/node-13-exports.js | ||
| const fs = require('fs'); | ||
|
|
||
| const subRepositories = ['zod', 'joi', 'vest', 'yup', 'superstruct']; | ||
| const snakeCaseToCamelCase = (str) => | ||
| str.replace(/([-_][a-z])/g, (group) => group.toUpperCase().replace('-', '')); | ||
|
|
||
| const copySrc = () => { | ||
| // Copy .module.js --> .mjs for Node 13 compat. | ||
| fs.writeFileSync( | ||
| `${process.cwd()}/dist/resolvers.mjs`, | ||
| fs.readFileSync(`${process.cwd()}/dist/resolvers.module.js`), | ||
| ); | ||
| }; | ||
|
|
||
| const copy = (name) => { | ||
| // Copy .module.js --> .mjs for Node 13 compat. | ||
| const filename = name.includes('-') ? snakeCaseToCamelCase(name) : name; | ||
| fs.writeFileSync( | ||
| `${process.cwd()}/${name}/dist/${filename}.mjs`, | ||
| fs.readFileSync(`${process.cwd()}/${name}/dist/${filename}.module.js`), | ||
| ); | ||
| }; | ||
|
|
||
| copySrc(); | ||
| subRepositories.forEach(copy); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,10 @@ | ||
| module.exports = { | ||
| roots: ['<rootDir>/src'], | ||
| transform: { | ||
| '^.+\\.tsx?$': 'ts-jest', | ||
| }, | ||
| globals: { | ||
| 'ts-jest': { | ||
| tsconfig: 'tsconfig.jest.json', | ||
| }, | ||
| }, | ||
| preset: 'ts-jest', | ||
| testEnvironment: 'node', | ||
| restoreMocks: true, | ||
| testMatch: ['**/?(*.)+(spec|test).ts?(x)'], | ||
| testMatch: ['**/__tests__/**/*.+(js|jsx|ts|tsx)'], | ||
| transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'], | ||
| moduleFileExtensions: ['ts', 'tsx', 'js'], | ||
| moduleNameMapper: { | ||
| '^@hookform/resolvers$': '<rootDir>/src', | ||
| }, | ||
| }; |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "name": "joi", | ||
| "amdName": "hookformResolversJoi", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "description": "React Hook Form validation resolver: joi", | ||
| "main": "dist/joi.js", | ||
| "module": "dist/joi.module.js", | ||
| "umd:main": "dist/joi.umd.js", | ||
| "source": "src/index.ts", | ||
| "types": "dist/index.d.ts", | ||
| "license": "MIT", | ||
| "peerDependencies": { | ||
| "react-hook-form": ">=6.6.0", | ||
| "@hookform/resolvers": "^1.0.0" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './joi'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,89 @@ | ||
| { | ||
| "name": "@hookform/resolvers", | ||
| "amdName": "hookformResolvers", | ||
| "version": "1.3.1", | ||
| "description": "React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod and etc.", | ||
| "umd:main": "umd/index.js", | ||
| "unpkg": "umd/index.js", | ||
| "jsdelivr": "umd/index.js", | ||
| "sideEffects": false, | ||
| "description": "React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod, Vest and etc.", | ||
| "main": "dist/resolvers.js", | ||
| "module": "dist/resolvers.module.js", | ||
| "umd:main": "dist/resolvers.umd.js", | ||
| "source": "src/index.ts", | ||
| "types": "dist/index.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "browser": "./dist/resolvers.module.js", | ||
| "umd": "./dist/resolvers.umd.js", | ||
| "import": "./dist/resolvers.mjs", | ||
| "require": "./dist/resolvers.js" | ||
| }, | ||
| "./zod": { | ||
| "browser": "./zod/dist/zod.module.js", | ||
| "umd": "./zod/dist/zod.umd.js", | ||
| "import": "./zod/dist/zod.mjs", | ||
| "require": "./zod/dist/zod.js" | ||
| }, | ||
| "./yup": { | ||
| "browser": "./yup/dist/yup.module.js", | ||
| "umd": "./yup/dist/yup.umd.js", | ||
| "import": "./yup/dist/yup.mjs", | ||
| "require": "./yup/dist/yup.js" | ||
| }, | ||
| "./joi": { | ||
| "browser": "./joi/dist/joi.module.js", | ||
| "umd": "./joi/dist/joi.umd.js", | ||
| "import": "./joi/dist/joi.mjs", | ||
| "require": "./joi/dist/joi.js" | ||
| }, | ||
| "./vest": { | ||
| "browser": "./vest/dist/vest.module.js", | ||
| "umd": "./vest/dist/vest.umd.js", | ||
| "import": "./vest/dist/vest.mjs", | ||
| "require": "./vest/dist/vest.js" | ||
| }, | ||
| "./superstruct": { | ||
| "browser": "./superstruct/dist/superstruct.module.js", | ||
| "umd": "./superstruct/dist/superstruct.umd.js", | ||
| "import": "./superstruct/dist/superstruct.mjs", | ||
| "require": "./superstruct/dist/superstruct.js" | ||
| }, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
| "./package.json": "./package.json", | ||
| "./": "./" | ||
| }, | ||
| "files": [ | ||
| "dist", | ||
| "yup.js", | ||
| "yup.d.ts", | ||
| "joi.js", | ||
| "joi.d.ts", | ||
| "superstruct.js", | ||
| "superstruct.d.ts", | ||
| "zod.js", | ||
| "zod.d.ts", | ||
| "vest.js", | ||
| "vest.d.ts" | ||
| "yup/package.json", | ||
| "yup/src", | ||
| "yup/dist", | ||
| "zod/package.json", | ||
| "zod/src", | ||
| "zod/dist", | ||
| "vest/package.json", | ||
| "vest/src", | ||
| "vest/dist", | ||
| "joi/package.json", | ||
| "joi/src", | ||
| "joi/dist", | ||
| "superstruct/package.json", | ||
| "superstruct/src", | ||
| "superstruct/dist" | ||
| ], | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "scripts": { | ||
| "clean": "rimraf dist", | ||
| "prebuild": "yarn clean", | ||
| "build": "tsc && rollup -c", | ||
| "lint": "eslint '**/*.{js,ts}'", | ||
| "lint:fix": "yarn lint -- --fix", | ||
| "lint:types": "tsc --noEmit", | ||
| "test": "jest --runInBand", | ||
| "test:watch": "yarn test --watchAll --coverage" | ||
| "prepare": "run-s build && check-export-map", | ||
| "build": "npm-run-all --parallel build:*", | ||
| "build:src": "microbundle build", | ||
| "build:zod": "microbundle --cwd zod --globals '@hookform/resolvers=hookformResolvers'", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's new to me,
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It specify variable name for external imports in umd/iife bundles |
||
| "build:yup": "microbundle --cwd yup", | ||
| "build:joi": "microbundle --cwd joi --globals '@hookform/resolvers=hookformResolvers'", | ||
| "build:superstruct": "microbundle --cwd superstruct --globals '@hookform/resolvers=hookformResolvers'", | ||
| "build:vest": "microbundle --cwd vest", | ||
| "postbuild": "node ./config/node-13-exports.js", | ||
| "lint": "eslint . --ext .ts,.js --ignore-path .gitignore", | ||
| "lint:types": "tsc", | ||
| "test": "jest", | ||
| "test:watch": "yarn test --watchAll --coverage --runInBand", | ||
| "check:all": "npm-run-all --parallel lint:* test" | ||
| }, | ||
| "keywords": [ | ||
| "scheme", | ||
|
|
@@ -40,9 +93,10 @@ | |
| "react-hook-form", | ||
| "yup", | ||
| "joi", | ||
| "sperstruct", | ||
| "superstruct", | ||
| "typescript", | ||
| "zod" | ||
| "zod", | ||
| "vest" | ||
| ], | ||
| "repository": { | ||
| "type": "git", | ||
|
|
@@ -55,28 +109,22 @@ | |
| }, | ||
| "homepage": "https://react-hook-form.com", | ||
| "devDependencies": { | ||
| "@rollup/plugin-commonjs": "^17.0.0", | ||
| "@rollup/plugin-node-resolve": "^11.0.1", | ||
| "@types/jest": "^26.0.19", | ||
| "@types/yup": "^0.29.11", | ||
| "@typescript-eslint/eslint-plugin": "^4.10.0", | ||
| "@typescript-eslint/parser": "^4.10.0", | ||
| "eslint": "^7.16.0", | ||
| "@typescript-eslint/eslint-plugin": "^4.11.1", | ||
| "@typescript-eslint/parser": "^4.11.1", | ||
| "check-export-map": "^1.0.1", | ||
| "eslint": "^7.17.0", | ||
| "eslint-config-prettier": "^7.1.0", | ||
| "eslint-plugin-prettier": "^3.3.0", | ||
| "husky": "^4.3.6", | ||
| "jest": "^26.6.3", | ||
| "joi": "^17.3.0", | ||
| "lint-staged": "^10.5.3", | ||
| "matched": "^5.0.1", | ||
| "microbundle": "^0.13.0", | ||
| "npm-run-all": "^4.1.5", | ||
| "prettier": "^2.2.1", | ||
| "react": "^17.0.1", | ||
| "react-hook-form": "^6.13.1", | ||
| "rimraf": "^3.0.2", | ||
| "rollup": "^2.35.1", | ||
| "rollup-plugin-terser": "^7.0.2", | ||
| "rollup-plugin-typescript2": "^0.29.0", | ||
| "react-hook-form": "^6.14.0", | ||
| "semantic-release": "^17.3.1", | ||
| "superstruct": "^0.13.1", | ||
| "ts-jest": "^26.4.4", | ||
|
|
@@ -88,19 +136,14 @@ | |
| "peerDependencies": { | ||
| "react-hook-form": ">=6.6.0" | ||
| }, | ||
| "release": { | ||
jorisre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "branches": [ | ||
| "master" | ||
| ] | ||
| }, | ||
| "husky": { | ||
| "hooks": { | ||
| "pre-commit": "yarn lint:types && lint-staged" | ||
| } | ||
| }, | ||
| "lint-staged": { | ||
| "*.{js,ts}": [ | ||
| "yarn lint:fix" | ||
| "yarn lint --fix" | ||
| ], | ||
| "*.{md,json,yml}": [ | ||
| "prettier --write" | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dependent itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, to import
convertArrayToPathName, inspiration from preactThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh cool! 👍