Skip to content

Commit 088e437

Browse files
authored
Adds rollup to publish cjs and esm (#40)
- [X] Fixes bad esm imports - [X] Updates dependencies - [X] Adds CHANGELOG
1 parent 3e67580 commit 088e437

File tree

6 files changed

+1343
-1404
lines changed

6 files changed

+1343
-1404
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ src/setupTests.ts
66
/src/**/*.test.ts
77
jest.config.js
88
babel.config.js
9+
rollup.config.js

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# CHANGELOG
2+
3+
## 5.1.0
4+
- [X] Fixes bad commonjs/esm import
5+
- [X] Updates dependencies
6+
- [X] Adds this CHANGELOG.md file
7+
8+
## v5.0.2
9+
- [X] Fixes missing js file
10+
- [X] Fixes import syntax in js file
11+
- [X] Removes node 14 requirement
12+
13+
## v5.0.0
14+
### BREAKING CHANGE
15+
- [X] Removes support for @hapi/joi.
16+
- This means only [@sideway/joi](https://github.com/sideway/joi) is supported.
17+
18+
## v4.2.1
19+
- [X] Adds Typescript Definitions
20+
21+
## v4.2.0
22+
- [X] Adds support for [@sideway/joi](https://github.com/sideway/joi) in addition to @hapi/joi
23+
24+
Note: As joi changes over time, this module will exclusively track sideway/joi.
25+
26+
### Peer Dependency
27+
Peer dependency on @hapi/joi has been removed. You will receive a runtime error instead if joi is not peer-installed.
28+
In the future when we exclusively track sideway/joi, the peer dependency will be restored.
29+
30+
## v4.0.0
31+
- [X] [#14] Added support for Joi v16 and v17 and more descriptive error messages.
32+
33+
### BREAKING CHANGES
34+
- Starting with v4 only Joi v16 and higher will be supported.
35+
- Joi is now a peer dependency which should stop any mix version errors.
36+
- Minimum Nodejs version was changed to v10 or higher.

package.json

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
22
"name": "joi-password-complexity",
3-
"version": "5.0.2",
3+
"version": "5.1.0",
44
"description": "Joi validation for password complexity requirements.",
55
"main": "lib/index.js",
6+
"module": "lib/index.es.js",
67
"types": "lib/index.d.ts",
8+
"jsnext:main": "lib/index.es.js",
79
"scripts": {
810
"test": "jest",
911
"lint": "eslint src --ext .js,.ts",
1012
"lint-fix": "yarn lint --fix",
11-
"build": "tsc -p tsconfig.json",
13+
"build": "rimraf ./lib && rollup -c",
1214
"prepublishOnly": "yarn build"
1315
},
1416
"repository": {
@@ -19,28 +21,34 @@
1921
"joi": ">= 17"
2022
},
2123
"devDependencies": {
22-
"@babel/core": "^7.12.3",
23-
"@babel/preset-env": "^7.12.1",
24-
"@babel/preset-typescript": "^7.12.1",
25-
"@types/jest": "^26.0.15",
26-
"@types/joi": "^14.3.4",
27-
"@typescript-eslint/eslint-plugin": "^4.6.1",
28-
"@typescript-eslint/parser": "^4.6.1",
24+
"@babel/core": "^7.12.16",
25+
"@babel/preset-env": "^7.12.16",
26+
"@babel/preset-typescript": "^7.12.16",
27+
"@rollup/plugin-commonjs": "^17.1.0",
28+
"@rollup/plugin-node-resolve": "^11.1.1",
29+
"@types/jest": "^26.0.20",
30+
"@types/joi": "^17.2.2",
31+
"@typescript-eslint/eslint-plugin": "^4.15.0",
32+
"@typescript-eslint/parser": "^4.15.0",
2933
"babel-jest": "^26.6.3",
30-
"eslint": "^7.12.1",
31-
"eslint-config-airbnb-base": "^14.2.0",
32-
"eslint-config-airbnb-typescript": "^12.0.0",
34+
"eslint": "^7.19.0",
35+
"eslint-config-airbnb-base": "^14.2.1",
36+
"eslint-config-airbnb-typescript": "^12.3.1",
3337
"eslint-plugin-import": "^2.22.1",
34-
"eslint-plugin-jest": "^24.1.0",
38+
"eslint-plugin-jest": "^24.1.3",
3539
"eslint-plugin-jsx-a11y": "^6.4.1",
36-
"eslint-plugin-react": "^7.21.5",
40+
"eslint-plugin-react": "^7.22.0",
3741
"eslint-plugin-react-hooks": "^4.2.0",
3842
"jest": "^26.6.3",
3943
"joi": "^17.3.0",
40-
"typescript": "^4.0.5"
44+
"rimraf": "^3.0.2",
45+
"rollup": "^2.38.5",
46+
"rollup-plugin-peer-deps-external": "^2.2.4",
47+
"rollup-plugin-typescript2": "^0.29.0",
48+
"typescript": "^4.1.5"
4149
},
4250
"files": [
43-
"lib"
51+
"lib/"
4452
],
4553
"keywords": [
4654
"Joi",

rollup.config.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import typescript from 'rollup-plugin-typescript2'
2+
import commonjs from '@rollup/plugin-commonjs'
3+
import external from 'rollup-plugin-peer-deps-external'
4+
import resolve from '@rollup/plugin-node-resolve'
5+
6+
import pkg from './package.json'
7+
8+
export default {
9+
input: 'src/index.ts',
10+
output: [
11+
{
12+
file: pkg.main,
13+
format: 'cjs',
14+
exports: 'default',
15+
sourcemap: true
16+
},
17+
{
18+
file: pkg.module,
19+
format: 'es',
20+
exports: 'default',
21+
sourcemap: true
22+
}
23+
],
24+
plugins: [
25+
external(),
26+
resolve(),
27+
typescript({
28+
rollupCommonJSResolveHack: true,
29+
exclude: '**/__tests__/**',
30+
clean: true
31+
}),
32+
commonjs({
33+
include: ['node_modules/**']
34+
})
35+
]
36+
}

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"allowSyntheticDefaultImports": true,
1010
"strict": true,
1111
"forceConsistentCasingInFileNames": true,
12-
"module": "CommonJS",
12+
"module": "esnext",
1313
"moduleResolution": "node",
1414
"resolveJsonModule": true,
1515
"isolatedModules": true,
@@ -21,5 +21,5 @@
2121
"types": ["jest"]
2222
},
2323
"include": ["src"],
24-
"exclude": ["node_modules", "**/*.spec.ts", "**/*.test.ts"]
24+
"exclude": ["lib", "node_modules", "**/*.spec.ts", "**/*.test.ts"]
2525
}

0 commit comments

Comments
 (0)