Skip to content

Commit c6ca014

Browse files
committed
build: add lundle
1 parent d460ab5 commit c6ca014

File tree

10 files changed

+3769
-1642
lines changed

10 files changed

+3769
-1642
lines changed

.eslintignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 61 deletions
This file was deleted.

.prettierignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

babel.config.js

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1 @@
1-
module.exports = (api) => {
2-
const module = api.env('module')
3-
const esm = api.env('esm')
4-
const presetEnv = [
5-
'@lunde/es',
6-
{
7-
env: {
8-
modules: esm || module ? false : 'commonjs',
9-
targets: module
10-
? {
11-
browsers: 'cover 80% in US',
12-
}
13-
: {
14-
node: esm ? '12' : '10',
15-
},
16-
},
17-
restSpread: false,
18-
devExpression: false,
19-
objectAssign: false,
20-
},
21-
]
22-
23-
return {
24-
presets: [['@babel/preset-react', {useSpread: true}], presetEnv],
25-
plugins: ['optimize-react', 'annotate-pure-calls'],
26-
}
27-
}
1+
module.exports = require('lundle').babelConfig('test', {react: true})

jest.config.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

package.json

Lines changed: 80 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"bugs": "https://github.com/accessible-ui/checkbox/issues",
77
"author": "Jared Lunde <jared.lunde@gmail.com> (https://jaredLunde.com)",
88
"license": "MIT",
9-
"description": "An accessible and versatile checkbox component for React",
9+
"description": "🅰 An accessible and versatile checkbox component for React",
1010
"keywords": [
1111
"react",
1212
"react component",
@@ -21,90 +21,136 @@
2121
],
2222
"main": "dist/main/index.js",
2323
"module": "dist/module/index.js",
24+
"unpkg": "dist/umd/checkbox.js",
2425
"source": "src/index.tsx",
2526
"types": "types/index.d.ts",
26-
"files": [
27-
"/dist",
28-
"/src",
29-
"/types"
30-
],
3127
"exports": {
3228
".": {
3329
"browser": "./dist/module/index.js",
3430
"import": "./dist/esm/index.mjs",
3531
"require": "./dist/main/index.js",
32+
"umd": "./dist/umd/checkbox.js",
3633
"source": "./src/index.tsx",
3734
"types": "./types/index.d.ts",
3835
"default": "./dist/main/index.js"
3936
},
4037
"./package.json": "./package.json",
4138
"./": "./"
4239
},
40+
"files": [
41+
"/dist",
42+
"/src",
43+
"/types"
44+
],
4345
"sideEffects": false,
4446
"scripts": {
45-
"build": "npm run build-esm && npm run build-main && npm run build-module && npm run build-types",
46-
"build-esm": "npm run compile -- -d dist/esm --env-name esm --out-file-extension .mjs",
47-
"build-main": "npm run compile -- -d dist/main --env-name main",
48-
"build-module": "npm run compile -- -d dist/module --env-name module",
49-
"build-types": "tsc -p tsconfig.json -d --outDir types --emitDeclarationOnly",
50-
"check-types": "tsc --noEmit -p tsconfig.json",
51-
"compile": "babel src -x .ts,.tsx --ignore \"**/*.test.ts\",\"**/*.test.tsx\" --delete-dir-on-start",
52-
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,md,yml,json,eslintrc,prettierrc}\"",
47+
"build": "lundle build",
48+
"check-types": "lundle check-types",
49+
"dev": "lundle build -f module,cjs -w",
50+
"format": "prettier --write \"{,!(node_modules|dist|coverage)/**/}*.{ts,tsx,js,jsx,md,yml,json}\"",
5351
"lint": "eslint . --ext .ts,.tsx",
54-
"prepublishOnly": "npm run lint && npm run test && npm run build && npm run format",
52+
"prepublishOnly": "cli-confirm \"Did you run 'yarn release' first? (y/N)\"",
53+
"prerelease": "npm run validate && npm run build",
54+
"release": "git add . && standard-version -a",
5555
"test": "jest",
56-
"validate": "npm run check-types && npm run lint && npm run test -- --coverage"
56+
"validate": "lundle check-types && npm run lint && jest --coverage"
5757
},
5858
"husky": {
5959
"hooks": {
60-
"pre-commit": "npm run build-types && git add types && lint-staged"
60+
"pre-commit": "lundle check-types && lint-staged",
61+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
6162
}
6263
},
6364
"lint-staged": {
6465
"**/*.{ts,tsx,js,jsx}": [
65-
"eslint",
66+
"eslint --fix",
6667
"prettier --write"
6768
],
68-
"**/*.{md,yml,json,eslintrc,prettierrc}": [
69+
"**/*.{md,yml,json}": [
6970
"prettier --write"
7071
]
7172
},
73+
"commitlint": {
74+
"extends": [
75+
"@commitlint/config-conventional"
76+
]
77+
},
78+
"config": {
79+
"commitizen": {
80+
"path": "./node_modules/cz-conventional-changelog"
81+
}
82+
},
83+
"eslintConfig": {
84+
"extends": [
85+
"lunde"
86+
]
87+
},
88+
"eslintIgnore": [
89+
"node_modules",
90+
"coverage",
91+
"dist",
92+
"/types",
93+
"test",
94+
"*.config.js"
95+
],
96+
"jest": {
97+
"moduleDirectories": [
98+
"node_modules",
99+
"src",
100+
"test"
101+
],
102+
"testMatch": [
103+
"<rootDir>/src/**/?(*.)test.{ts,tsx}"
104+
],
105+
"collectCoverageFrom": [
106+
"**/src/**/*.{ts,tsx}"
107+
],
108+
"setupFilesAfterEnv": [
109+
"./test/setup.js"
110+
],
111+
"snapshotResolver": "./test/resolve-snapshot.js",
112+
"globals": {
113+
"__DEV__": true
114+
}
115+
},
116+
"prettier": {
117+
"semi": false,
118+
"singleQuote": true,
119+
"jsxSingleQuote": true,
120+
"bracketSpacing": false
121+
},
72122
"devDependencies": {
73-
"@babel/preset-react": "latest",
74-
"@lunde/babel-preset-es": "latest",
123+
"@commitlint/cli": "latest",
124+
"@commitlint/config-conventional": "latest",
75125
"@testing-library/jest-dom": "latest",
76126
"@testing-library/react": "latest",
77127
"@testing-library/react-hooks": "latest",
78128
"@testing-library/user-event": "latest",
79129
"@types/jest": "latest",
80130
"@types/react": "latest",
81131
"@types/react-dom": "latest",
82-
"@typescript-eslint/eslint-plugin": "latest",
83-
"@typescript-eslint/parser": "latest",
84-
"babel-plugin-annotate-pure-calls": "latest",
85-
"babel-plugin-optimize-react": "latest",
132+
"babel-jest": "latest",
133+
"cli-confirm": "latest",
134+
"cz-conventional-changelog": "latest",
86135
"eslint": "latest",
87-
"eslint-import-resolver-jest": "latest",
88-
"eslint-plugin-jest": "latest",
89-
"eslint-plugin-react": "latest",
90-
"eslint-plugin-react-hooks": "latest",
136+
"eslint-config-lunde": "latest",
91137
"husky": "latest",
92138
"jest": "latest",
93139
"lint-staged": "latest",
140+
"lundle": "latest",
94141
"prettier": "latest",
95142
"react": "latest",
96143
"react-dom": "latest",
97144
"react-test-renderer": "latest",
98-
"ts-jest": "latest",
145+
"standard-version": "latest",
99146
"typescript": "latest"
100147
},
101148
"dependencies": {
102-
"@accessible/visually-hidden": "^1.1.0",
103-
"@react-hook/switch": "^1.1.0",
149+
"@accessible/visually-hidden": "^2.0.0",
150+
"@react-hook/switch": "^1.3.0",
104151
"clsx": "^1.1.1"
105152
},
106153
"peerDependencies": {
107-
"react": ">=16.8",
108-
"react-dom": ">=16.8"
154+
"react": ">=16.8"
109155
}
110156
}

test/resolve-snapshot.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@ const snapshots = '__snapshots__'
44
module.exports = {
55
resolveSnapshotPath: (testPath, snapshotExtension) =>
66
path.join(
7-
testPath.split('/').slice(0, -1).join('/'),
7+
testPath
8+
.split('/')
9+
.slice(0, -1)
10+
.join('/'),
811
snapshots,
912
testPath.split('/').pop() + snapshotExtension
1013
),
1114
resolveTestPath: (snapshotFilePath, snapshotExtension) =>
1215
path.join(
13-
snapshotFilePath.split('/').slice(0, -2).join('/'),
14-
snapshotFilePath.split('/').pop().slice(0, -snapshotExtension.length)
16+
snapshotFilePath
17+
.split('/')
18+
.slice(0, -2)
19+
.join('/'),
20+
snapshotFilePath
21+
.split('/')
22+
.pop()
23+
.slice(0, -snapshotExtension.length)
1524
),
1625
testPathForConsistencyCheck: 'src/foo.test.js',
1726
}

test/setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// This file is for setting up Jest test environments
2+
import '@testing-library/jest-dom/extend-expect'
3+
24
afterEach(() => {
35
jest.clearAllMocks()
46
})

0 commit comments

Comments
 (0)