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 Apr 26, 2023
2 parents ea6dfc3 + 84c4118 commit 7479f40
Show file tree
Hide file tree
Showing 33 changed files with 193 additions and 33 deletions.
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export default defineConfig({
text: 'Resources',
items: [
{ text: 'Team', link: '/team' },
{ text: 'Releases', link: '/releases' },
{
items: [
{
Expand Down
61 changes: 61 additions & 0 deletions docs/releases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Releases

Vite releases follow [Semantic Versioning](https://semver.org/). You can see the latest stable version of Vite in the [Vite npm package page](https://www.npmjs.com/package/vite).

A full changelog of past releases is [available on GitHub](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md).

::: tip note
The next Vite Major release will happen after the Node 16 EOL in September.

Check out the [Vite 5 discussion](https://github.com/vitejs/vite/discussions/12466) for more information.
:::

## Release Cycle​

Vite does not have a fixed release cycle.

- **Patch** releases are released as needed.
- **Minor** releases always contain new features and are also released as needed. Minor releases always go through a beta pre-release phase.
- **Major** releases generally align with [Node.js EOL schedule](https://endoflife.date/nodejs), and will be announced ahead of time. These releases will go through an early discussion phase, and both alpha and beta pre-release phases.

The previous Vite Major will keep receiving important fixes and security patches. After that, it would only get updates if there are security concerns. We recommend updating Vite regularly. Check out the [Migration Guides](https://vitejs.dev/guide/migration.html) when you update to each Major.

The Vite team partners with the main projects in the ecosystem to test new Vite versions before they are released through the [vite-ecosystem-ci project](https://github.com/vitejs/vite-ecosystem-ci). Most projects using Vite should be able to quickly offer support or migrate to new versions as soon as they are released.

## Semantic Versioning Edge Cases

### TypeScript Definitions​

We may ship incompatible changes to TypeScript definitions between minor versions. This is because:

- Sometimes TypeScript itself ships incompatible changes between minor versions, and we may have to adjust types to support newer versions of TypeScript.
- Occasionally we may need to adopt features that are only available in a newer version of TypeScript, raising the minimum required version of TypeScript.
- If you are using TypeScript, you can use a semver range that locks the current minor and manually upgrade when a new minor version of Vite is released.

### esbuild

[esbuild](https://esbuild.github.io/) is pre-1.0.0 and sometimes it has a breaking change we may need to include to have access to newer features and performance improvements. We may bump the esbuild's version in a Vite Minor.

### Node.js non-LTS versions

Non-LTS Node.js versions (odd-numbered) are not tested as part of Vite's CI, but they should still work before their [EOL](https://endoflife.date/nodejs).

## Pre Releases​

Minor releases typically go through a non-fixed number of beta releases. Major releases will go through an alpha phase and a beta phase.

Pre-releases allow early adopters and maintainers from the Ecosystem to do integration and stability testing, and provide feedback. Do not use pre-releases in production. All pre-releases are considered unstable and may ship breaking changes in between. Always pin to exact versions when using pre-releases.

## Deprecations​

We periodically deprecate features that have been superseded by better alternatives in Minor releases. Deprecated features will continue to work with a type or logged warning. They will be removed in the next major release after entering deprecated status. The [Migration Guide](https://vitejs.dev/guide/migration.html) for each major will list these removals and document an upgrade path for them.

## Experimental Features​

Some features are marked as experimental when released in a stable version of Vite. Experimental features allows us to gather real-world experience to influence their final design. The goal is to let users provide feedback by testing them in production. Experimental features themselves are considered unstable, and should only be used in a controlled manner. These features may change between Minors, so users must pin their Vite version when they rely on them.

## RFCs​

Many changes, including features, bug fixes, and documentation improvements are discussed, implemented and reviewed via GitHub discussions, issues, and pull requests workflow. For substantial changes that would affect several downstream projects, we offer a Request For Comments (RFC) process to help gather consensus among the Vite core team, the Ecosystem, and the community.

Continue reading about the RFC process in the [vitejs/rfcs](https://github.com/vitejs/rfcs) repo on GitHub.
8 changes: 8 additions & 0 deletions packages/create-vite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## <small>4.3.1 (2023-04-25)</small>

* chore(create-vite): bump vue-tsc (#12952) ([30fd101](https://github.com/vitejs/vite/commit/30fd101)), closes [#12952](https://github.com/vitejs/vite/issues/12952)
* chore(create-vite): update to plugin-react 4.0.0 ([14cd939](https://github.com/vitejs/vite/commit/14cd939))
* fix(create-vite): fix h1 css selector in lit templates (#12951) ([21c61cb](https://github.com/vitejs/vite/commit/21c61cb)), closes [#12951](https://github.com/vitejs/vite/issues/12951)



## 4.3.0 (2023-04-20)

* fix(create-vite): update template-lit-ts tsconfig (fix #12854) (#12855) ([c186815](https://github.com/vitejs/vite/commit/c186815)), closes [#12854](https://github.com/vitejs/vite/issues/12854) [#12855](https://github.com/vitejs/vite/issues/12855)
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-vite",
"version": "4.3.0",
"version": "4.3.1",
"type": "module",
"license": "MIT",
"author": "Evan You",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-lit-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
},
"devDependencies": {
"typescript": "^5.0.2",
"vite": "^4.3.0"
"vite": "^4.3.2"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-lit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"lit": "^2.7.2"
},
"devDependencies": {
"vite": "^4.3.0"
"vite": "^4.3.2"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-preact-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"devDependencies": {
"@preact/preset-vite": "^2.5.0",
"typescript": "^5.0.2",
"vite": "^4.3.0"
"vite": "^4.3.2"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
},
"devDependencies": {
"@preact/preset-vite": "^2.5.0",
"vite": "^4.3.0"
"vite": "^4.3.2"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.3.4",
"typescript": "^5.0.2",
"vite": "^4.3.0"
"vite": "^4.3.2"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.3.4",
"vite": "^4.3.0"
"vite": "^4.3.2"
}
}
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": "^2.10.3",
"tslib": "^2.5.0",
"typescript": "^5.0.2",
"vite": "^4.3.0"
"vite": "^4.3.2"
}
}
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": "^2.0.4",
"svelte": "^3.58.0",
"vite": "^4.3.0"
"vite": "^4.3.2"
}
}
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.0.2",
"vite": "^4.3.0"
"vite": "^4.3.2"
}
}
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": "^4.3.0"
"vite": "^4.3.2"
}
}
2 changes: 1 addition & 1 deletion 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.1.0",
"typescript": "^5.0.2",
"vite": "^4.3.0",
"vite": "^4.3.2",
"vue-tsc": "^1.4.2"
}
}
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.1.0",
"vite": "^4.3.0"
"vite": "^4.3.2"
}
}
8 changes: 8 additions & 0 deletions packages/plugin-legacy/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## <small>4.0.3 (2023-04-25)</small>

* feat(plugin-legacy): support file protocol (#8524) ([7a87ff4](https://github.com/vitejs/vite/commit/7a87ff4)), closes [#8524](https://github.com/vitejs/vite/issues/8524)
* refactor(eslint): migrate to `eslint-plugin-n` (#12895) ([62ebe28](https://github.com/vitejs/vite/commit/62ebe28)), closes [#12895](https://github.com/vitejs/vite/issues/12895)
* fix(deps): update all non-major dependencies (#12389) ([3e60b77](https://github.com/vitejs/vite/commit/3e60b77)), closes [#12389](https://github.com/vitejs/vite/issues/12389)



## <small>4.0.2 (2023-03-16)</small>

* chore(deps): update all non-major dependencies (#12299) ([b41336e](https://github.com/vitejs/vite/commit/b41336e)), closes [#12299](https://github.com/vitejs/vite/issues/12299)
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-legacy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vitejs/plugin-legacy",
"version": "4.0.2",
"version": "4.0.3",
"license": "MIT",
"author": "Evan You",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-legacy/src/snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const systemJSInlineCode = `System.import(document.getElementById('${lega
const detectModernBrowserVarName = '__vite_is_modern_browser'
export const detectModernBrowserDetector =
'import.meta.url;import("_").catch(()=>1);async function* g(){};'
export const detectModernBrowserCode = `${detectModernBrowserDetector}window.${detectModernBrowserVarName}=true;`
export const detectModernBrowserCode = `${detectModernBrowserDetector}if(location.protocol!="file:"){window.${detectModernBrowserVarName}=true}`
export const dynamicFallbackInlineCode = `!function(){if(window.${detectModernBrowserVarName})return;console.warn("vite: loading legacy chunks, syntax error above and the same error below should be ignored");var e=document.getElementById("${legacyPolyfillId}"),n=document.createElement("script");n.src=e.src,n.onload=function(){${systemJSInlineCode}},document.body.appendChild(n)}();`

export const modernChunkLegacyGuard = `export function __vite_legacy_guard(){${detectModernBrowserDetector}};`
12 changes: 12 additions & 0 deletions packages/vite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## <small>4.3.2 (2023-04-25)</small>

* fix: status optional in windows network drive regex (fix: #12948) (#12949) ([f781fc6](https://github.com/vitejs/vite/commit/f781fc6)), closes [#12948](https://github.com/vitejs/vite/issues/12948) [#12949](https://github.com/vitejs/vite/issues/12949)
* fix: use realpathSync for node <16.18 on windows (#12971) ([965839c](https://github.com/vitejs/vite/commit/965839c)), closes [#12971](https://github.com/vitejs/vite/issues/12971)
* fix(ssr): hoist statements after hashbang (#12985) ([07bd6d1](https://github.com/vitejs/vite/commit/07bd6d1)), closes [#12985](https://github.com/vitejs/vite/issues/12985)
* chore: build time message setting color (#12940) ([ada7cd5](https://github.com/vitejs/vite/commit/ada7cd5)), closes [#12940](https://github.com/vitejs/vite/issues/12940)
* chore: remove extra ) in changelog (#12932) ([e7924d2](https://github.com/vitejs/vite/commit/e7924d2)), closes [#12932](https://github.com/vitejs/vite/issues/12932)
* chore: upgrade rollup (#12965) ([bdb2f25](https://github.com/vitejs/vite/commit/bdb2f25)), closes [#12965](https://github.com/vitejs/vite/issues/12965)
* refactor: resolveExports (#10917) ([ad21ec3](https://github.com/vitejs/vite/commit/ad21ec3)), closes [#10917](https://github.com/vitejs/vite/issues/10917)



## <small>4.3.1 (2023-04-20)</small>

* fix: revert ensure module in graph before transforming (#12774) (#12929) ([9cc93a5](https://github.com/vitejs/vite/commit/9cc93a5)), closes [#12774](https://github.com/vitejs/vite/issues/12774) [#12929](https://github.com/vitejs/vite/issues/12929)
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite",
"version": "4.3.1",
"version": "4.3.2",
"type": "module",
"license": "MIT",
"author": "Evan You",
Expand Down
8 changes: 7 additions & 1 deletion packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from 'node:fs'
import fsp from 'node:fs/promises'
import path from 'node:path'
import { pathToFileURL } from 'node:url'
import { promisify } from 'node:util'
import { performance } from 'node:perf_hooks'
import { createRequire } from 'node:module'
import colors from 'picocolors'
Expand Down Expand Up @@ -69,6 +70,7 @@ import type { ResolvedSSROptions, SSROptions } from './ssr'
import { resolveSSROptions } from './ssr'

const debug = createDebugger('vite:config')
const promisifiedRealpath = promisify(fs.realpath)

export type {
RenderBuiltAssetUrl,
Expand Down Expand Up @@ -1106,7 +1108,11 @@ async function loadConfigFromBundledFile(
// for cjs, we can register a custom loader via `_require.extensions`
else {
const extension = path.extname(fileName)
const realFileName = await fsp.realpath(fileName)
// We don't use fsp.realpath() here because it has the same behaviour as
// fs.realpath.native. On some Windows systems, it returns uppercase volume
// letters (e.g. "C:\") while the Node.js loader uses lowercase volume letters.
// See https://github.com/vitejs/vite/issues/12923
const realFileName = await promisifiedRealpath(fileName)
const loaderExt = extension in _require.extensions ? extension : '.js'
const defaultLoader = _require.extensions[loaderExt]!
_require.extensions[loaderExt] = (module: NodeModule, filename: string) => {
Expand Down
13 changes: 13 additions & 0 deletions packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,19 @@ console.log("it can parse the hashbang")`,
`)
})

test('import hoisted after hashbang', async () => {
expect(
await ssrTransformSimpleCode(
`#!/usr/bin/env node
import "foo"`,
),
).toMatchInlineSnapshot(`
"#!/usr/bin/env node
const __vite_ssr_import_0__ = await __vite_ssr_import__(\\"foo\\");
"
`)
})

// #10289
test('track scope by class, function, condition blocks', async () => {
const code = `
Expand Down
13 changes: 9 additions & 4 deletions packages/vite/src/node/ssr/ssrTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export const ssrDynamicImportKey = `__vite_ssr_dynamic_import__`
export const ssrExportAllKey = `__vite_ssr_exportAll__`
export const ssrImportMetaKey = `__vite_ssr_import_meta__`

const hashbangRE = /^#!.*\n/

export async function ssrTransform(
code: string,
inMap: SourceMap | null,
Expand Down Expand Up @@ -92,13 +94,16 @@ async function ssrTransformScript(
const idToImportMap = new Map<string, string>()
const declaredConst = new Set<string>()

// hoist at the start of the file, after the hashbang
const hoistIndex = code.match(hashbangRE)?.[0].length ?? 0

function defineImport(source: string) {
deps.add(source)
const importId = `__vite_ssr_import_${uid++}__`
// There will be an error if the module is called before it is imported,
// so the module import statement is hoisted to the top
s.appendLeft(
0,
hoistIndex,
`const ${importId} = await ${ssrImportKey}(${JSON.stringify(source)});\n`,
)
return importId
Expand Down Expand Up @@ -165,7 +170,7 @@ async function ssrTransformScript(
// hoist re-exports near the defined import so they are immediately exported
for (const spec of node.specifiers) {
defineExport(
0,
hoistIndex,
spec.exported.name,
`${importId}.${spec.local.name}`,
)
Expand Down Expand Up @@ -214,9 +219,9 @@ async function ssrTransformScript(
const importId = defineImport(node.source.value as string)
// hoist re-exports near the defined import so they are immediately exported
if (node.exported) {
defineExport(0, node.exported.name, `${importId}`)
defineExport(hoistIndex, node.exported.name, `${importId}`)
} else {
s.appendLeft(0, `${ssrExportAllKey}(${importId});\n`)
s.appendLeft(hoistIndex, `${ssrExportAllKey}(${importId});\n`)
}
}
}
Expand Down
17 changes: 15 additions & 2 deletions playground/cli/__tests__/cli.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from 'vitest'
import { port } from './serve'
import { page } from '~utils'
import { port, streams } from './serve'
import { editFile, page, withRetry } from '~utils'

test('cli should work', async () => {
// this test uses a custom serve implementation, so regular helpers for browserLogs and goto don't work
Expand All @@ -12,9 +12,22 @@ test('cli should work', async () => {
try {
page.on('console', onConsole)
await page.goto(`http://localhost:${port}/`)

expect(await page.textContent('.app')).toBe('vite cli works!')
expect(logs.some((msg) => msg.match('vite cli works!'))).toBe(true)
} finally {
page.off('console', onConsole)
}
})

test('should restart', async () => {
editFile('./vite.config.js', (content) => content)
await withRetry(async () => {
expect(streams.server.out).toEqual(
expect.arrayContaining([expect.stringMatching('server restarted')]),
)
expect(streams.server.out).not.toEqual(
expect.arrayContaining([expect.stringMatching('error')]),
)
})
})
9 changes: 6 additions & 3 deletions playground/cli/__tests__/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ import {
} from '~utils'

export const port = ports.cli

export const streams = {} as {
build: { out: string[]; err: string[] }
server: { out: string[]; err: string[] }
}
export async function serve() {
// collect stdout and stderr streams from child processes here to avoid interfering with regular vitest output
const streams = {
Object.assign(streams, {
build: { out: [], err: [] },
server: { out: [], err: [] },
}
})
// helpers to collect streams
const collectStreams = (name, process) => {
process.stdout.on('data', (d) => streams[name].out.push(d.toString()))
Expand Down
2 changes: 1 addition & 1 deletion playground/dynamic-import/__tests__/dynamic-import.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ test('should load dynamic import with vars', async () => {

test('should load dynamic import with vars multiline', async () => {
await untilUpdated(
() => page.textContent('.dynamic-import-with-vars'),
() => page.textContent('.dynamic-import-with-vars-multiline'),
'hello',
true,
)
Expand Down

0 comments on commit 7479f40

Please sign in to comment.