Skip to content

Commit fdd2629

Browse files
authored
Improve overal codebase, use modern tech like esbuild and TypeScript 4! (#1055)
* use esbuild for React instead of tsdx * remove tsdx from Vue * use consistent names * add jest and prettier * update scripts * ignore some folders for prettier * run lint script instead of tsdx lint * run prettier en-masse This has a few changes because of the new prettier version. * bump typescript to latest version * make typescript happy * cleanup playground package.json * make esbuild a dev dependency * make scripts consistent * fix husky hooks * add dedicated watch script * add `yarn playground-react` and `yarn react-playground` (alias) This will make sure to run a watcher for the actual @headlessui/react package, and start a development server in the playground-react package. * ignore formatting in the .next folder * run prettier on playground-react package * setup playground-vue Still not 100% working, but getting there! * add playground aliases in @headlessui/vue and @headlessui/react This allows you to run `yarn react playground` or `yarn vue playground` from the root. * add `clean` script * move examples folder in playground-vue to root * ensure new lines for consistency in scripts * fix typescript issue * fix typescript issues in playgrounds * make sure to run prettier on everything it can * run prettier on all files * improve error output If you minify the code, then it could happen that the errors are a bit obscure. This will hardcode the component name to improve errors. * add the `prettier-plugin-tailwindcss` plugin, party! * update changelog
1 parent ea26870 commit fdd2629

File tree

166 files changed

+5151
-5575
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+5151
-5575
lines changed

.github/CONTRIBUTING.md

-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,3 @@ yarn vue test
4646
```
4747

4848
Please ensure that the tests are passing when submitting a pull request. If you're adding new features to Headless UI, please include tests.
49-

.github/ISSUE_TEMPLATE/config.yml

-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ contact_links:
1212
- name: Documentation Issue
1313
url: https://github.com/tailwindlabs/headlessui/issues/new?title=%5BDOCS%5D:%20
1414
about: 'For documentation issues, suggest changes on our documentation repository.'
15-

.github/workflows/release-insiders.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ jobs:
4444
id: vars
4545
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
4646

47-
- name: "Version based on commit: 0.0.0-insiders.${{ steps.vars.outputs.sha_short }}"
47+
- name: 'Version based on commit: 0.0.0-insiders.${{ steps.vars.outputs.sha_short }}'
4848
run: npm version -w packages 0.0.0-insiders.${{ steps.vars.outputs.sha_short }} --force --no-git-tag-version
4949

5050
- name: Publish
5151
run: npm publish -w packages --tag insiders
5252
env:
5353
CI: true
5454
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55-

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/
2+
node_modules/
3+
coverage/
4+
.next/

.swcrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"minify": false,
3+
"jsc": {
4+
"parser": {
5+
"syntax": "typescript",
6+
"tsx": true,
7+
"decorators": false,
8+
"dynamicImport": false
9+
}
10+
}
11+
}

CHANGELOG.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Ensure correct order when conditionally rendering `Menu.Item`, `Listbox.Option` and `RadioGroup.Option` ([#1045](https://github.com/tailwindlabs/headlessui/pull/1045))
1313
- Improve controlled Tabs behaviour ([#1050](https://github.com/tailwindlabs/headlessui/pull/1050))
1414
- Improve typeahead search logic ([#1051](https://github.com/tailwindlabs/headlessui/pull/1051))
15+
- Improve overal codebase, use modern tech like `esbuild` and TypeScript 4! ([#1055](https://github.com/tailwindlabs/headlessui/pull/1055))
1516

1617
### Added
1718

@@ -23,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2324

2425
- Ensure correct order when conditionally rendering `MenuItem`, `ListboxOption` and `RadioGroupOption` ([#1045](https://github.com/tailwindlabs/headlessui/pull/1045))
2526
- Improve typeahead search logic ([#1051](https://github.com/tailwindlabs/headlessui/pull/1051))
27+
- Improve overal codebase, use modern tech like `esbuild` and TypeScript 4! ([#1055](https://github.com/tailwindlabs/headlessui/pull/1055))
2628

2729
### Added
2830

@@ -107,7 +109,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
107109

108110
## [@headlessui/react@v1.3.0] - 2021-06-21
109111

110-
### Added
112+
### Added
111113

112114
- Ensure that you can use `Transition.Child` when using implicit Transitions ([#503](https://github.com/tailwindlabs/headlessui/pull/503))
113115
- Add new `entered` prop for `Transition` and `Transition.Child` components ([#504](https://github.com/tailwindlabs/headlessui/pull/504))
@@ -127,7 +129,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
127129

128130
## [@headlessui/vue@v1.3.0] - 2021-06-21
129131

130-
### Added
132+
### Added
131133

132134
- Ensure that you can use `TransitionChild` when using implicit Transitions ([#503](https://github.com/tailwindlabs/headlessui/pull/503))
133135
- Add new `entered` prop for `Transition` and `TransitionChild` components ([#504](https://github.com/tailwindlabs/headlessui/pull/504))
@@ -141,7 +143,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
141143

142144
## [@headlessui/react@v1.2.0] - 2021-05-10
143145

144-
### Added
146+
### Added
145147

146148
- Introduce Open/Closed state, to simplify component communication ([#466](https://github.com/tailwindlabs/headlessui/pull/466))
147149

@@ -153,7 +155,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
153155

154156
## [@headlessui/vue@v1.2.0] - 2021-05-10
155157

156-
### Added
158+
### Added
157159

158160
- Introduce Open/Closed state, to simplify component communication ([#466](https://github.com/tailwindlabs/headlessui/pull/466))
159161

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,3 @@ For casual chit-chat with others using the library:
4949
## Contributing
5050

5151
If you're interested in contributing to Headless UI, please read our [contributing docs](https://github.com/tailwindlabs/headlessui/blob/main/.github/CONTRIBUTING.md) **before submitting a pull request**.
52-

jest/create-jest-config.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
const { createJestConfig: create } = require('tsdx/dist/createJestConfig')
2-
31
module.exports = function createJestConfig(root, options) {
42
return Object.assign(
5-
{},
6-
create(undefined, root),
73
{
84
rootDir: root,
95
setupFilesAfterEnv: ['<rootDir>../../jest/custom-matchers.ts'],
10-
globals: {
11-
'ts-jest': {
12-
isolatedModules: true,
13-
tsConfig: '<rootDir>/tsconfig.tsdx.json',
14-
},
6+
transform: {
7+
'^.+\\.(t|j)sx?$': '@swc/jest',
158
},
169
},
1710
options

package.json

+18-6
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@
1414
"react-playground": "yarn workspace playground-react dev",
1515
"playground-react": "yarn workspace playground-react dev",
1616
"vue": "yarn workspace @headlessui/vue",
17-
"shared": "yarn workspace @headlessui/shared",
17+
"playground-vue": "yarn workspace playground-vue dev",
18+
"vue-playground": "yarn workspace playground-vue dev",
19+
"clean": "yarn workspaces run clean",
1820
"build": "yarn workspaces run build",
1921
"test": "./scripts/test.sh",
20-
"lint": "./scripts/lint.sh"
22+
"lint": "./scripts/lint.sh",
23+
"lint-check": "CI=true ./scripts/lint.sh"
2124
},
2225
"husky": {
2326
"hooks": {
2427
"pre-commit": "lint-staged"
2528
}
2629
},
2730
"lint-staged": {
28-
"*.{js,jsx,ts,tsx}": "tsdx lint"
31+
"*": "yarn lint-check"
2932
},
3033
"prettier": {
3134
"printWidth": 100,
@@ -34,12 +37,21 @@
3437
"trailingComma": "es5"
3538
},
3639
"devDependencies": {
40+
"@swc/core": "^1.2.131",
41+
"@swc/jest": "^0.2.17",
3742
"@testing-library/jest-dom": "^5.11.9",
3843
"@types/node": "^14.14.22",
44+
"esbuild": "^0.14.11",
3945
"husky": "^4.3.8",
46+
"jest": "26",
4047
"lint-staged": "^12.2.1",
41-
"tsdx": "^0.14.1",
42-
"tslib": "^2.1.0",
43-
"typescript": "^3.9.7"
48+
"npm-run-all": "^4.1.5",
49+
"prettier": "^2.5.1",
50+
"rimraf": "^3.0.2",
51+
"tslib": "^2.3.1",
52+
"typescript": "^4.5.4"
53+
},
54+
"dependencies": {
55+
"prettier-plugin-tailwindcss": "^0.1.4"
4456
}
4557
}

packages/@headlessui-react/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ For help, discussion about best practices, or any other conversation that would
3636
For casual chit-chat with others using the library:
3737

3838
[Join the Tailwind CSS Discord Server](https://discord.gg/7NF8GNe)
39-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict'
2+
3+
if (process.env.NODE_ENV === 'production') {
4+
module.exports = require('./headlessui.prod.cjs.js')
5+
} else {
6+
module.exports = require('./headlessui.dev.cjs.js')
7+
}

packages/@headlessui-react/package.json

+17-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@
44
"description": "A set of completely unstyled, fully accessible UI components for React, designed to integrate beautifully with Tailwind CSS.",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",
7-
"module": "dist/index.esm.js",
7+
"module": "dist/headlessui.esm.js",
88
"license": "MIT",
99
"files": [
1010
"README.md",
1111
"dist"
1212
],
13+
"exports": {
14+
".": {
15+
"import": {
16+
"default": "./dist/headlessui.esm.js"
17+
},
18+
"require": "./dist/index.js",
19+
"types": "./dist/index.d.ts"
20+
}
21+
},
1322
"sideEffects": false,
1423
"engines": {
1524
"node": ">=10"
@@ -24,10 +33,12 @@
2433
},
2534
"scripts": {
2635
"prepublishOnly": "npm run build",
36+
"build": "../../scripts/build.sh --external:react --external:react-dom",
37+
"watch": "../../scripts/watch.sh --external:react --external:react-dom",
2738
"test": "../../scripts/test.sh",
28-
"build": "../../scripts/build.sh",
29-
"watch": "../../scripts/watch.sh",
30-
"lint": "../../scripts/lint.sh"
39+
"lint": "../../scripts/lint.sh",
40+
"playground": "yarn workspace playground-react dev",
41+
"clean": "rimraf ./dist"
3142
},
3243
"peerDependencies": {
3344
"react": "^16 || ^17 || ^18",
@@ -39,6 +50,7 @@
3950
"@types/react-dom": "^16.9.10",
4051
"react": "^16.14.0",
4152
"react-dom": "^16.14.0",
42-
"snapshot-diff": "^0.8.1"
53+
"snapshot-diff": "^0.8.1",
54+
"esbuild": "^0.11.18"
4355
}
4456
}

0 commit comments

Comments
 (0)