Skip to content

Commit

Permalink
v3.0.0 - upgraded package exports and improved devx (#153)
Browse files Browse the repository at this point in the history
* replace TSDX with tsup
* upgrade typescript, add dev node version
* remove eslint (for now)
* modernize package.json with exports and type:module fields
* Switch from Circle CI to Github Actions
* upgrade to modern yarn (v4.6.0)
* yarn workspaces and migrate example app to vite react
* Revamp TS setup with child configs extending root with common properties
  • Loading branch information
E-Kuerschner authored Jan 5, 2025
1 parent 5268fc0 commit 52f893d
Show file tree
Hide file tree
Showing 73 changed files with 5,513 additions and 13,462 deletions.
29 changes: 0 additions & 29 deletions .circleci/config.yml

This file was deleted.

2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

46 changes: 0 additions & 46 deletions .eslintrc.js

This file was deleted.

53 changes: 53 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI
on:
push:
branches:
- main
- upgrade-devx
pull_request:
types: [opened]
branches:
- "*"

jobs:
typecheck:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Enable Corepack
run: corepack enable
- name: Install Deps
run: yarn install
- name: Build package
run: yarn g:build-package
- name: Typecheck
run: yarn lint-all

cypress:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Enable Corepack
run: corepack enable
- name: Install Deps
run: yarn install
- name: Build package
run: yarn g:build-package
- name: Cypress run
uses: cypress-io/github-action@v2
with:
working-directory: packages/react-use-audio-player
start: yarn g:demo-vite-start
wait-on: http://localhost:1234/
17 changes: 13 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ node_modules
.cache
dist
.idea
*.nvmrc
test/cypress/videos
test/cypress/screenshots
.eslintcache

.eslintcache

.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

packages/react-use-audio-player/test/cypress/videos
packages/react-use-audio-player/test/cypress/screenshots
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22.12.0
9 changes: 9 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
nodeLinker: node-modules

packageExtensions:
# deasync didn't add node-gyp as a direct dependency so it fails to build in
# Yarn (https://github.com/yarnpkg/berry/issues/5804), so extend its
# pkg.json config here.
deasync@*:
dependencies:
node-gyp: 'latest'
24 changes: 24 additions & 0 deletions demos/vite-spa/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
50 changes: 50 additions & 0 deletions demos/vite-spa/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default tseslint.config({
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
})
```

- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
- Optionally add `...tseslint.configs.stylisticTypeChecked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:

```js
// eslint.config.js
import react from 'eslint-plugin-react'

export default tseslint.config({
// Set the react version
settings: { react: { version: '18.3' } },
plugins: {
// Add the react plugin
react,
},
rules: {
// other rules...
// Enable its recommended rules
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
},
})
```
13 changes: 13 additions & 0 deletions demos/vite-spa/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./src/index.tsx"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions demos/vite-spa/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "vite-spa",
"packageManager": "[email protected]",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite --port 1234",
"lint": "tsc --project ./tsconfig.app.json",
"g:demo-vite-start": "yarn --cwd $PROJECT_CWD/demos/vite-spa dev"
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.11.0",
"react-use-audio-player": "workspace:^"
},
"devDependencies": {
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"@vitejs/plugin-react": "^4.3.4",
"globals": "^15.14.0",
"sass": "^1.83.1",
"typescript": "~5.6.2",
"vite": "^6.0.5"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions examples/src/App.tsx → demos/vite-spa/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from "react"
import { BrowserRouter, Link, Route, Routes } from "react-router-dom"
import { BasicExample } from "./GlobalAudioSource/AudioPlayerState"
import { Spotifyish } from "./GlobalAudioSource/SoundLibrary"
import { AutoPlayNextSound } from "./GlobalAudioSource/AutoPlayNextSound"
import { MultipleSounds } from "./MultipleSounds"
import { GlobalAudioSource } from "./GlobalAudioSource"
import "./app.scss"
import { Streaming } from "./Streaming"
import "./app.scss"

function ExampleSelect() {
return (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {
import {
useCallback,
useEffect,
useRef,
Expand All @@ -13,7 +13,7 @@ interface AudioSeekBarProps {
className?: string
}

export const AudioSeekBar: FunctionComponent<AudioSeekBarProps> = props => {
export const AudioSeekBar: FunctionComponent<AudioSeekBarProps> = (props) => {
const { className = "" } = props
const { playing, getPosition, duration, seek } = useGlobalAudioPlayer()
const [pos, setPos] = useState(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import React, { FunctionComponent } from "react"
import { FunctionComponent } from "react"
import { Link } from "react-router-dom"

interface BackToHomeProps {
className?: string
}

export const BackToHome: FunctionComponent<BackToHomeProps> = (props) => {
return <Link className={ props.className || "" } to="/">{"< -"} Example Select</Link>
return (
<Link className={props.className || ""} to="/">
{"< -"} Example Select
</Link>
)
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import React, { useEffect, useState, FunctionComponent } from "react"
import { type FunctionComponent } from "react"
import { useGlobalAudioPlayer } from "react-use-audio-player"

export const AudioControls: FunctionComponent<{}> = () => {
const {
play,
pause,
stop,
mute,
muted,
playing,
loop,
looping
} = useGlobalAudioPlayer()
const { play, pause, stop, mute, muted, playing, loop, looping } =
useGlobalAudioPlayer()

return (
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import React, {
useState,
FunctionComponent,
ChangeEvent,
useEffect
} from "react"
import { useState, FunctionComponent, ChangeEvent, useEffect } from "react"
import { AudioLoadOptions, useGlobalAudioPlayer } from "react-use-audio-player"

export const FileLoader: FunctionComponent = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FunctionComponent } from "react"
import { FunctionComponent } from "react"
import { useGlobalAudioPlayer } from "react-use-audio-player"
import { FileLoader } from "./FileLoader"
import { AudioControls } from "./AudioControls"
Expand Down
Loading

0 comments on commit 52f893d

Please sign in to comment.