Skip to content

Commit 4e034e6

Browse files
zpaocursoragent
andcommitted
Migrate the website package to Vite.
Replace the tsup IIFE + static serve loop with a self-contained Vite app under website/, keep GitHub Pages under /qrcode.react/, and alias qrcode.react to src for local HMR. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1e9cfc4 commit 4e034e6

13 files changed

Lines changed: 470 additions & 350 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ jobs:
1515
cache: 'pnpm'
1616
- run: pnpm install
1717
- run: make
18+
- run: pnpm website:build
1819
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
1920
with:
2021
name: build-output
2122
path: |
2223
lib
23-
website/**/*.js
24+
website/dist
2425
test:
2526
# Perhaps in the future we'll bring back matrix testing so we'll leave the support in.
2627
name: Test against React (@v${{ matrix.react_version }})

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ node_modules/
33
.pnpm-store/
44
lib/
55
package-lock.json
6-
website/iife
6+
website/dist

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ package.json
22
node_modules
33
lib
44
third-party
5+
website/dist

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
SRC_DEPS = src/index.tsx src/third-party/qrcodegen/index.ts
22
CFG_DEPS = pnpm-lock.yaml package.json tsup.config.ts tsconfig.json
3-
EXAMPLE_DEPS = website/*.tsx
3+
WEBSITE_DEPS = website/*.tsx website/index.html
4+
WEBSITE_CFG_DEPS = pnpm-lock.yaml package.json website/package.json website/vite.config.ts website/tsconfig.json
45

56
.PHONY: all clean
67

7-
all: lib/index.js lib/index.d.ts lib/index.d.mts lib/index.js website/iife/demo.js
8+
all: lib/index.js lib/index.d.ts lib/index.d.mts lib/index.js website/dist/index.html
89

910
lib:
1011
mkdir -p lib
@@ -21,9 +22,9 @@ lib/esm/index.js: lib $(SRC_DEPS) $(CFG_DEPS)
2122
lib/index.js: lib $(SRC_DEPS) $(CFG_DEPS)
2223
pnpm run build:code
2324

24-
website/iife/demo.js: lib/esm/index.js ${EXAMPLE_DEPS}
25-
pnpm run build:examples
25+
website/dist/index.html: lib/esm/index.js ${WEBSITE_DEPS} ${WEBSITE_CFG_DEPS}
26+
pnpm run website:build
2627

2728
clean:
2829
git clean -fX lib
29-
rm -rf website/iife
30+
rm -rf website/dist

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default [
3434
ignores: [
3535
'lib/',
3636
'node_modules/',
37-
'website/iife/demo.js',
37+
'website/dist/',
3838
'third-party/',
3939
'src/third-party/',
4040
'**/.DS_Store',

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@
2424
}
2525
},
2626
"scripts": {
27-
"build": "pnpm run build:code && pnpm run build:examples",
27+
"build": "pnpm run build:code",
2828
"build:code": "tsup src/index.tsx -d lib --format esm,cjs --dts --legacy-output --target=es2017 --platform=browser",
29-
"build:examples": "pnpm --filter website build",
30-
"build:examples:dev": "pnpm --filter website build:dev",
3129
"lint": "eslint .",
3230
"pretty": "prettier --write '**/*.{html,js,json,mjs,ts,tsx,yml}'",
3331
"prepack": "make clean && make all && pnpm run typecheck",
3432
"prepublish-docs": "make clean && make all",
35-
"publish-docs": "gh-pages --dist=website --src='{index.html,iife/demo.js}'",
36-
"serve:examples": "pnpm --filter website serve",
33+
"publish-docs": "gh-pages --dist=website/dist",
34+
"website": "pnpm --filter website dev",
35+
"website:build": "pnpm --filter website build",
36+
"website:preview": "pnpm --filter website preview",
3737
"test": "jest",
3838
"typecheck": "tsc --noEmit && pnpm --filter website typecheck"
3939
},

0 commit comments

Comments
 (0)