Skip to content

Commit 8d10047

Browse files
author
Diogo Fonseca
authored
Merge pull request #105 from eruptionjs/chore/update-ts-and-deps
RC: v1.13 - Update ts and deps
2 parents e823e5a + 39c1b2d commit 8d10047

File tree

10 files changed

+1776
-76
lines changed

10 files changed

+1776
-76
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,46 @@
1-
name: CI
1+
# This workflow runs on every push to the staging and main branches
2+
# and on pull requests targeting those branches.
3+
# It installs dependencies, runs linting, tests, and builds the project using Bun.
4+
name: 'CI: Pre-Merge Validations'
25

36
on:
47
push:
58
branches:
9+
- staging
610
- main
711
pull_request:
12+
branches:
13+
- staging
14+
- main
815

916
# cancel in-progress runs on new commits to same PR (gitub.event.number)
1017
concurrency:
1118
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
1219
cancel-in-progress: true
1320

1421
jobs:
15-
build:
16-
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}
22+
run:
23+
name: Install, lint, test, and build on Bun ${{ matrix.os }}
1724

1825
runs-on: ${{ matrix.os }}
1926
strategy:
2027
matrix:
21-
node: ['20.x']
2228
os: [ubuntu-latest]
2329

2430
steps:
2531
- name: Checkout repo
2632
uses: actions/checkout@v3
2733

28-
# bun install
29-
- uses: oven-sh/setup-bun@v1
34+
- name: Setup Bun and install dependencies
35+
uses: oven-sh/setup-bun@v1
3036
with:
3137
bun-version: latest
3238

3339
- name: Install
3440
run: bun install
3541

3642
- name: Lint
37-
run: bun run lint
43+
run: bun run lint-staged
3844

3945
- name: Test
4046
run: bun run test

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bun run lint-staged && bun run test && bun run build
1+
bun run test && bun run build

.lintstagedrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"*.{html,md,json,jsonc}": ["npm run prettier:fix"],
3-
"*.{ts,tsx}": ["npm run prettier:fix", "npm run lint:fix"],
4-
"*.css": ["npm run lint:css"]
2+
"*.{html,md,json,jsonc}": ["bun run prettier:fix"],
3+
"*.{ts,tsx}": ["bun run prettier:fix", "bun run lint:fix"],
4+
"*.css": ["bun run lint:css"]
55
}

.prettierrc.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { default as eruptionPrettierConfig } from "@eruptionjs/config/prettier"
2-
export default {
3-
...eruptionPrettierConfig,
4-
}
1+
import { default as eruptionPrettierConfig } from '@eruptionjs/config/prettier'
2+
3+
export default { ...eruptionPrettierConfig }

bun.lock

Lines changed: 1708 additions & 0 deletions
Large diffs are not rendered by default.

bun.lockb

-409 KB
Binary file not shown.

package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "eruption",
33
"description": "Next Generation Boilerplate for React/Typescript, built on top of Vite ⚡️",
44
"private": false,
5-
"version": "1.12",
5+
"version": "1.13",
66
"type": "module",
77
"main": "src/main.tsx",
88
"license": "MIT",
@@ -32,7 +32,8 @@
3232
"prettier:fix": "bun run prettier -- --write",
3333
"format": "bun run prettier && bun run lint",
3434
"format:fix": "bun run prettier:fix && bun run lint:fix",
35-
"lint-staged": "lint-staged && tsc",
35+
"typecheck": "tsc",
36+
"lint-staged": "tsc & lint-staged",
3637
"prebuild": "bun run lint-staged",
3738
"prepare": "husky",
3839
"commit": "commit"
@@ -42,7 +43,7 @@
4243
"npm": "!^x",
4344
"yarn": "!^x",
4445
"pnpm": "!^x",
45-
"bun": "^1.1.x"
46+
"bun": "^1.2.x"
4647
},
4748
"dependencies": {
4849
"react": "^19.x",
@@ -53,33 +54,33 @@
5354
"@commitlint/config-conventional": "^19.x",
5455
"@commitlint/prompt-cli": "^19.x",
5556
"@commitlint/types": "^19.x",
56-
"@eruptionjs/config": "^0.5.0",
57+
"@eruptionjs/config": "^0.6.1",
5758
"@testing-library/jest-dom": "^6.x",
5859
"@testing-library/react": "^16.x",
5960
"@testing-library/user-event": "^14.x",
6061
"@types/bun": "^1.x",
6162
"@types/react": "^19.x",
6263
"@types/react-dom": "^19.x",
6364
"@vitejs/plugin-react-swc": "^3.x",
64-
"@vitest/coverage-v8": "^2.x",
65-
"@vitest/ui": "^2.x",
65+
"@vitest/coverage-v8": "^3.x",
66+
"@vitest/ui": "^3.x",
6667
"c8": "^10.x",
6768
"eslint": "^9.x",
68-
"happy-dom": "^15.x",
69+
"happy-dom": "^17.x",
6970
"husky": "^9.x",
7071
"lint-staged": "^15.x",
7172
"msw": "^2.x",
72-
"npm-check-updates": "^16.x",
73+
"npm-check-updates": "^17.x",
7374
"prettier": "^3.x",
7475
"stylelint": "^16.x",
75-
"stylelint-config-standard": "^36.x",
76+
"stylelint-config-standard": "^37.x",
7677
"typescript": "^5.x",
77-
"vite": "^5.x",
78+
"vite": "^6.x",
7879
"vite-bundle-visualizer": "^1.x",
7980
"vite-plugin-compression2": "^1.x",
8081
"vite-plugin-qrcode": "^0.x",
81-
"vitest": "^2.x",
82-
"web-vitals": "^3.x"
82+
"vitest": "^3.x",
83+
"web-vitals": "^4.x"
8384
},
8485
"msw": {
8586
"workerDirectory": "public"

public/mockServiceWorker.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* - Please do NOT serve this file on production.
99
*/
1010

11-
const PACKAGE_VERSION = '2.2.13'
12-
const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
11+
const PACKAGE_VERSION = '2.7.3'
12+
const INTEGRITY_CHECKSUM = '00729d72e3b82faf54ca8b9621dbb96f'
1313
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
1414
const activeClientIds = new Set()
1515

@@ -62,7 +62,12 @@ self.addEventListener('message', async function (event) {
6262

6363
sendToClient(client, {
6464
type: 'MOCKING_ENABLED',
65-
payload: true,
65+
payload: {
66+
client: {
67+
id: client.id,
68+
frameType: client.frameType,
69+
},
70+
},
6671
})
6772
break
6873
}
@@ -155,6 +160,10 @@ async function handleRequest(event, requestId) {
155160
async function resolveMainClient(event) {
156161
const client = await self.clients.get(event.clientId)
157162

163+
if (activeClientIds.has(event.clientId)) {
164+
return client
165+
}
166+
158167
if (client?.frameType === 'top-level') {
159168
return client
160169
}
@@ -183,12 +192,26 @@ async function getResponse(event, client, requestId) {
183192
const requestClone = request.clone()
184193

185194
function passthrough() {
186-
const headers = Object.fromEntries(requestClone.headers.entries())
195+
// Cast the request headers to a new Headers instance
196+
// so the headers can be manipulated with.
197+
const headers = new Headers(requestClone.headers)
198+
199+
// Remove the "accept" header value that marked this request as passthrough.
200+
// This prevents request alteration and also keeps it compliant with the
201+
// user-defined CORS policies.
202+
const acceptHeader = headers.get('accept')
203+
if (acceptHeader) {
204+
const values = acceptHeader.split(',').map((value) => value.trim())
205+
const filteredValues = values.filter(
206+
(value) => value !== 'msw/passthrough',
207+
)
187208

188-
// Remove internal MSW request header so the passthrough request
189-
// complies with any potential CORS preflight checks on the server.
190-
// Some servers forbid unknown request headers.
191-
delete headers['x-msw-intention']
209+
if (filteredValues.length > 0) {
210+
headers.set('accept', filteredValues.join(', '))
211+
} else {
212+
headers.delete('accept')
213+
}
214+
}
192215

193216
return fetch(requestClone, { headers })
194217
}

tsconfig.json

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,10 @@
11
{
2+
"extends": "@eruptionjs/config/typescript",
3+
"include": ["@eruptionjs/reset.d.ts", "**/*.ts", "**/*.tsx"],
24
"compilerOptions": {
3-
"target": "ESNext",
4-
"useDefineForClassFields": true,
5-
"lib": ["ESNext", "DOM", "DOM.Iterable"],
6-
"module": "ESNext",
7-
"skipLibCheck": true,
8-
9-
/* Bundler mode */
10-
"moduleResolution": "Bundler",
11-
"allowImportingTsExtensions": true,
12-
"resolveJsonModule": true,
13-
"isolatedModules": true,
14-
"noEmit": true,
15-
"allowJs": false,
16-
"esModuleInterop": false,
17-
"jsx": "react-jsx",
18-
19-
/* Linting */
20-
"strict": true,
21-
"noUnusedLocals": true,
22-
"noUnusedParameters": true,
23-
"noFallthroughCasesInSwitch": true,
24-
"forceConsistentCasingInFileNames": true,
25-
"allowSyntheticDefaultImports": true,
26-
275
/* Absolute import */
286
"baseUrl": ".",
29-
"paths": {
30-
"@/*": ["src/*"]
31-
},
7+
"paths": { "@/*": ["src/*"] },
328
"types": ["vite/client", "vitest/globals"]
33-
},
34-
"include": ["**/*.ts", "**/*.tsx"],
35-
"exclude": ["node_modules"],
36-
"references": [{ "path": "./tsconfig.node.json" }]
9+
}
3710
}

tsconfig.node.json

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

0 commit comments

Comments
 (0)