Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: use native Vite resolver #65

Draft
wants to merge 8 commits into
base: rolldown-v6
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
"dependencies": {
"esbuild": "^0.24.0",
"oxc-resolver": "^2.0.0",
"postcss": "^8.4.48",
"rolldown": "https://pkg.pr.new/rolldown@72ed6ce",
"rollup": "^4.23.0"
Expand Down
26 changes: 14 additions & 12 deletions packages/vite/src/node/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from '../plugin'
import { watchPackageDataPlugin } from '../packages'
import { jsonPlugin } from './json'
import { filteredResolvePlugin, resolvePlugin } from './resolve'
import { oxcResolvePlugin, resolvePlugin } from './resolve'
import { optimizedDepsPlugin } from './optimizedDeps'
import { importAnalysisPlugin } from './importAnalysis'
import { cssAnalysisPlugin, cssPlugin, cssPostPlugin } from './css'
Expand Down Expand Up @@ -96,8 +96,8 @@ export async function resolvePlugins(
)
: modulePreloadPolyfillPlugin(config)
: null,
enableNativePlugin
? filteredResolvePlugin({
...(enableNativePlugin
? oxcResolvePlugin({
root: config.root,
isProduction: config.isProduction,
isBuild,
Expand All @@ -106,15 +106,17 @@ export async function resolvePlugins(
optimizeDeps: true,
externalize: true,
})
: resolvePlugin({
root: config.root,
isProduction: config.isProduction,
isBuild,
packageCache: config.packageCache,
asSrc: true,
optimizeDeps: true,
externalize: true,
}),
: [
resolvePlugin({
root: config.root,
isProduction: config.isProduction,
isBuild,
packageCache: config.packageCache,
asSrc: true,
optimizeDeps: true,
externalize: true,
}),
]),
htmlInlineProxyPlugin(config),
cssPlugin(config),
config.oxc !== false
Expand Down
8 changes: 7 additions & 1 deletion packages/vite/src/node/plugins/preAlias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ export function preAliasPlugin(config: ResolvedConfig): Plugin {
id !== '@vite/env'
) {
if (findPatterns.find((pattern) => matches(pattern, id))) {
const optimizedId = await tryOptimizedResolve(
// TODO: we need to wait until scanning is done here as this function
// is used in the preAliasPlugin to decide if an aliased dep is optimized,
// and avoid replacing the bare import with the resolved path.
// We should be able to remove this in the future
await depsOptimizer.scanProcessing

const optimizedId = tryOptimizedResolve(
depsOptimizer,
id,
importer,
Expand Down
Loading
Loading