Skip to content

Commit c536f49

Browse files
authored
[wip] Components package (#14)
* move components to a package * from master * include hyparam libs in bundle * remove commented code * use the recommended way to load a worker * remove comments from JSON * inline the worker in build JS Note the size of the bundled JS: $ npm run build > @hyparam/components@0.1.0 build > tsc -b ./tsconfig.lib.json && vite build vite v5.4.10 building for production... ✓ 39 modules transformed. [vite:dts] Start generate declaration files... computing gzip size (0)...[vite:dts] Declaration files built in 2044ms. dist/main.es.js 234.34 kB │ gzip: 123.03 kB │ map: 119.65 kB dist/main.umd.js 223.48 kB │ gzip: 121.78 kB │ map: 116.58 kB ✓ built in 2.79s * remove vite boilerplate * add intermediate Page component to later handle authentication * use urls in viewers, fix ts * fix * addBreadcrumb component (even if it contains some redundant code for now) * include fixes and improvements from space it prepares the way to parse Hugging Face URLs * split worker in two, fix eslint * fix tests * fix install * fix CI for typechecking (only components) * remove temp comments * remove vite logo * apply the same eslint rules as the root + lint/fix * use components/index.ts as the entry point * only one tsconfig file * remove commented code * fix eslint in the root * fix types * add CI for the components * fix ci * try to fix tsc issue in root * Revert "try to fix tsc issue in root" This reverts commit 7d0fa35. * try to fix the CI * Revert "try to fix the CI" This reverts commit ad73e05. * remove typescript from the root app * ci: don't run twice * merge the workers back together * stricter lint rules * readme (still to be done) * disable rule that force explicit .toString() * type guard Error * lint * build app * run tests only on the app, not the workspace package * fix the test + add assert instead of forcing the type * better comment * fix npm versions + add test * try to fix the CI tsc * build the package to get the types * one sentence in the README
1 parent a84cc53 commit c536f49

Some content is hidden

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

59 files changed

+1269
-574
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: CI
22
on:
3-
pull_request:
43
push:
54

65
jobs:
@@ -16,6 +15,8 @@ jobs:
1615
steps:
1716
- uses: actions/checkout@v4
1817
- run: npm i
18+
- run: npm run build
19+
working-directory: ./packages/components
1920
- run: tsc
2021

2122
test:
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI in the components package
2+
on:
3+
push:
4+
paths:
5+
- 'packages/components/**'
6+
- '.github/workflows/ci_components.yml'
7+
8+
defaults:
9+
run:
10+
working-directory: ./packages/components
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- run: npm i
18+
- run: npm run lint
19+
20+
typecheck:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
- run: npm i
25+
- run: tsc
26+
27+
test:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
- run: npm i
32+
- run: npm run coverage

eslint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import javascript from '@eslint/js'
2-
import typescript from 'typescript-eslint'
32
import globals from 'globals'
3+
import typescript from 'typescript-eslint'
44

55
export default [
66
{
77
plugins: {
88
typescript,
99
},
1010

11-
ignores: ['public/build/*'],
11+
ignores: ['public/build/*', 'packages/components/dist/*'],
1212

1313
languageOptions: {
1414
globals: {

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@
1919
"lint": "eslint",
2020
"serve": "node src/cli.js",
2121
"url": "node src/cli.js https://hyperparam.blob.core.windows.net/hyperparam/starcoderdata-js-00000-of-00065.parquet",
22-
"test": "vitest run"
22+
"test": "vitest run --dir test"
2323
},
2424
"dependencies": {
2525
"highlight.js": "11.10.0",
26-
"hightable": "0.6.3",
27-
"hyparquet": "1.5.0",
28-
"hyparquet-compressors": "0.1.4"
26+
"@hyparam/components": "file:packages/components"
2927
},
3028
"devDependencies": {
3129
"@rollup/plugin-commonjs": "28.0.1",
@@ -50,5 +48,8 @@
5048
"typescript": "5.6.3",
5149
"typescript-eslint": "8.12.2",
5250
"vitest": "2.1.4"
53-
}
51+
},
52+
"workspaces": [
53+
"packages/components"
54+
]
5455
}

packages/components/.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
coverage
15+
16+
# Editor directories and files
17+
.vscode/*
18+
!.vscode/extensions.json
19+
.idea
20+
.DS_Store
21+
*.suo
22+
*.ntvs*
23+
*.njsproj
24+
*.sln
25+
*.sw?
26+
27+
package-lock.json
28+
*.tgz
29+
.vscode
30+
*.parquet
31+
/coverage/

packages/components/LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
The MIT License (MIT)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

packages/components/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# React components for hyparam apps
2+
3+
This package contains the React components for the hyparam apps.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import js from '@eslint/js'
2+
import react from 'eslint-plugin-react'
3+
import reactHooks from 'eslint-plugin-react-hooks'
4+
import reactRefresh from 'eslint-plugin-react-refresh'
5+
import globals from 'globals'
6+
import tseslint from 'typescript-eslint'
7+
8+
export default tseslint.config(
9+
{ ignores: ['coverage/', 'dist/'] },
10+
{
11+
settings: { react: { version: '18.3' } },
12+
extends: [js.configs.recommended, ...tseslint.configs.strictTypeChecked, ...tseslint.configs.stylisticTypeChecked],
13+
files: ['**/*.{ts,tsx,js}'],
14+
languageOptions: {
15+
ecmaVersion: 2020,
16+
globals: globals.browser,
17+
parserOptions: {
18+
project: ['./tsconfig.json', './tsconfig.eslint.json'],
19+
tsconfigRootDir: import.meta.dirname,
20+
},
21+
},
22+
plugins: {
23+
'react': react,
24+
'react-hooks': reactHooks,
25+
'react-refresh': reactRefresh,
26+
},
27+
rules: {
28+
...react.configs.recommended.rules,
29+
...react.configs['jsx-runtime'].rules,
30+
...reactHooks.configs.recommended.rules,
31+
'react-refresh/only-export-components': [
32+
'warn',
33+
{ allowConstantExport: true },
34+
],
35+
/// ^ from vite default configuration
36+
...js.configs.recommended.rules,
37+
...tseslint.configs.recommended.rules,
38+
'arrow-spacing': 'error',
39+
camelcase: 'off',
40+
'comma-spacing': 'error',
41+
'comma-dangle': ['error', 'always-multiline'],
42+
'eol-last': 'error',
43+
eqeqeq: 'error',
44+
'func-style': ['error', 'declaration'],
45+
indent: ['error', 2],
46+
'no-constant-condition': 'off',
47+
'no-extra-parens': 'error',
48+
'no-multi-spaces': 'error',
49+
'no-trailing-spaces': 'error',
50+
'no-unused-vars': 'off',
51+
'@typescript-eslint/no-unused-vars': 'warn',
52+
'no-useless-concat': 'error',
53+
'no-useless-rename': 'error',
54+
'no-useless-return': 'error',
55+
'no-var': 'error',
56+
'object-curly-spacing': ['error', 'always'],
57+
'prefer-const': 'warn',
58+
'prefer-destructuring': ['warn', {
59+
object: true,
60+
array: false,
61+
}],
62+
'prefer-promise-reject-errors': 'error',
63+
quotes: ['error', 'single'],
64+
'require-await': 'warn',
65+
semi: ['error', 'never'],
66+
67+
'sort-imports': ['error', {
68+
ignoreDeclarationSort: true,
69+
ignoreMemberSort: false,
70+
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
71+
}],
72+
73+
'space-infix-ops': 'error',
74+
75+
'@typescript-eslint/restrict-template-expressions': 'off',
76+
},
77+
},
78+
{
79+
files: ['test/**/*.{ts,tsx}', '*.{js,ts}'],
80+
languageOptions: {
81+
ecmaVersion: 2020,
82+
globals: {
83+
...globals.node,
84+
...globals.browser,
85+
},
86+
},
87+
},
88+
{
89+
files: ['**/*.js'],
90+
...tseslint.configs.disableTypeChecked,
91+
},
92+
)

packages/components/package.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"name": "@hyparam/components",
3+
"version": "0.1.0",
4+
"description": "React components for hyparam apps",
5+
"keywords": [
6+
"component",
7+
"data",
8+
"javascript",
9+
"react"
10+
],
11+
"license": "MIT",
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/hyparam/hyperparam-cli.git",
15+
"directory": "packages/components"
16+
},
17+
"type": "module",
18+
"main": "dist/index.umd.js",
19+
"module": "dist/index.es.js",
20+
"exports": {
21+
".": {
22+
"import": "./dist/index.es.js",
23+
"require": "./dist/index.umd.js",
24+
"types": "./dist/components/index.d.ts"
25+
}
26+
},
27+
"types": "dist/components/index.d.ts",
28+
"files": [
29+
"dist"
30+
],
31+
"scripts": {
32+
"build": "tsc && vite build",
33+
"coverage": "vitest run --coverage --coverage.include=src",
34+
"lint": "eslint .",
35+
"preview": "vite preview",
36+
"prepublishOnly": "npm run build",
37+
"test": "vitest run"
38+
},
39+
"dependencies": {
40+
"hightable": "0.6.3",
41+
"hyparquet": "1.5.0",
42+
"hyparquet-compressors": "0.1.4"
43+
},
44+
"peerDependencies": {
45+
"react": "^18.3.1",
46+
"react-dom": "^18.3.1"
47+
},
48+
"devDependencies": {
49+
"@eslint/js": "9.14.0",
50+
"@testing-library/react": "16.0.1",
51+
"@types/node": "22.9.0",
52+
"@types/react": "18.3.12",
53+
"@types/react-dom": "18.3.1",
54+
"@vitejs/plugin-react": "4.3.3",
55+
"@vitest/coverage-v8": "2.1.4",
56+
"eslint": "9.14.0",
57+
"eslint-plugin-react": "7.37.2",
58+
"eslint-plugin-react-hooks": "5.0.0",
59+
"eslint-plugin-react-refresh": "0.4.14",
60+
"globals": "15.11.0",
61+
"typescript": "5.6.3",
62+
"typescript-eslint": "8.13.0",
63+
"vite": "5.4.10",
64+
"vite-plugin-dts": "4.3.0",
65+
"vitest": "2.1.4"
66+
}
67+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Page from './Page.tsx'
2+
3+
export default function App() {
4+
return (
5+
<Page />
6+
)
7+
}

0 commit comments

Comments
 (0)