Skip to content

Commit 22d7bd9

Browse files
committed
chore: merge main
2 parents 8915ca5 + 4dcf9c4 commit 22d7bd9

File tree

24 files changed

+153
-64
lines changed

24 files changed

+153
-64
lines changed

docs/guide/build.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The production bundle assumes support for modern JavaScript. By default, Vite ta
1313

1414
You can specify custom targets via the [`build.target` config option](/config/build-options.md#build-target), where the lowest target is `es2015`.
1515

16-
Note that by default, Vite only handles syntax transforms and **does not cover polyfills**. You can check out [Polyfill.io](https://polyfill.io/v3/) which is a service that automatically generates polyfill bundles based on the user's browser UserAgent string.
16+
Note that by default, Vite only handles syntax transforms and **does not cover polyfills**. You can check out [Polyfill.io](https://polyfill.io/) which is a service that automatically generates polyfill bundles based on the user's browser UserAgent string.
1717

1818
Legacy browsers can be supported via [@vitejs/plugin-legacy](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy), which will automatically generate legacy chunks and corresponding ES language feature polyfills. The legacy chunks are conditionally loaded only in browsers that do not have native ESM support.
1919

docs/guide/migration.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,29 @@ CLI shortcuts, like `r` to restart the dev server, now require an additional `En
5151

5252
This change prevents Vite from swallowing and controlling OS-specific shortcuts, allowing better compatibility when combining the Vite dev server with other processes, and avoids the [previous caveats](https://github.com/vitejs/vite/pull/14342).
5353

54+
### Remove `resolvePackageEntry` and `resolvePackageData` APIs
55+
56+
The `resolvePackageEntry` and `resolvePackageData` APIs are removed as they exposed Vite's internals and blocked potential Vite 4.3 optimizations in the past. These APIs can be replaced with third-party packages, for example:
57+
58+
- `resolvePackageEntry`: [`import.meta.resolve`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve) or the [`import-meta-resolve`](https://github.com/wooorm/import-meta-resolve) package.
59+
- `resolvePackageData`: Same as above, and crawl up the package directory to get the root `package.json`. Or use the community [`vitefu`](https://github.com/svitejs/vitefu) package.
60+
61+
```js
62+
import { resolve } from 'import-meta-env'
63+
import { findDepPkgJsonPath } from 'vitefu'
64+
import fs from 'node:fs'
65+
66+
const pkg = 'my-lib'
67+
const basedir = process.cwd()
68+
69+
// `resolvePackageEntry`:
70+
const packageEntry = resolve(pkg, basedir)
71+
72+
// `resolvePackageData`:
73+
const packageJsonPath = findDepPkgJsonPath(pkg, basedir)
74+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))
75+
```
76+
5477
## Removed Deprecated APIs
5578

5679
- Default exports of CSS files (e.g `import style from './foo.css'`): Use the `?inline` query instead
@@ -69,6 +92,12 @@ Also there are other breaking changes which only affect few users.
6992
- Top level `this` was rewritten to `globalThis` by default when building. This behavior is now removed.
7093
- [[#14231] feat!: add extension to internal virtual modules](https://github.com/vitejs/vite/pull/14231)
7194
- Internal virtual modules' id now has an extension (`.js`).
95+
- [[#14583] refactor!: remove exporting internal APIs](https://github.com/vitejs/vite/pull/14583)
96+
- Removed accidentally exported internal APIs: `isDepsOptimizerEnabled` and `getDepOptimizationConfig`
97+
- Removed exported internal types: `DepOptimizationResult`, `DepOptimizationProcessing`, and `DepsOptimizer`
98+
- Renamed `ResolveWorkerOptions` type to `ResolvedWorkerOptions`
99+
- [[#5657] fix: return 404 for resources requests outside the base path](https://github.com/vitejs/vite/pull/5657)
100+
- In the past, Vite responded to requests outside the base path without `Accept: text/html`, as if they were requested with the base path. Vite no longer does that and responds with 404 instead.
72101

73102
## Migration from v3
74103

packages/vite/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## 5.0.0-beta.7 (2023-10-12)
2+
3+
* feat: add off method to ViteHotContext (issue #14185) (#14518) ([31333bb](https://github.com/vitejs/vite/commit/31333bb)), closes [#14185](https://github.com/vitejs/vite/issues/14185) [#14518](https://github.com/vitejs/vite/issues/14518)
4+
* feat: show better parse error in build (#14600) ([84df7db](https://github.com/vitejs/vite/commit/84df7db)), closes [#14600](https://github.com/vitejs/vite/issues/14600)
5+
* chore(config): improve the readability of warning messages (#14594) ([b43b4df](https://github.com/vitejs/vite/commit/b43b4df)), closes [#14594](https://github.com/vitejs/vite/issues/14594)
6+
* fix: off-by-one bug in HTML whitespace removal (#14589) ([f54e6d8](https://github.com/vitejs/vite/commit/f54e6d8)), closes [#14589](https://github.com/vitejs/vite/issues/14589)
7+
* fix(html): import expression in classic script for dev (#14595) ([ea47b8f](https://github.com/vitejs/vite/commit/ea47b8f)), closes [#14595](https://github.com/vitejs/vite/issues/14595)
8+
* fix(html): inline style attribute not working in dev (#14592) ([a4a17b8](https://github.com/vitejs/vite/commit/a4a17b8)), closes [#14592](https://github.com/vitejs/vite/issues/14592)
9+
* fix(html): relative paths without leading dot wasn't rewritten (#14591) ([0a38e3b](https://github.com/vitejs/vite/commit/0a38e3b)), closes [#14591](https://github.com/vitejs/vite/issues/14591)
10+
* fix(proxy): correct the logic of bypass returning false (#14579) ([261633a](https://github.com/vitejs/vite/commit/261633a)), closes [#14579](https://github.com/vitejs/vite/issues/14579)
11+
* build: clean generated type file (#14582) ([fffe16e](https://github.com/vitejs/vite/commit/fffe16e)), closes [#14582](https://github.com/vitejs/vite/issues/14582)
12+
* build: use rollup-plugin-dts (#14571) ([d89725b](https://github.com/vitejs/vite/commit/d89725b)), closes [#14571](https://github.com/vitejs/vite/issues/14571)
13+
14+
15+
116
## 5.0.0-beta.6 (2023-10-10)
217

318
* refactor(css): make `getEmptyChunkReplacer` for unit test (#14528) ([18900fd](https://github.com/vitejs/vite/commit/18900fd)), closes [#14528](https://github.com/vitejs/vite/issues/14528)

packages/vite/index.cjs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ asyncFunctions.forEach((name) => {
2525
import('./dist/node/index.js').then((i) => i[name](...args))
2626
})
2727

28-
// some sync functions are marked not supported due to their complexity and uncommon usage
29-
const unsupportedCJS = ['resolvePackageEntry', 'resolvePackageData']
30-
unsupportedCJS.forEach((name) => {
31-
module.exports[name] = () => {
32-
throw new Error(
33-
`"${name}" is not supported in CJS build of Vite 4.\nPlease use ESM or dynamic imports \`const { ${name} } = await import('vite')\`.`,
34-
)
35-
}
36-
})
37-
3828
function warnCjsUsage() {
3929
if (process.env.VITE_CJS_IGNORE_WARNING) return
4030
globalThis.__vite_cjs_skip_clear_screen = true

packages/vite/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vite",
3-
"version": "5.0.0-beta.6",
3+
"version": "5.0.0-beta.7",
44
"type": "module",
55
"license": "MIT",
66
"author": "Evan You",
@@ -135,7 +135,7 @@
135135
"source-map-support": "^0.5.21",
136136
"strip-ansi": "^7.1.0",
137137
"strip-literal": "^1.3.0",
138-
"tsconfck": "^3.0.0-next.9",
138+
"tsconfck": "^3.0.0",
139139
"tslib": "^2.6.2",
140140
"types": "link:./types",
141141
"ufo": "^1.3.1",

packages/vite/src/node/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { ServerOptions } from './server'
88
import type { LogLevel } from './logger'
99
import { createLogger } from './logger'
1010
import { VERSION } from './constants'
11-
import { resolveConfig } from '.'
11+
import { resolveConfig } from './config'
1212

1313
const cli = cac('vite')
1414

packages/vite/src/node/config.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,6 @@ import { resolveSSROptions } from './ssr'
7474
const debug = createDebugger('vite:config')
7575
const promisifiedRealpath = promisify(fs.realpath)
7676

77-
export type {
78-
RenderBuiltAssetUrl,
79-
ModulePreloadOptions,
80-
ResolvedModulePreloadOptions,
81-
ResolveModulePreloadDependenciesFn,
82-
} from './build'
83-
84-
// NOTE: every export in this file is re-exported from ./index.ts so it will
85-
// be part of the public API.
86-
8777
export interface ConfigEnv {
8878
command: 'build' | 'serve'
8979
mode: string
@@ -327,7 +317,7 @@ export interface LegacyOptions {
327317
*/
328318
}
329319

330-
export interface ResolveWorkerOptions extends PluginHookUtils {
320+
export interface ResolvedWorkerOptions extends PluginHookUtils {
331321
format: 'es' | 'iife'
332322
plugins: Plugin[]
333323
rollupOptions: RollupOptions
@@ -377,7 +367,7 @@ export type ResolvedConfig = Readonly<
377367
optimizeDeps: DepOptimizationOptions
378368
/** @internal */
379369
packageCache: PackageCache
380-
worker: ResolveWorkerOptions
370+
worker: ResolvedWorkerOptions
381371
appType: AppType
382372
experimental: ExperimentalOptions
383373
} & PluginHookUtils
@@ -682,7 +672,7 @@ export async function resolveConfig(
682672
...workerPostPlugins,
683673
]
684674
workerConfig = await runConfigHook(workerConfig, workerUserPlugins, configEnv)
685-
const resolvedWorkerOptions: ResolveWorkerOptions = {
675+
const resolvedWorkerOptions: ResolvedWorkerOptions = {
686676
format: workerConfig.worker?.format || 'iife',
687677
plugins: [],
688678
rollupOptions: workerConfig.worker?.rollupOptions || {},

packages/vite/src/node/index.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
11
import type * as Rollup from 'rollup'
22

33
export type { Rollup }
4-
export * from './config'
4+
export {
5+
defineConfig,
6+
loadConfigFromFile,
7+
resolveConfig,
8+
sortUserPlugins,
9+
} from './config'
510
export { createServer } from './server'
611
export { preview } from './preview'
712
export { build } from './build'
813
export { optimizeDeps } from './optimizer'
914
export { formatPostcssSourceMap, preprocessCSS } from './plugins/css'
1015
export { transformWithEsbuild } from './plugins/esbuild'
11-
export { resolvePackageEntry } from './plugins/resolve'
12-
export { resolvePackageData } from './packages'
1316
export { buildErrorMessage } from './server/middlewares/error'
1417
export * from './publicUtils'
1518

1619
// additional types
20+
export type {
21+
AppType,
22+
ConfigEnv,
23+
ExperimentalOptions,
24+
InlineConfig,
25+
LegacyOptions,
26+
PluginHookUtils,
27+
PluginOption,
28+
ResolveFn,
29+
ResolvedWorkerOptions,
30+
ResolvedConfig,
31+
UserConfig,
32+
UserConfigExport,
33+
UserConfigFn,
34+
UserConfigFnObject,
35+
UserConfigFnPromise,
36+
} from './config'
1737
export type { FilterPattern } from './utils'
1838
export type { CorsOptions, CorsOrigin, CommonServerOptions } from './http'
1939
export type {
@@ -30,6 +50,9 @@ export type {
3050
LibraryFormats,
3151
RenderBuiltAssetUrl,
3252
ResolvedBuildOptions,
53+
ModulePreloadOptions,
54+
ResolvedModulePreloadOptions,
55+
ResolveModulePreloadDependenciesFn,
3356
} from './build'
3457
export type {
3558
PreviewOptions,
@@ -41,10 +64,7 @@ export type {
4164
DepOptimizationMetadata,
4265
DepOptimizationOptions,
4366
DepOptimizationConfig,
44-
DepOptimizationResult,
45-
DepOptimizationProcessing,
4667
OptimizedDepInfo,
47-
DepsOptimizer,
4868
ExportsData,
4969
} from './optimizer'
5070
export type {
@@ -54,7 +74,6 @@ export type {
5474
SSRTarget,
5575
} from './ssr'
5676
export type { Plugin, HookHandler } from './plugin'
57-
export type { PackageCache, PackageData } from './packages'
5877
export type {
5978
Logger,
6079
LogOptions,

packages/vite/src/node/optimizer/esbuildDepPlugin.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import path from 'node:path'
22
import type { ImportKind, Plugin } from 'esbuild'
33
import { KNOWN_ASSET_TYPES } from '../constants'
4-
import { getDepOptimizationConfig } from '..'
5-
import type { PackageCache, ResolvedConfig } from '..'
4+
import type { PackageCache } from '../packages'
5+
import { getDepOptimizationConfig } from '../config'
6+
import type { ResolvedConfig } from '../config'
67
import {
78
escapeRegex,
89
flattenId,

packages/vite/src/node/preview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import { printServerUrls } from './logger'
2121
import { bindCLIShortcuts } from './shortcuts'
2222
import type { BindCLIShortcutsOptions } from './shortcuts'
2323
import { DEFAULT_PREVIEW_PORT } from './constants'
24-
import { resolveConfig } from '.'
25-
import type { InlineConfig, ResolvedConfig } from '.'
24+
import { resolveConfig } from './config'
25+
import type { InlineConfig, ResolvedConfig } from './config'
2626

2727
export interface PreviewOptions extends CommonServerOptions {}
2828

0 commit comments

Comments
 (0)