Skip to content
Merged

Vite v8 #1526

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
5 changes: 5 additions & 0 deletions .changeset/fair-bears-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sku-lib/vite': major
---

Dropped vite@7 support. Minimum version bumped to vite@8.
5 changes: 5 additions & 0 deletions .changeset/giant-eyes-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sku': patch
---

Updated minimum versions of dependencies to address security vulnerabilities
13 changes: 13 additions & 0 deletions .changeset/modern-suits-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'sku': minor
---

Bumping vite version to vite@8

This update should not affect most applications, unless you have specified unsupported vite@8 options via `dangerouslySetViteConfig`. Since this API is subject to potential changes, this is a minor (not breaking) release.

If your app relies on `@sku-lib/vite`, please ensure you upgrade to at least version 2.0.0.
Comment thread
williamlark marked this conversation as resolved.

```
pnpm update @sku-lib/vite^2.0.0
```
17 changes: 9 additions & 8 deletions fixtures/translations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
"name": "@sku-fixtures/translations",
"private": true,
"type": "module",
"scripts": {
"build": "sku build",
"build:vite": "sku build --config sku.config.vite.ts",
"serve": "sku serve",
"start": "sku start",
"start:ssr": "sku start-ssr --config sku-ssr.config.ts",
"start:vite": "sku start --config sku.config.vite.ts"
},
"dependencies": {
"@vocab/core": "^1.6.2",
"@vocab/react": "^1.1.11",
"@vocab/webpack": "^1.2.9",
"@vocab/vite": "catalog:",
"@vocab/webpack": "^1.2.9",
"react": "catalog:",
"react-dom": "catalog:"
},
"scripts": {
"build": "sku build",
"build:vite": "sku build --config sku.config.vite.ts",
"start": "sku start",
"start:vite": "sku start --config sku.config.vite.ts",
"start:ssr": "sku start-ssr --config sku-ssr.config.ts"
},
"devDependencies": {
"@sku-private/test-utils": "workspace:*",
"@types/express": "^4.17.11",
Expand Down
2 changes: 2 additions & 0 deletions fixtures/vite-cjs-interop-apollo-client-v3/sku.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { makeStableViteHashes } from '@sku-private/test-utils';
import type { SkuConfig } from 'sku';

export default {
bundler: 'vite',
dangerouslySetViteConfig: makeStableViteHashes,
} satisfies SkuConfig;
5 changes: 3 additions & 2 deletions fixtures/vite-cjs-interop-apollo-client-v4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"type": "module",
"scripts": {
"build": "sku build",
"serve": "sku serve",
"start": "sku start"
},
"dependencies": {
"@apollo/client": "^4.1.6",
"react": "catalog:",
"react-dom": "catalog:",
"@apollo/client": "^4.1.6"
"react-dom": "catalog:"
},
"devDependencies": {
"@types/react": "catalog:",
Expand Down
2 changes: 2 additions & 0 deletions fixtures/vite-cjs-interop-apollo-client-v4/sku.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { makeStableViteHashes } from '@sku-private/test-utils';
import type { SkuConfig } from 'sku';

export default {
bundler: 'vite',
dangerouslySetViteConfig: makeStableViteHashes,
} satisfies SkuConfig;
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"tsdown": "^0.16.7",
"tsx": "^4.19.4",
"typescript": "~5.9.0",
"vite-tsconfig-paths": "^6.0.3",
"vitest": "catalog:"
},
"engines": {
Expand Down
31 changes: 16 additions & 15 deletions packages/sku/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@babel/preset-env": "^7.21.5",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.21.5",
"@babel/runtime": "^7.21.0",
"@babel/runtime": "^7.29.2",
"@babel/traverse": "^7.26.9",
"@babel/types": "^7.26.0",
"@eslint/compat": "^1.2.1",
Expand All @@ -90,19 +90,20 @@
"@loadable/server": "^5.16.7",
"@loadable/webpack-plugin": "^5.14.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.0",
"@rolldown/plugin-babel": "^0.2.1",
"@sku-lib/babel-plugin-display-name": "workspace:*",
"@sku-lib/vite": "workspace:*",
"@swc/core": "^1.6.13",
"@types/express": "^4.17.11",
"@types/jest": "^30.0.0",
"@types/loadable__component": "^5.13.1",
"@types/loadable__server": "^5.12.10",
"@vanilla-extract/integration": "^8.0.1",
"@vanilla-extract/jest-transform": "^1.1.0",
"@vanilla-extract/integration": "catalog:",
"@vanilla-extract/jest-transform": "catalog:",
"@vanilla-extract/vite-plugin": "catalog:",
"@vanilla-extract/webpack-plugin": "^2.2.0",
"@vanilla-extract/webpack-plugin": "catalog:",
"@vitejs/plugin-basic-ssl": "^2.1.0",
"@vitejs/plugin-react": "^5.1.1",
"@vitejs/plugin-react": "^6.0.1",
"@vocab/core": "^1.6.2",
"@vocab/phrase": "^2.2.0",
"@vocab/pseudo-localize": "^1.0.1",
Expand All @@ -120,7 +121,7 @@
"browserslist-config-seek": "3.3.0",
"chalk": "^5.3.0",
"commander": "catalog:",
"cross-spawn": "^7.0.3",
"cross-spawn": "^7.0.6",
"css-loader": "^7.1.2",
"cssnano": "^7.0.7",
"death": "^1.1.0",
Expand All @@ -132,7 +133,7 @@
"eslint": "^9.10.0",
"eslint-config-seek": "^15.0.4",
"exception-formatter": "^2.1.2",
"express": "^4.19.2",
"express": "^4.22.1",
"fastest-levenshtein": "^1.0.16",
"fastest-validator": "^1.9.0",
"fdir": "^6.1.1",
Expand All @@ -150,26 +151,26 @@
"nano-memoize": "^3.0.16",
"node-html-parser": "^7.0.1",
"open": "^10.1.2",
"path-to-regexp": "^6.2.0",
"path-to-regexp": "^6.3.0",
"picomatch": "^4.0.3",
"postcss": "^8.4.0",
"postcss": "^8.5.8",
"postcss-loader": "^8.0.0",
"prettier": "~3.8.0",
"pretty-ms": "^9.2.0",
"react-refresh": "^0.18.0",
"rollup-plugin-visualizer": "^6.0.3",
"rolldown": "^1.0.0-rc.9",
"rollup-plugin-visualizer": "^7.0.1",
"selfsigned": "^3.0.1",
"semver": "^7.3.4",
"serialize-javascript": "^7.0.2",
"semver": "^7.7.4",
"serialize-javascript": "^7.0.4",
"serve-handler": "^6.1.3",
"sort-package-json": "^3.6.0",
"svgo-loader": "^4.0.0",
"terser-webpack-plugin": "^5.1.4",
"typescript": "~5.9.0",
"vite": "catalog:",
"vite-plugin-cjs-interop": "^2.4.0",
"vite-tsconfig-paths": "^6.0.3",
"webpack": "^5.99.8",
"webpack": "^5.105.4",
"webpack-bundle-analyzer": "^5.1.1",
"webpack-dev-server": "<=5.2.0",
"webpack-merge": "^6.0.1",
Expand All @@ -195,7 +196,7 @@
"@types/serve-handler": "^6.1.4",
"@types/webpack-bundle-analyzer": "^4.7.0",
"@types/webpack-node-externals": "^3.0.4",
"@vanilla-extract/css": "^1.17.0",
"@vanilla-extract/css": "catalog:",
"@vocab/react": "^1.1.11",
"braid-design-system": "catalog:",
"esbuild": "^0.27.0",
Expand Down
22 changes: 13 additions & 9 deletions packages/sku/src/services/vite/helpers/config/createConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { SkuContext } from '../../../../context/createSkuContext.js';
import { createRequire } from 'node:module';
import type { InlineConfig } from 'vite';
import { vitePluginVocab } from '@vocab/vite';
import tsconfigPaths from 'vite-tsconfig-paths';
import { cjsInterop } from 'vite-plugin-cjs-interop';
import react from '@vitejs/plugin-react';
import babel from '@rolldown/plugin-babel';
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
import { getVocabConfig } from '../../../vocab/config.js';
import { skuPlugin } from '../../skuPlugin.js';
Expand Down Expand Up @@ -38,6 +38,10 @@ export const createConfig = (
}

return {
resolve: {
// adding this at the top level so that vanilla-extract picks it up. VE doesn't inherit config options from plugins at the moment.
tsconfigPaths: true,
},
plugins: [
/**
* user added plugins
Expand All @@ -48,7 +52,6 @@ export const createConfig = (
* vendor plugins
*/
vocabConfig && vitePluginVocab({ vocabConfig }),
tsconfigPaths(),
cjsInterop({
dependencies: skuContext.serveCjsInteropDependencies,
apply: 'serve',
Expand All @@ -57,13 +60,14 @@ export const createConfig = (
dependencies: skuContext.buildCjsInteropDependencies,
apply: 'build',
}),
react({
babel: {
plugins: [
require.resolve('babel-plugin-macros'),
...(isProductionBuild ? prodBabelPlugins : []),
],
},
react(),
babel({
// turn this on for react-compiler support
// presets: [reactCompilerPreset()],
plugins: [
require.resolve('babel-plugin-macros'),
...(isProductionBuild ? prodBabelPlugins : []),
],
}),
vanillaExtractPlugin(),
/**
Expand Down
24 changes: 15 additions & 9 deletions packages/sku/src/services/vite/plugins/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ export const buildPlugin = ({
build: {
target: browserslistToEsbuild(skuContext.supportedBrowsers),
assetsDir: '',
rollupOptions: {
rolldownOptions: {
output: {
experimentalMinChunkSize: undefined,
manualChunks: (id, ctx) => {
const languageChunkName = createVocabChunks(id, ctx);
if (languageChunkName) {
return languageChunkName;
}
codeSplitting: {
groups: [
{
name: (id, ctx) => {
const languageChunkName = createVocabChunks(id, ctx);
if (languageChunkName) {
return languageChunkName;
}
return null;
},
},
],
},
},
},
Expand All @@ -41,7 +47,7 @@ export const buildPlugin = ({
outDir: outDir.client,
manifest: true,
sourcemap: skuContext.sourceMapsProd,
rollupOptions: {
rolldownOptions: {
// this should be skuContext.paths.clientEntry in sku start-ssr or build-ssr mode
input: clientEntry,
},
Expand All @@ -51,7 +57,7 @@ export const buildPlugin = ({
build: {
ssr: true,
outDir: outDir.ssg,
rollupOptions: {
rolldownOptions: {
// this should be skuContext.paths.serverEntry in sku start-ssr or build-ssr mode
input: skuContext.paths.renderEntry,
output: {
Expand Down
4 changes: 2 additions & 2 deletions packages/sku/src/services/vite/plugins/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const configPlugin = ({
publicDir: false,
root: process.cwd(),
resolve: {
tsconfigPaths: true,
alias: {
__sku_alias__clientEntry: skuContext.paths.clientEntry,
__sku_alias__serverEntry: skuContext.paths.serverEntry,
Expand All @@ -28,7 +29,6 @@ export const configPlugin = ({
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
},

optimizeDeps: {
// crawl all the entries to ensure they get optimized ahead of time. This helps prevent reloads on cold-start.
// Reloads on cold-start cause issues with our Playwright tests, so we need to ensure they get optimized ahead of time.
Expand All @@ -40,7 +40,7 @@ export const configPlugin = ({
renderEntry,
clientEntry,
],
esbuildOptions: {
rolldownOptions: {
plugins: [fixViteVanillaExtractDepScanPlugin()],
},
exclude: skuContext.skipPackageCompatibilityCompilation,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
import type { Plugin } from 'esbuild';
import type { RolldownPluginOption } from 'rolldown';
import { cssFileFilter } from '@vanilla-extract/integration';
import { makePluginName } from '../../helpers/makePluginName.js';
import { dirname } from 'node:path';
import { createRequire } from 'node:module';
import { makePluginName } from '../../helpers/makePluginName.js';

const require = createRequire(import.meta.url);

export const fixViteVanillaExtractDepScanPlugin = (): Plugin => ({
export const fixViteVanillaExtractDepScanPlugin = (): RolldownPluginOption => ({
name: makePluginName('fix-vanilla-extract-dep-scan'),
setup(build) {
build.onResolve({ filter: cssFileFilter }, ({ importer, path }) => ({
path: require.resolve(path, { paths: [dirname(importer)] }),
external: true,
}));

resolveId: {
filter: {
id: cssFileFilter,
},
handler: (source, importer) => {
const id = require.resolve(source, {
paths: importer ? [dirname(importer)] : undefined,
});

return {
id,
// keep the absolute path of the css file so its externalized correctly.
external: 'absolute',
};
},
},
});
15 changes: 9 additions & 6 deletions packages/sku/src/services/vite/plugins/polyfills.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Plugin } from 'vite';
import { exactRegex } from 'rolldown/filter';

import type { SkuContext } from '../../../context/createSkuContext.js';
import { resolvePolyfills } from '../../../utils/resolvePolyfills.js';
Expand All @@ -11,17 +12,19 @@ export const polyfillsPlugin = (skuContext: SkuContext): Plugin => {

return {
name: makePluginName('polyfills'),
resolveId(id) {
if (id === virtualModuleId) {
resolveId: {
filter: { id: exactRegex(virtualModuleId) },
handler() {
return resolvedVirtualModuleId;
}
},
},
load(id) {
if (id === resolvedVirtualModuleId) {
load: {
filter: { id: exactRegex(resolvedVirtualModuleId) },
handler() {
return resolvedPolyfills
.map((polyfillPath) => `import '${polyfillPath}';`)
.join('\n');
}
},
},
};
};
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"peerDependencies": {
"@types/react": "^18.0.0 || ^19.0.0",
"vite": "^7.0.0",
"vite": "^8.0.0",
"react": "^18.0.0 || ^19.0.0"
}
}
Loading
Loading