Skip to content
Closed
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
179 changes: 89 additions & 90 deletions Cargo.lock

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"css-module-lexer",
"html5gum",
"prettyplease",
"proc-macro2",

Check warning on line 11 in Cargo.toml

View workflow job for this annotation

GitHub Actions / Lint

shear/redundant_ignore

redundant ignore `proc-macro2` (remove from ignored list)
"quote",

Check warning on line 12 in Cargo.toml

View workflow job for this annotation

GitHub Actions / Lint

shear/redundant_ignore

redundant ignore `quote` (remove from ignored list)
"string_cache",
"syn",

Check warning on line 14 in Cargo.toml

View workflow job for this annotation

GitHub Actions / Lint

shear/redundant_ignore

redundant ignore `syn` (remove from ignored list)
]

[workspace.package]
Expand Down Expand Up @@ -312,7 +312,7 @@
zip = { version = "7.2", default-features = false, features = ["deflate-flate2-zlib-rs"] }

# oxc crates with the same version
oxc = { version = "0.142.0", features = [
oxc = { version = "0.143.0", features = [
"ast_visit",
"transformer",
"minifier",
Expand All @@ -324,17 +324,17 @@
"regular_expression",
"cfg",
] }
oxc_allocator = { version = "0.142.0", features = ["pool"] }
oxc_ast = "0.142.0"
oxc_ecmascript = "0.142.0"
oxc_parser = "0.142.0"
oxc_span = "0.142.0"
oxc_napi = "0.142.0"
oxc_str = "0.142.0"
oxc_minify_napi = "0.142.0"
oxc_parser_napi = "0.142.0"
oxc_transform_napi = "0.142.0"
oxc_traverse = "0.142.0"
oxc_allocator = { version = "0.143.0", features = ["pool"] }
oxc_ast = "0.143.0"
oxc_ecmascript = "0.143.0"
oxc_parser = "0.143.0"
oxc_span = "0.143.0"
oxc_napi = "0.143.0"
oxc_str = "0.143.0"
oxc_minify_napi = "0.143.0"
oxc_parser_napi = "0.143.0"
oxc_transform_napi = "0.143.0"
oxc_traverse = "0.143.0"

# oxc crates in their own repos
oxc_index = { version = "5", features = ["rayon", "serde"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Allowing / Denying Multiple Lints
* `all` - All categories listed above except `nursery`. Does not enable plugins
automatically.
-A, --allow=NAME Allow the rule or category (suppress the lint)
-W, --warn=NAME Deny the rule or category (emit a warning)
-W, --warn=NAME Warn on the rule or category (emit a warning)
-D, --deny=NAME Deny the rule or category (emit an error)

Enable/Disable Plugins
Expand Down
49 changes: 26 additions & 23 deletions crates/vp_static_config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,15 @@ fn extract_config_from_expr(
match first_arg_expr.get_inner_expression() {
Expression::ObjectExpression(obj) => extract_object_fields(obj),
Expression::ArrowFunctionExpression(arrow) => {
extract_config_from_function_body(&arrow.body)
// Block body: `() => { ... return { ... }; }`.
if let Some(body) = arrow.get_function_body() {
extract_config_from_function_body(body)
} else if let Some(expr) = arrow.get_expression() {
// Concise body: `() => ({ ... })`.
extract_config_from_returned_expr(expr)
} else {
FieldMap::unanalyzable()
}
}
Expression::FunctionExpression(func) => {
let Some(body) = func.body.as_ref() else {
Expand All @@ -242,11 +250,11 @@ fn extract_config_from_expr(
}
}

/// Extract the config object from the body of a function passed to `defineConfig`.
/// Extract the config object from the block body of a function passed to `defineConfig`.
///
/// Handles two patterns:
/// - Concise arrow body: `() => ({ ... })` — body has a single `ExpressionStatement`
/// - Block body with exactly one return: `() => { ... return { ... }; }`
/// Handles a block body with exactly one return: `() => { ... return { ... }; }`
/// (or the equivalent `function () { ... }`). Concise arrow bodies (`() => ({ ... })`)
/// are handled directly at the call site via [`extract_config_from_returned_expr`].
///
/// Returns `FieldMap::unanalyzable()` if the body contains multiple `return` statements
/// (at any nesting depth), since the returned config would depend on runtime control flow.
Expand All @@ -257,30 +265,25 @@ fn extract_config_from_function_body(body: &oxc_ast::ast::FunctionBody<'_>) -> F
}

for stmt in &body.statements {
match stmt {
Statement::ReturnStatement(ret) => {
let Some(arg) = ret.argument.as_ref() else {
return FieldMap::unanalyzable();
};
if let Expression::ObjectExpression(obj) = arg.get_inner_expression() {
return extract_object_fields(obj);
}
if let Statement::ReturnStatement(ret) = stmt {
let Some(arg) = ret.argument.as_ref() else {
return FieldMap::unanalyzable();
}
Statement::ExpressionStatement(expr_stmt) => {
// Concise arrow: `() => ({ ... })` is represented as ExpressionStatement
if let Expression::ObjectExpression(obj) =
expr_stmt.expression.get_inner_expression()
{
return extract_object_fields(obj);
}
}
_ => {}
};
return extract_config_from_returned_expr(arg);
}
}
FieldMap::unanalyzable()
}

/// Extract config fields from an expression that stands in for the returned config
/// object, e.g. the concise body of `() => ({ ... })` or the argument of a `return`.
fn extract_config_from_returned_expr(expr: &Expression<'_>) -> FieldMap {
if let Expression::ObjectExpression(obj) = expr.get_inner_expression() {
return extract_object_fields(obj);
}
FieldMap::unanalyzable()
}

fn is_trusted_define_config_import(stmt: &Statement<'_>) -> bool {
let Statement::ImportDeclaration(import_decl) = stmt else {
return false;
Expand Down
7 changes: 0 additions & 7 deletions packages/cli/rules/vite-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ rule:
regex: 'vite\s+(-v|--version)'
fix: vp


# vite => vp dev (handles all cases: with/without env var prefix and flag args)
# Match command_name to preserve env var prefix and arguments
# Excludes subcommands like "vite build", "vite test", etc.
Expand All @@ -27,7 +26,6 @@ rule:
regex: 'vite\s+[^-]'
fix: vp dev


# vite <subcommand> => vp <subcommand> (handles vite build, vite test, vite dev, etc.)
# Match command_name when followed by a subcommand, replace only the command name
---
Expand All @@ -41,7 +39,6 @@ rule:
regex: 'vite\s+[^-]'
fix: vp


# oxlint => vp lint (handles all cases: with/without env var prefix and args)
# Match command_name to preserve env var prefix and arguments
---
Expand All @@ -52,7 +49,6 @@ rule:
regex: '^oxlint$'
fix: vp lint


# oxfmt => vp fmt
---
id: replace-oxfmt
Expand All @@ -62,7 +58,6 @@ rule:
regex: '^oxfmt$'
fix: vp fmt


# vitest => vp test
---
id: replace-vitest
Expand All @@ -72,7 +67,6 @@ rule:
regex: '^vitest$'
fix: vp test


# lint-staged => vp staged
---
id: replace-lint-staged
Expand All @@ -82,7 +76,6 @@ rule:
regex: '^lint-staged$'
fix: vp staged


# tsdown => vp pack
---
id: replace-tsdown
Expand Down
13 changes: 12 additions & 1 deletion packages/core/__tests__/binding-resolution-layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,20 @@ function buildGlobalVirtualStoreLayout(options: {
}

function runProject(root: string, env: Record<string, string> = {}) {
// The test runner spawns its workers with NODE_PATH pointing at the workspace
// virtual store (node_modules/.pnpm/node_modules), where the real `vite-plus`
// lives. Leaking that into the child would let core resolve the workspace's
// `vite-plus` and defeat the global-virtual-store isolation this fixture
// recreates, so strip it and let resolution walk only the synthetic layout.
const childEnv: NodeJS.ProcessEnv = {
...process.env,
NAPI_RS_ENFORCE_VERSION_CHECK: '',
...env,
};
delete childEnv.NODE_PATH;
try {
const stdout = execFileSync(process.execPath, [path.join(root, 'project/main.cjs')], {
env: { ...process.env, NAPI_RS_ENFORCE_VERSION_CHECK: '', ...env },
env: childEnv,
encoding: 'utf-8',
timeout: 30_000,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"@oxc-node/cli": "catalog:",
"@tsdown/css": "catalog:",
"@tsdown/exe": "catalog:",
"@vitejs/devtools": "^0.4.10",
"@vitejs/devtools": "^0.4.12",
"es-module-lexer": "^1.7.0",
"hookable": "^6.0.1",
"magic-string": "^0.30.21",
Expand Down Expand Up @@ -221,7 +221,7 @@
},
"bundledVersions": {
"vite": "8.2.0",
"rolldown": "1.2.2",
"rolldown": "1.2.3",
"tsdown": "0.22.14"
}
}
2 changes: 1 addition & 1 deletion packages/tools/.upstream-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"rolldown": {
"repo": "https://github.com/rolldown/rolldown.git",
"branch": "main",
"hash": "872b98ac7476eb7d5892a2913e4ba010d124c6ac"
"hash": "52dbd194ea6b6d4320706caa5f2db14b1034adaf"
},
"vite": {
"repo": "https://github.com/vitejs/vite.git",
Expand Down
Loading
Loading