Skip to content

Commit

Permalink
chore: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Oct 16, 2023
2 parents 72a4624 + 4e763c5 commit 6a5d4dd
Show file tree
Hide file tree
Showing 41 changed files with 555 additions and 707 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@db153baf731265ad02cd490b07f470e2d55e3345 # v39.2.1
uses: tj-actions/changed-files@408093d9ff9c134c33b974e0722ce06b9d6e8263 # v39.2.2
with:
files: |
docs/**
Expand Down
14 changes: 10 additions & 4 deletions docs/guide/ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ If you have questions, the community is usually helpful at [Vite Discord's #ssr

## Example Projects

Vite provides built-in support for server-side rendering (SSR). The Vite playground contains example SSR setups for Vue 3 and React, which can be used as references for this guide:
Vite provides built-in support for server-side rendering (SSR). [`create-vite-extra`](https://github.com/bluwy/create-vite-extra) contains example SSR setups you can use as references for this guide:

- [Vue 3](https://github.com/vitejs/vite-plugin-vue/tree/main/playground/ssr-vue)
- [React](https://github.com/vitejs/vite-plugin-react/tree/main/playground/ssr-react)
- [Vanilla](https://github.com/bluwy/create-vite-extra/tree/master/template-ssr-vanilla)
- [Vue](https://github.com/bluwy/create-vite-extra/tree/master/template-ssr-vue)
- [React](https://github.com/bluwy/create-vite-extra/tree/master/template-ssr-react)
- [Preact](https://github.com/bluwy/create-vite-extra/tree/master/template-ssr-preact)
- [Svelte](https://github.com/bluwy/create-vite-extra/tree/master/template-ssr-svelte)
- [Solid](https://github.com/bluwy/create-vite-extra/tree/master/template-ssr-solid)

You can also scaffold these projects locally by [running `create-vite`](./index.md#scaffolding-your-first-vite-project) and choose `Others > create-vite-extra` under the framework option.

## Source Structure

Expand Down Expand Up @@ -177,7 +183,7 @@ Then, in `server.js` we need to add some production specific logic by checking `
- Move the creation and all usage of the `vite` dev server behind dev-only conditional branches, then add static file serving middlewares to serve files from `dist/client`.
Refer to the [Vue](https://github.com/vitejs/vite-plugin-vue/tree/main/playground/ssr-vue) and [React](https://github.com/vitejs/vite-plugin-react/tree/main/playground/ssr-react) demos for a working setup.
Refer to the [example projects](#example-projects) for a working setup.
## Generating Preload Directives
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,26 @@
"@types/json-stable-stringify": "^1.0.34",
"@types/less": "^3.0.4",
"@types/micromatch": "^4.0.3",
"@types/node": "^18.18.4",
"@types/node": "^18.18.5",
"@types/picomatch": "^2.3.1",
"@types/sass": "~1.43.1",
"@types/stylus": "^0.48.40",
"@types/ws": "^8.5.6",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"@types/ws": "^8.5.7",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"@vitejs/release-scripts": "^1.3.1",
"conventional-changelog-cli": "^3.0.0",
"eslint": "^8.51.0",
"eslint-define-config": "^1.24.1",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-n": "^16.1.0",
"eslint-plugin-n": "^16.2.0",
"eslint-plugin-regexp": "^1.15.0",
"execa": "^8.0.1",
"fs-extra": "^11.1.1",
"lint-staged": "^14.0.1",
"lint-staged": "^15.0.1",
"npm-run-all2": "^6.1.1",
"picocolors": "^1.0.0",
"playwright-chromium": "^1.38.1",
"playwright-chromium": "^1.39.0",
"prettier": "3.0.3",
"rimraf": "^5.0.5",
"rollup": "^4.1.4",
Expand All @@ -83,7 +83,7 @@
"typescript": "^5.2.2",
"unbuild": "^2.0.0",
"vite": "workspace:*",
"vitepress": "1.0.0-rc.21",
"vitepress": "1.0.0-rc.22",
"vitest": "^0.34.6",
"vue": "^3.3.4"
},
Expand All @@ -104,7 +104,7 @@
"eslint --cache --fix"
]
},
"packageManager": "pnpm@8.8.0",
"packageManager": "pnpm@8.9.2",
"pnpm": {
"overrides": {
"vite": "workspace:*"
Expand Down
2 changes: 2 additions & 0 deletions packages/create-vite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ Currently supported template presets include:
- `svelte-ts`
- `solid`
- `solid-ts`
- `qwik`
- `qwik-ts`

You can use `.` for the project name to scaffold in the current directory.

Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"funding": "https://github.com/vitejs/vite?sponsor=1",
"devDependencies": {
"@types/minimist": "^1.2.3",
"@types/prompts": "^2.4.5",
"@types/prompts": "^2.4.6",
"cross-spawn": "^7.0.3",
"kolorist": "^1.8.0",
"minimist": "^1.2.8",
Expand Down
4 changes: 2 additions & 2 deletions packages/create-vite/template-lit-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"preview": "vite preview"
},
"dependencies": {
"lit": "^2.8.0"
"lit": "^3.0.0"
},
"devDependencies": {
"typescript": "^5.2.2",
"vite": "^5.0.0-beta.4"
"vite": "^5.0.0-beta.7"
}
}
4 changes: 2 additions & 2 deletions packages/create-vite/template-lit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"preview": "vite preview"
},
"dependencies": {
"lit": "^2.8.0"
"lit": "^3.0.0"
},
"devDependencies": {
"vite": "^5.0.0-beta.4"
"vite": "^5.0.0-beta.7"
}
}
4 changes: 2 additions & 2 deletions packages/create-vite/template-preact-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"preact": "^10.18.1"
},
"devDependencies": {
"@preact/preset-vite": "^2.5.0",
"@preact/preset-vite": "^2.6.0",
"typescript": "^5.2.2",
"vite": "^5.0.0-beta.4"
"vite": "^5.0.0-beta.7"
}
}
4 changes: 2 additions & 2 deletions packages/create-vite/template-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"preact": "^10.18.1"
},
"devDependencies": {
"@preact/preset-vite": "^2.5.0",
"vite": "^5.0.0-beta.4"
"@preact/preset-vite": "^2.6.0",
"vite": "^5.0.0-beta.7"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-qwik-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"typescript": "^5.2.2",
"vite": "^5.0.0-beta.4"
"vite": "^5.0.0-beta.7"
},
"dependencies": {
"@builder.io/qwik": "^1.2.13"
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-qwik/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"typescript": "^5.2.2",
"vite": "^5.0.0-beta.4"
"vite": "^5.0.0-beta.7"
},
"dependencies": {
"@builder.io/qwik": "^1.2.13"
Expand Down
10 changes: 5 additions & 5 deletions packages/create-vite/template-react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.25",
"@types/react-dom": "^18.2.11",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"@vitejs/plugin-react": "^4.1.0",
"eslint": "^8.51.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"typescript": "^5.2.2",
"vite": "^5.0.0-beta.4"
"vite": "^5.0.0-beta.7"
}
}
6 changes: 3 additions & 3 deletions packages/create-vite/template-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.25",
"@types/react-dom": "^18.2.11",
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13",
"@vitejs/plugin-react": "^4.1.0",
"eslint": "^8.51.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"vite": "^5.0.0-beta.4"
"vite": "^5.0.0-beta.7"
}
}
6 changes: 3 additions & 3 deletions packages/create-vite/template-solid-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"preview": "vite preview"
},
"dependencies": {
"solid-js": "^1.7.12"
"solid-js": "^1.8.1"
},
"devDependencies": {
"typescript": "^5.2.2",
"vite": "^5.0.0-beta.4",
"vite-plugin-solid": "^2.7.0"
"vite": "^5.0.0-beta.7",
"vite-plugin-solid": "^2.7.1"
}
}
6 changes: 3 additions & 3 deletions packages/create-vite/template-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"preview": "vite preview"
},
"dependencies": {
"solid-js": "^1.7.12"
"solid-js": "^1.8.1"
},
"devDependencies": {
"vite": "^5.0.0-beta.4",
"vite-plugin-solid": "^2.7.0"
"vite": "^5.0.0-beta.7",
"vite-plugin-solid": "^2.7.1"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-svelte-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"svelte-check": "^3.5.2",
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"vite": "^5.0.0-beta.4"
"vite": "^5.0.0-beta.7"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^3.0.0-next.0",
"svelte": "^4.2.1",
"vite": "^5.0.0-beta.4"
"vite": "^5.0.0-beta.7"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-vanilla-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
},
"devDependencies": {
"typescript": "^5.2.2",
"vite": "^5.0.0-beta.4"
"vite": "^5.0.0-beta.7"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"preview": "vite preview"
},
"devDependencies": {
"vite": "^5.0.0-beta.4"
"vite": "^5.0.0-beta.7"
}
}
4 changes: 2 additions & 2 deletions packages/create-vite/template-vue-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"devDependencies": {
"@vitejs/plugin-vue": "^4.4.0",
"typescript": "^5.2.2",
"vite": "^5.0.0-beta.4",
"vue-tsc": "^1.8.18"
"vite": "^5.0.0-beta.7",
"vue-tsc": "^1.8.19"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.4.0",
"vite": "^5.0.0-beta.4"
"vite": "^5.0.0-beta.7"
}
}
4 changes: 2 additions & 2 deletions packages/plugin-legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
"funding": "https://github.com/vitejs/vite?sponsor=1",
"dependencies": {
"@babel/core": "^7.23.0",
"@babel/preset-env": "^7.22.20",
"@babel/core": "^7.23.2",
"@babel/preset-env": "^7.23.2",
"browserslist": "^4.22.1",
"core-js": "^3.33.0",
"magic-string": "^0.30.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
"@ampproject/remapping": "^2.2.1",
"@jridgewell/trace-mapping": "^0.3.19",
"@rollup/plugin-alias": "^5.0.1",
"@rollup/plugin-commonjs": "^25.0.5",
"@rollup/plugin-dynamic-import-vars": "^2.0.6",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-dynamic-import-vars": "^2.0.7",
"@rollup/plugin-json": "^6.0.1",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-typescript": "^11.1.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ function prettifyMessage(m: Message, code: string): string {
return res + `\n`
}

let tsconfckCache: TSConfckCache<TSConfckParseResult>
let tsconfckCache: TSConfckCache<TSConfckParseResult> | undefined

async function loadTsconfigJsonForFile(
filename: string,
Expand Down Expand Up @@ -518,7 +518,7 @@ async function reloadOnTsconfigChange(changedFile: string) {
server.moduleGraph.invalidateAll()

// reset tsconfck so that recompile works with up2date configs
tsconfckCache.clear()
tsconfckCache?.clear()

// server may not be available if vite config is updated at the same time
if (server) {
Expand Down
6 changes: 5 additions & 1 deletion packages/vite/src/node/server/moduleGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ export class ModuleGraph {
mod.ssrModule = null
mod.ssrError = null

// Fix #3033
// https://github.com/vitejs/vite/issues/3033
// Given b.js -> c.js -> b.js (arrow means top-level import), if c.js self-accepts
// and refetches itself, the execution order becomes c.js -> b.js -> c.js. The import
// order matters here as it will fail. The workaround for now is to not hmr invalidate
// b.js so that c.js refetches the already cached b.js, skipping the import loop.
if (hmrBoundaries.includes(mod)) {
return
}
Expand Down
3 changes: 2 additions & 1 deletion packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ export const isDataUrl = (url: string): boolean => dataUrlRE.test(url)
export const virtualModuleRE = /^virtual-module:.*/
export const virtualModulePrefix = 'virtual-module:'

const knownJsSrcRE = /\.(?:[jt]sx?|m[jt]s|vue|marko|svelte|astro|imba)(?:$|\?)/
const knownJsSrcRE =
/\.(?:[jt]sx?|m[jt]s|vue|marko|svelte|astro|imba|mdx)(?:$|\?)/
export const isJSRequest = (url: string): boolean => {
url = cleanUrl(url)
if (knownJsSrcRE.test(url)) {
Expand Down
2 changes: 1 addition & 1 deletion playground/backend-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"preview": "vite preview"
},
"devDependencies": {
"sass": "^1.69.0",
"sass": "^1.69.3",
"tailwindcss": "^3.3.3",
"fast-glob": "^3.3.1"
}
Expand Down
2 changes: 1 addition & 1 deletion playground/css-sourcemap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"devDependencies": {
"less": "^4.2.0",
"magic-string": "^0.30.5",
"sass": "^1.69.0",
"sass": "^1.69.3",
"stylus": "^0.60.0",
"sugarss": "^4.0.1"
}
Expand Down
2 changes: 1 addition & 1 deletion playground/css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"fast-glob": "^3.3.1",
"less": "^4.2.0",
"postcss-nested": "^6.0.1",
"sass": "^1.69.0",
"sass": "^1.69.3",
"stylus": "^0.60.0",
"sugarss": "^4.0.1"
}
Expand Down
8 changes: 4 additions & 4 deletions playground/hmr/__tests__/hmr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,11 +800,11 @@ if (import.meta.hot) {
await untilUpdated(() => el.textContent(), '2')
})

test('issue-3033', async () => {
await page.goto(viteTestUrl + '/issue-3033/index.html')
const el = await page.$('.issue-3033')
test('hmr works for self-accepted module within circular imported files', async () => {
await page.goto(viteTestUrl + '/self-accept-within-circular/index.html')
const el = await page.$('.self-accept-within-circular')
expect(await el.textContent()).toBe('c')
editFile('issue-3033/c.js', (code) =>
editFile('self-accept-within-circular/c.js', (code) =>
code.replace(`export const c = 'c'`, `export const c = 'cc'`),
)
await untilUpdated(() => el.textContent(), 'cc')
Expand Down
2 changes: 0 additions & 2 deletions playground/hmr/issue-3033/index.html

This file was deleted.

File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 6a5d4dd

Please sign in to comment.