Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade vite dependencies #9565

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions examples/crm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "react-admin-crm",
"version": "4.12.0",
"private": true,
"type": "module",
"dependencies": {
"@hello-pangea/dnd": "^16.3.0",
"@mui/icons-material": "^5.14.18",
Expand Down Expand Up @@ -30,11 +31,11 @@
"@types/lodash": "~4.14.168",
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.16",
"@vitejs/plugin-react": "^2.2.0",
"rollup-plugin-visualizer": "^5.9.2",
"@vitejs/plugin-react": "^4.2.1",
"rollup-plugin-visualizer": "^5.12.0",
"typescript": "^5.1.3",
"vite": "^3.2.0",
"web-vitals": "^1.0.1"
"vite": "^5.0.11",
"web-vitals": "^3.5.1"
},
"scripts": {
"dev": "vite",
Expand Down
35 changes: 18 additions & 17 deletions examples/crm/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@ import { defineConfig } from 'vite';
import path from 'path';
import fs from 'fs';
import react from '@vitejs/plugin-react';
import visualizer from 'rollup-plugin-visualizer';
import { visualizer } from 'rollup-plugin-visualizer';

const packages = fs.readdirSync(path.resolve(__dirname, '../../packages'));
const aliases = packages.reduce((acc, dirName) => {
const packageJson = require(path.resolve(
__dirname,
'../../packages',
dirName,
'package.json'
));
acc[packageJson.name] = path.resolve(
__dirname,
`${path.resolve('../..')}/packages/${packageJson.name}/src`
);
return acc;
}, {});

// https://vitejs.dev/config/
export default defineConfig({
export default defineConfig(async () => {
const packages = fs.readdirSync(path.resolve(__dirname, '../../packages'));
const aliases: Record<string, string> = {};
for (const dirName of packages) {
if (dirName === 'create-react-admin') continue;
// eslint-disable-next-line prettier/prettier
const packageJson = await import(
path.resolve(__dirname, '../../packages', dirName, 'package.json'),
{ assert: { type: 'json' } }
);
aliases[packageJson.default.name] = path.resolve(
__dirname,
`../../packages/${packageJson.default.name}/src`
);
}
return {
plugins: [
react(),
visualizer({
Expand Down Expand Up @@ -58,4 +59,4 @@ export default defineConfig({
})),
],
},
});
}});
9 changes: 5 additions & 4 deletions examples/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "demo",
"version": "4.12.0",
"private": true,
"type": "module",
"dependencies": {
"@apollo/client": "^3.3.19",
"@mui/icons-material": "^5.14.18",
Expand Down Expand Up @@ -43,14 +44,14 @@
"devDependencies": {
"@types/fetch-mock": "^7.3.2",
"@types/jest": "^29.5.2",
"@types/node": "^12.12.14",
"@types/node": "^20.10.7",
"@types/prop-types": "^15.7.11",
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.16",
"@vitejs/plugin-react": "^2.2.0",
"@vitejs/plugin-react": "^4.2.1",
"rewire": "^5.0.0",
"rollup-plugin-visualizer": "^5.9.2",
"rollup-plugin-visualizer": "^5.12.0",
"typescript": "^5.1.3",
"vite": "^3.2.0"
"vite": "^5.0.11"
}
}
108 changes: 55 additions & 53 deletions examples/demo/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,62 @@ import { defineConfig } from 'vite';
import path from 'path';
import fs from 'fs';
import react from '@vitejs/plugin-react';
import visualizer from 'rollup-plugin-visualizer';

const packages = fs.readdirSync(path.resolve(__dirname, '../../packages'));
const aliases = packages.reduce((acc, dirName) => {
const packageJson = require(path.resolve(
__dirname,
'../../packages',
dirName,
'package.json'
));
acc[packageJson.name] = path.resolve(
__dirname,
`${path.resolve('../..')}/packages/${packageJson.name}/src`
);
return acc;
}, {});
import { visualizer } from 'rollup-plugin-visualizer';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
visualizer({
open: process.env.NODE_ENV !== 'CI',
filename: './dist/stats.html',
}),
],
define: {
'process.env': process.env,
},
server: {
port: 8000,
open: true,
},
base: './',
esbuild: {
keepNames: true,
},
build: {
sourcemap: true,
},
resolve: {
preserveSymlinks: true,
alias: [
// allow profiling in production
// { find: 'react-dom', replacement: 'react-dom/profiling' },
{
find: 'scheduler/tracing',
replacement: 'scheduler/tracing-profiling',
},
// we need to manually follow the symlinks for local packages to allow deep HMR
...Object.keys(aliases).map(packageName => ({
find: packageName,
replacement: aliases[packageName],
})),
export default defineConfig(async () => {
const packages = fs.readdirSync(path.resolve(__dirname, '../../packages'));
const aliases: Record<string, string> = {};
for (const dirName of packages) {
if (dirName === 'create-react-admin') continue;
// eslint-disable-next-line prettier/prettier
const packageJson = await import(
path.resolve(__dirname, '../../packages', dirName, 'package.json'),
{ assert: { type: 'json' } }
);
aliases[packageJson.default.name] = path.resolve(
__dirname,
`../../packages/${packageJson.default.name}/src`
);
}

return {
plugins: [
react(),
visualizer({
open: process.env.NODE_ENV !== 'CI',
filename: './dist/stats.html',
}),
],
},
define: {
'process.env': process.env,
},
server: {
port: 8000,
open: true,
},
base: './',
esbuild: {
keepNames: true,
},
build: {
sourcemap: true,
},
resolve: {
preserveSymlinks: true,
alias: [
// allow profiling in production
// { find: 'react-dom', replacement: 'react-dom/profiling' },
{
find: 'scheduler/tracing',
replacement: 'scheduler/tracing-profiling',
},
// we need to manually follow the symlinks for local packages to allow deep HMR
...Object.keys(aliases).map(packageName => ({
find: packageName,
replacement: aliases[packageName],
})),
],
},
};
});
4 changes: 2 additions & 2 deletions examples/no-code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@vitejs/plugin-react": "^2.2.0",
"@vitejs/plugin-react": "^4.2.1",
"typescript": "^5.1.3",
"vite": "^3.2.0"
"vite": "^5.0.11"
},
"gitHead": "6eb0f6fcbe3ba237b507f3506d230b3445c0a764"
}
6 changes: 3 additions & 3 deletions examples/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "simple",
"version": "4.16.2",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down Expand Up @@ -31,10 +32,9 @@
"react-router-dom": "^6.1.0"
},
"devDependencies": {
"@babel/preset-react": "^7.12.10",
"@hookform/devtools": "^4.0.2",
"@vitejs/plugin-react": "^2.2.0",
"@vitejs/plugin-react": "^4.2.1",
"typescript": "^5.1.3",
"vite": "^3.2.0"
"vite": "^5.0.11"
}
}
46 changes: 0 additions & 46 deletions examples/simple/vite.config.js

This file was deleted.

52 changes: 52 additions & 0 deletions examples/simple/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import react from '@vitejs/plugin-react';
import path from 'path';
import fs from 'fs';
import { defineConfig } from 'vite';

/**
* https://vitejs.dev/config/
* @type { import('vite').UserConfig }
*/
export default defineConfig(async () => {
// In codesandbox, we won't have the packages folder
// We ignore errors in this case
let aliases: any[] = [];
try {
const packages = fs.readdirSync(
path.resolve(__dirname, '../../packages')
);
for (const dirName of packages) {
if (dirName === 'create-react-admin') continue;
// eslint-disable-next-line prettier/prettier
const packageJson = await import(
path.resolve(__dirname, '../../packages', dirName, 'package.json'),
{ assert: { type: 'json' } }
);
aliases.push({
find: new RegExp(`^${packageJson.default.name}$`),
replacement: path.resolve(
__dirname,
`../../packages/${packageJson.default.name}/src`
),
});
}
} catch {
}

return {
plugins: [react()],
resolve: {
alias: [
...aliases,
{
find: /^@mui\/icons-material\/(.*)/,
replacement: '@mui/icons-material/esm/$1',
},
],
},
server: {
port: 8080,
},
define: { 'process.env': {} },
};
});
4 changes: 2 additions & 2 deletions examples/tutorial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"devDependencies": {
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.16",
"@vitejs/plugin-react": "^2.2.0",
"@vitejs/plugin-react": "^4.2.1",
"typescript": "^5.1.3",
"vite": "^3.2.0"
"vite": "^5.0.11"
}
}
2 changes: 1 addition & 1 deletion packages/create-react-admin/src/generateProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const BasePackageJson = {
devDependencies: {
'@typescript-eslint/parser': '^5.60.1',
'@typescript-eslint/eslint-plugin': '^5.60.1',
'@types/node': '^18.16.1',
'@types/node': '^20.10.7',
'@types/react': '^18.0.22',
'@types/react-dom': '^18.0.7',
'@vitejs/plugin-react': '^4.0.1',
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@testing-library/react": "^14.1.2",
"@testing-library/react-hooks": "^8.0.1",
"@types/jest": "^29.5.2",
"@types/node": "^17.0.8",
"@types/node": "^20.10.7",
"@types/node-polyglot": "^0.4.31",
"@types/react": "^18.2.37",
"cross-env": "^5.2.0",
Expand Down
Loading
Loading