Skip to content

Commit 1ffd719

Browse files
RichDom2185leeyi45
andauthored
Upgrade Vite ecosystem to v8 (#632)
* Pin Vitest and upgrade to Vite v8 * Rollback Vite to v7 * Revert "Rollback Vite to v7" This reverts commit 2301e42. * Ignore Vitest attachments * Migrate Vitest config * Run Vitest non-interactively * Skip failing tests for now * Rollback vitest-browser-react * Add the legacy.inconsistentCjsInterop flag to vitest configuration * Restore playground tests * Update vite config resolution to remove type error * Fix tests being skipped --------- Co-authored-by: DESKTOP-G08HS3B\Lee Yi <leeyi45@gmail.com>
1 parent e6d664a commit 1ffd719

16 files changed

Lines changed: 656 additions & 308 deletions

File tree

.github/actions/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"@sourceacademy/modules-repotools": "workspace:^",
88
"@types/node": "^22.15.30",
99
"typescript": "^5.8.2",
10-
"vitest": "^4.0.18"
10+
"vitest": "4.1.0"
1111
},
1212
"dependencies": {
1313
"@actions/artifact": "^6.0.0",
@@ -19,7 +19,7 @@
1919
"scripts": {
2020
"build": "node ./build.js",
2121
"postinstall": "yarn build",
22-
"test": "vitest",
22+
"test": "vitest run",
2323
"tsc": "tsc --project ./tsconfig.json"
2424
}
2525
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ ehthumbs.db
5050
Thumbs.db
5151

5252
**/__tests__/**/__screenshots__
53+
**/.vitest-attachments

devserver/package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@blueprintjs/icons": "^6.0.0",
1414
"@commander-js/extra-typings": "^14.0.0",
1515
"@sourceacademy/modules-lib": "workspace:^",
16-
"@vitejs/plugin-react": "^5.1.0",
16+
"@vitejs/plugin-react": "^6.0.1",
1717
"ace-builds": "^1.25.1",
1818
"classnames": "^2.3.1",
1919
"commander": "^14.0.0",
@@ -22,20 +22,23 @@
2222
"react": "^18.3.1",
2323
"react-ace": "^14.0.0",
2424
"react-dom": "^18.3.1",
25-
"vite": "^7.1.11",
25+
"vite": "^8.0.0",
2626
"vite-plugin-node-polyfills": "^0.25.0"
2727
},
2828
"devDependencies": {
2929
"@sourceacademy/modules-buildtools": "workspace:^",
3030
"@types/react": "^18.3.1",
3131
"@types/react-dom": "^18.3.1",
32-
"@vitest/browser-playwright": "^4.0.18",
32+
"@vitest/browser-playwright": "4.1.0",
3333
"eslint": "^9.35.0",
3434
"playwright": "^1.55.1",
3535
"sass": "^1.85.0",
3636
"typescript": "^5.8.2",
37-
"vitest": "^4.0.18",
38-
"vitest-browser-react": "^2.0.4"
37+
"vitest": "4.1.0",
38+
"vitest-browser-react": "^2.1.0"
39+
},
40+
"peerDependencies": {
41+
"es-toolkit": "^1.44.0"
3942
},
4043
"scripts": {
4144
"dev": "vite",

devserver/vite.config.ts

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,37 @@ export default defineProject(({ mode }) => {
2525
}),
2626
react(),
2727
],
28+
legacy: {
29+
inconsistentCjsInterop: true
30+
},
2831
resolve: {
2932
preserveSymlinks: true,
30-
alias: [{
31-
find: /^js-slang\/context/,
32-
replacement: pathlib.resolve(import.meta.dirname, 'src', 'mockModuleContext.ts')
33-
}, {
34-
// This alias configuration allows us to edit the modules library and have the changes
33+
alias: [
34+
{
35+
find: /^js-slang\/context/,
36+
replacement: pathlib.resolve(import.meta.dirname, 'src', 'mockModuleContext.ts')
37+
},
38+
{
39+
// This alias configuration allows us to edit the modules library and bundles and have those changes
3540
// be reflected in real time when in hot-reload mode
36-
find: /^@sourceacademy\/modules-lib/,
37-
replacement: '.',
38-
customResolver(source, importer, options) {
39-
const newSource = pathlib.resolve(import.meta.dirname, '../lib/modules-lib/src', source);
40-
return this.resolve(newSource, importer, options);
41+
find: /^@sourceacademy\/modules-lib\/(.+)/,
42+
replacement: pathlib.resolve(import.meta.dirname, '../lib/modules-lib/src/$1')
4143
},
42-
}, {
43-
find: /^@sourceacademy\/bundle-(.+)/,
44-
replacement: '$1',
45-
customResolver(source, importer, options) {
46-
const [bundleName, everythingElse] = source.split('/', 2);
47-
const newSource = pathlib.resolve(import.meta.dirname, '../src/bundles', bundleName, 'src', everythingElse);
48-
return this.resolve(newSource, importer, options);
44+
{
45+
find: /^@sourceacademy\/bundle-(\w+)$/,
46+
replacement: pathlib.resolve(import.meta.dirname, '../src/bundles/$1/src/index.ts')
4947
},
50-
}],
48+
{
49+
find: /^@sourceacademy\/bundle-(\w+?)\/(.+)$/,
50+
replacement: pathlib.resolve(import.meta.dirname, '../src/bundles/$1/src/$2')
51+
}
52+
],
5153
},
5254
define: {
53-
'process.env': env
55+
'process.env': env,
56+
global: 'globalThis'
5457
},
5558
optimizeDeps: {
56-
esbuildOptions: {
57-
// Node.js global to browser globalThis
58-
define: {
59-
global: 'globalThis'
60-
}
61-
},
6259
include: [
6360
'../build/tabs/*.js',
6461
'@blueprintjs/core',
@@ -68,6 +65,8 @@ export default defineProject(({ mode }) => {
6865
'ace-builds/src-noconflict/ext-language_tools',
6966
'ace-builds/src-noconflict/ext-searchbox',
7067
'classnames',
68+
'es-toolkit',
69+
'gl-matrix',
7170
'js-slang',
7271
'js-slang/dist/createContext',
7372
'js-slang/dist/editors/ace/modes/source',

lib/buildtools/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
"type": "module",
1818
"dependencies": {
1919
"@sourceacademy/modules-repotools": "workspace:^",
20-
"@vitejs/plugin-react": "^5.1.0",
21-
"@vitest/browser-playwright": "^4.0.18",
22-
"@vitest/coverage-v8": "^4.0.18",
20+
"@vitejs/plugin-react": "^6.0.1",
21+
"@vitest/browser-playwright": "4.1.0",
22+
"@vitest/coverage-v8": "4.1.0",
2323
"acorn": "^8.8.1",
2424
"acorn-typescript": "^1.4.13",
2525
"astring": "^1.8.6",
@@ -31,8 +31,8 @@
3131
"http-server": "^14.1.1",
3232
"jsdom": "^29.0.0",
3333
"typedoc": "^0.28.9",
34-
"vite": "^7.1.11",
35-
"vitest": "^4.0.18"
34+
"vite": "^8.0.0",
35+
"vitest": "4.1.0"
3636
},
3737
"scripts": {
3838
"build": "node ./build.js --dev",

lib/lintplugin/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"peerDependencies": {
1717
"@eslint/markdown": "^7.0.0",
1818
"@stylistic/eslint-plugin": "^5.0.0",
19-
"@vitest/eslint-plugin": "^1.3.4",
19+
"@vitest/eslint-plugin": "^1.6.12",
2020
"eslint": ">=9",
2121
"eslint-plugin-import": "^2.32.0",
2222
"eslint-plugin-jsdoc": "^62.0.0",
@@ -32,7 +32,7 @@
3232
"@stylistic/eslint-plugin": "^5.0.0",
3333
"@typescript-eslint/rule-tester": "^8.56.1",
3434
"@typescript-eslint/utils": "^8.56.1",
35-
"@vitest/eslint-plugin": "^1.6.6",
35+
"@vitest/eslint-plugin": "^1.6.12",
3636
"eslint-plugin-import": "^2.32.0",
3737
"eslint-plugin-jsdoc": "^62.0.0",
3838
"eslint-plugin-react": "^7.37.4",

lib/modules-lib/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
"@sourceacademy/modules-buildtools": "workspace:^",
88
"@types/react": "^18.3.1",
99
"@types/react-dom": "^18.3.1",
10-
"@vitejs/plugin-react": "^5.1.0",
11-
"@vitest/browser-playwright": "^4.0.18",
10+
"@vitejs/plugin-react": "^6.0.1",
11+
"@vitest/browser-playwright": "4.1.0",
1212
"eslint": "^9.35.0",
1313
"playwright": "^1.55.1",
1414
"typedoc": "^0.28.9",
1515
"typedoc-plugin-frontmatter": "^1.3.0",
1616
"typedoc-plugin-markdown": "^4.7.0",
1717
"typedoc-plugin-rename-defaults": "^0.7.3",
1818
"typescript": "^5.8.2",
19-
"vitest": "^4.0.18",
20-
"vitest-browser-react": "^2.0.4"
19+
"vitest": "4.1.0",
20+
"vitest-browser-react": "^2.1.0"
2121
},
2222
"exports": {
2323
"./tabs/index": null,

lib/repotools/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
"devDependencies": {
88
"@commander-js/extra-typings": "^14.0.0",
99
"@types/node": "^22.15.30",
10-
"@vitejs/plugin-react": "^5.1.0",
11-
"@vitest/coverage-v8": "^4.0.18",
10+
"@vitejs/plugin-react": "^6.0.1",
11+
"@vitest/coverage-v8": "4.1.0",
1212
"typescript": "^5.8.2",
13-
"vitest": "^4.0.18",
14-
"vitest-browser-react": "^2.0.4"
13+
"vitest": "4.1.0",
14+
"vitest-browser-react": "^2.1.0"
1515
},
1616
"dependencies": {
17-
"@vitest/browser-playwright": "^4.0.18",
17+
"@vitest/browser-playwright": "4.1.0",
1818
"chalk": "^5.0.1",
1919
"commander": "^14.0.0",
2020
"es-toolkit": "^1.44.0",
@@ -33,6 +33,6 @@
3333
"build": "tsc --project ./tsconfig.prod.json",
3434
"postinstall": "yarn build",
3535
"tsc": "tsc --project ./tsconfig.json",
36-
"test": "vitest"
36+
"test": "vitest run"
3737
}
3838
}

lib/vitest-reporter/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
"type": "module",
66
"dependencies": {
77
"istanbul-lib-report": "^3.0.1",
8-
"vitest": "^4.0.18"
8+
"vitest": "4.1.0"
99
},
1010
"devDependencies": {
1111
"@types/istanbul-lib-report": "^3.0.3",
1212
"@types/node": "^22.15.30",
13-
"@vitest/coverage-v8": "^4.0.18",
13+
"@vitest/coverage-v8": "4.1.0",
1414
"esbuild": "^0.27.0",
1515
"typescript": "^5.8.2"
1616
},
@@ -27,6 +27,6 @@
2727
"build": "yarn build:coverage-reporter && yarn build:test-reporter",
2828
"build:coverage-reporter": "esbuild --outfile=./build/coverage-reporter.cjs --format=cjs --bundle=true --minify --external:\"istanbul-lib-report\" --platform=node src/coverage-reporter.cts",
2929
"build:test-reporter": "esbuild --outfile=./build/test-reporter.js --format=esm --bundle=true --minify --external:\"vitest*\" --platform=node src/test-reporter.ts",
30-
"test": "vitest"
30+
"test": "vitest run"
3131
}
3232
}

lib/vitest-reporter/vitest.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { defineConfig } from 'vitest/config';
33
import rootConfig from '../../vitest.config.js';
44

55
export default defineConfig({
6-
esbuild: {
7-
include: ['**/*.{cts,ts}']
6+
oxc: {
7+
include: ['**/*.{cts,ts}'],
88
},
99
optimizeDeps: {
1010
include: ['istanbul-lib-report'],

0 commit comments

Comments
 (0)