Skip to content

Commit

Permalink
Merge branch 'main' into renovate/all-minor-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Apr 24, 2023
2 parents e158f48 + e0b1197 commit ea6dfc3
Show file tree
Hide file tree
Showing 12 changed files with 390 additions and 268 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -75,8 +75,8 @@
"playwright-chromium": "^1.32.3",
"prettier": "2.8.7",
"resolve": "^1.22.2",
"rimraf": "^4.4.1",
"rollup": "^3.20.2",
"rimraf": "^5.0.0",
"rollup": "^3.21.0",
"simple-git-hooks": "^2.8.1",
"tslib": "^2.5.0",
"tsx": "^3.12.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-lit-ts/src/my-element.ts
Expand Up @@ -76,7 +76,7 @@ export class MyElement extends LitElement {
color: #888;
}
h1 {
::slotted(h1) {
font-size: 3.2em;
line-height: 1.1;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-lit/src/my-element.js
Expand Up @@ -92,7 +92,7 @@ export class MyElement extends LitElement {
color: #535bf2;
}
h1 {
::slotted(h1) {
font-size: 3.2em;
line-height: 1.1;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-vue-ts/package.json
Expand Up @@ -15,6 +15,6 @@
"@vitejs/plugin-vue": "^4.1.0",
"typescript": "^5.0.2",
"vite": "^4.3.0",
"vue-tsc": "^1.2.0"
"vue-tsc": "^1.4.2"
}
}
10 changes: 9 additions & 1 deletion packages/vite/CHANGELOG.md
@@ -1,8 +1,16 @@
## <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)
* docs: 4.3 announcement and release notes (#12925) ([f29c582](https://github.com/vitejs/vite/commit/f29c582)), closes [#12925](https://github.com/vitejs/vite/issues/12925)
* chore: clean up 4.3 changelog ([55ec023](https://github.com/vitejs/vite/commit/55ec023))



## 4.3.0 (2023-04-20)

Vite 4.3 is out! Read the [announcement blog post here](https://vitejs.dev/blog/announcing-vite4-3)

[![Vite 4.3, It's Fast](https://vitejs.dev/og-image-announcing-vite4-3.png))](https://vitejs.dev/blog/announcing-vite4-3)
[![Vite 4.3, It's Fast](https://vitejs.dev/og-image-announcing-vite4-3.png)](https://vitejs.dev/blog/announcing-vite4-3)

In this minor, we focused on improving the dev server performance. The resolve logic got streamlined, improving hot paths and implementing smarter caching for finding `package.json`, TS config files, and resolved URL in general.

Expand Down
4 changes: 2 additions & 2 deletions packages/vite/package.json
@@ -1,6 +1,6 @@
{
"name": "vite",
"version": "4.3.0",
"version": "4.3.1",
"type": "module",
"license": "MIT",
"author": "Evan You",
Expand Down Expand Up @@ -68,7 +68,7 @@
"dependencies": {
"esbuild": "^0.17.5",
"postcss": "^8.4.23",
"rollup": "^3.20.2"
"rollup": "^3.21.0"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/plugins/reporter.ts
Expand Up @@ -260,8 +260,8 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
closeBundle() {
if (shouldLogInfo && !config.build.watch) {
config.logger.info(
`${colors.green(`✓`)} built in ${displayTime(
Date.now() - startTime,
`${colors.green(
`✓ built in ${displayTime(Date.now() - startTime)}`,
)}`,
)
}
Expand Down
57 changes: 21 additions & 36 deletions packages/vite/src/node/plugins/resolve.ts
Expand Up @@ -670,7 +670,6 @@ function tryResolveRealFileWithExtensions(
export type InternalResolveOptionsWithOverrideConditions =
InternalResolveOptions & {
/**
* @deprecated In future, `conditions` will work like this.
* @internal
*/
overrideConditions?: string[]
Expand Down Expand Up @@ -1072,52 +1071,38 @@ function packageEntryFailure(id: string, details?: string) {
)
}

const conditionalConditions = new Set(['production', 'development', 'module'])

function resolveExportsOrImports(
pkg: PackageData['data'],
key: string,
options: InternalResolveOptionsWithOverrideConditions,
targetWeb: boolean,
type: 'imports' | 'exports',
) {
const overrideConditions = options.overrideConditions
? new Set(options.overrideConditions)
: undefined
const additionalConditions = new Set(
options.overrideConditions || [
'production',
'development',
'module',
...options.conditions,
],
)

const conditions = []
if (
(!overrideConditions || overrideConditions.has('production')) &&
options.isProduction
) {
conditions.push('production')
}
if (
(!overrideConditions || overrideConditions.has('development')) &&
!options.isProduction
) {
conditions.push('development')
}
if (
(!overrideConditions || overrideConditions.has('module')) &&
!options.isRequire
) {
conditions.push('module')
}
if (options.overrideConditions) {
conditions.push(
...options.overrideConditions.filter((condition) =>
conditionalConditions.has(condition),
),
)
} else if (options.conditions.length > 0) {
conditions.push(...options.conditions)
}
const conditions = [...additionalConditions].filter((condition) => {
switch (condition) {
case 'production':
return options.isProduction
case 'development':
return !options.isProduction
case 'module':
return !options.isRequire
}
return true
})

const fn = type === 'imports' ? imports : exports
const result = fn(pkg, key, {
browser: targetWeb && !conditions.includes('node'),
require: options.isRequire && !conditions.includes('import'),
browser: targetWeb && !additionalConditions.has('node'),
require: options.isRequire && !additionalConditions.has('import'),
conditions,
})

Expand Down
2 changes: 0 additions & 2 deletions packages/vite/src/node/plugins/worker.ts
Expand Up @@ -240,8 +240,6 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {
}
},

// @ts-expect-error return void to fallback to other plugins, even though
// the types doesn't allow it. https://github.com/rollup/rollup/pull/4932
shouldTransformCachedModule({ id }) {
if (isBuild && isWorkerQueryId(id) && config.build.watch) {
return true
Expand Down
8 changes: 3 additions & 5 deletions packages/vite/src/node/server/transformRequest.ts
Expand Up @@ -172,11 +172,6 @@ async function loadAndTransform(
let code: string | null = null
let map: SourceDescription['map'] = null

// Ensure that the module is in the graph before it is loaded and the file is checked.
// This prevents errors from occurring during the load process and interrupting the watching process at its inception.
const mod = await moduleGraph.ensureEntryFromUrl(url, ssr)
ensureWatchedFile(watcher, mod.file, root)

// load
const loadStart = debugLoad ? performance.now() : 0
const loadResult = await pluginContainer.load(id, { ssr })
Expand Down Expand Up @@ -247,6 +242,9 @@ async function loadAndTransform(
err.code = isPublicFile ? ERR_LOAD_PUBLIC_URL : ERR_LOAD_URL
throw err
}
// ensure module in graph after successful load
const mod = await moduleGraph.ensureEntryFromUrl(url, ssr)
ensureWatchedFile(watcher, mod.file, root)

// transform
const transformStart = debugTransform ? performance.now() : 0
Expand Down
9 changes: 8 additions & 1 deletion packages/vite/src/node/utils.ts
Expand Up @@ -574,7 +574,7 @@ function windowsMappedRealpathSync(path: string) {
}
return realPath
}
const parseNetUseRE = /^(\w+) +(\w:) +([^ ]+)\s/
const parseNetUseRE = /^(\w+)? +(\w:) +([^ ]+)\s/
let firstSafeRealPathSyncRun = false

function windowsSafeRealPathSync(path: string): string {
Expand All @@ -586,6 +586,13 @@ function windowsSafeRealPathSync(path: string): string {
}

function optimizeSafeRealPathSync() {
// Skip if using Node <16.18 due to MAX_PATH issue: https://github.com/vitejs/vite/issues/12931
const nodeVersion = process.versions.node.split('.').map(Number)
if (nodeVersion[0] < 16 || (nodeVersion[0] === 16 && nodeVersion[1] < 18)) {
safeRealpathSync = fs.realpathSync
return
}

exec('net use', (error, stdout) => {
if (error) return
const lines = stdout.split('\n')
Expand Down

0 comments on commit ea6dfc3

Please sign in to comment.