Skip to content

Commit 7c281f3

Browse files
authored
Merge branch 'main' into fix/install-respect-shell-dir-settings
2 parents 7287290 + 708734d commit 7c281f3

9 files changed

Lines changed: 41 additions & 14 deletions

File tree

.github/workflows/e2e-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ jobs:
246246
vp run type-check:tsgo
247247
vp run build
248248
vp run test navigation-utils.test.ts real-browser-flicker.test.tsx workflow-parallel-limit.test.tsx
249+
- name: viteplus-ws-repro
250+
node-version: 24
251+
command: |
252+
vp test run
249253
exclude:
250254
# frm-stack uses Docker (testcontainers) which doesn't work the same way on Windows
251255
- os: windows-latest

crates/vite_global_cli/src/commands/upgrade/registry.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ pub async fn resolve_version(
4545
registry_override: Option<&str>,
4646
) -> Result<ResolvedVersion, Error> {
4747
let default_registry = npm_registry();
48-
let registry = registry_override.unwrap_or(&default_registry);
48+
let registry_raw = registry_override.unwrap_or(&default_registry);
49+
let registry = registry_raw.trim_end_matches('/');
4950
let client = HttpClient::new();
5051

5152
// Step 1: Fetch main package metadata to resolve version

crates/vite_shared/src/env_config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ impl EnvConfig {
133133
vite_plus_home: std::env::var(env_vars::VITE_PLUS_HOME).ok().map(PathBuf::from),
134134
npm_registry: std::env::var(env_vars::NPM_CONFIG_REGISTRY)
135135
.or_else(|_| std::env::var(env_vars::NPM_CONFIG_REGISTRY_UPPER))
136-
.unwrap_or_else(|_| "https://registry.npmjs.org".into()),
136+
.unwrap_or_else(|_| "https://registry.npmjs.org".into())
137+
.trim_end_matches('/')
138+
.to_string(),
137139
node_dist_mirror: std::env::var(env_vars::VITE_NODE_DIST_MIRROR).ok(),
138140
is_ci: std::env::var("CI").is_ok(),
139141
bypass_shim: std::env::var(env_vars::VITE_PLUS_BYPASS).is_ok(),

ecosystem-ci/patch-project.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ const cwd = directory ? join(repoRoot, directory) : repoRoot;
2121
// run vp migrate
2222
const cli = process.env.VITE_PLUS_CLI_BIN ?? 'vp';
2323

24+
// Projects that already have vite-plus need it removed before migration so
25+
// vp migrate treats them as fresh and applies tgz overrides. Without this,
26+
// vp migrate detects "already using Vite+" and skips override injection.
27+
const forceFreshMigration = 'forceFreshMigration' in repoConfig && repoConfig.forceFreshMigration;
28+
if (forceFreshMigration) {
29+
const pkgPath = join(cwd, 'package.json');
30+
const pkg = JSON.parse(await readFile(pkgPath, 'utf-8'));
31+
delete pkg.devDependencies?.['vite-plus'];
32+
delete pkg.dependencies?.['vite-plus'];
33+
await writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf-8');
34+
}
35+
2436
if (project === 'rollipop') {
2537
const oxfmtrc = await readFile(join(repoRoot, '.oxfmtrc.json'), 'utf-8');
2638
await writeFile(

ecosystem-ci/repo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,11 @@
5454
"repository": "https://github.com/fengmk2/vite-vue-vercel.git",
5555
"branch": "main",
5656
"hash": "f2bf9fc40880c6a80f5d89bff70641c2eeaf77ef"
57+
},
58+
"viteplus-ws-repro": {
59+
"repository": "https://github.com/Charles5277/viteplus-ws-repro.git",
60+
"branch": "main",
61+
"hash": "451925ad7c07750a23de1d6ed454825d0eb14092",
62+
"forceFreshMigration": true
5763
}
5864
}

packages/cli/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/npm
22
/artifacts
33
/LICENSE
4-
/LICENSE.md
54
/skills/vite-plus/docs

packages/cli/build.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* 4. syncCorePackageExports() - Creates shim files to re-export from @voidzero-dev/vite-plus-core
99
* 5. syncTestPackageExports() - Creates shim files to re-export from @voidzero-dev/vite-plus-test
1010
* 6. copySkillDocs() - Copies docs into skills/vite-plus/docs for runtime MCP access
11-
* 7. syncReadmeFromRoot()/syncLicenseFromRoot() - Keeps package docs/license in sync
11+
* 7. syncReadmeFromRoot() - Keeps package README in sync
1212
*
1313
* The sync functions allow this package to be a drop-in replacement for 'vite' by
1414
* re-exporting all the same subpaths (./client, ./types/*, etc.) while delegating
@@ -64,13 +64,13 @@ if (!skipTs) {
6464
generateLicenseFile({
6565
title: 'Vite-Plus CLI license',
6666
packageName: 'Vite-Plus',
67-
outputPath: join(projectDir, 'LICENSE.md'),
67+
outputPath: join(projectDir, 'LICENSE'),
6868
coreLicensePath: join(projectDir, '..', '..', 'LICENSE'),
6969
bundledPaths: [join(projectDir, 'dist', 'global')],
7070
resolveFrom: [projectDir],
7171
});
72-
if (!existsSync(join(projectDir, 'LICENSE.md'))) {
73-
throw new Error('LICENSE.md was not generated during build');
72+
if (!existsSync(join(projectDir, 'LICENSE'))) {
73+
throw new Error('LICENSE was not generated during build');
7474
}
7575
}
7676
// Build native first - TypeScript may depend on the generated binding types
@@ -83,7 +83,6 @@ if (!skipTs) {
8383
}
8484
await copySkillDocs();
8585
await syncReadmeFromRoot();
86-
await syncLicenseFromRoot();
8786

8887
async function buildNapiBinding() {
8988
const buildCommand = createBuildCommand(napiArgs);
@@ -482,12 +481,6 @@ async function syncReadmeFromRoot() {
482481
}
483482
}
484483

485-
async function syncLicenseFromRoot() {
486-
const rootLicensePath = join(projectDir, '..', '..', 'LICENSE');
487-
const packageLicensePath = join(projectDir, 'LICENSE');
488-
await copyFile(rootLicensePath, packageLicensePath);
489-
}
490-
491484
function splitReadme(content: string, label: string) {
492485
const match = /^---\s*$/m.exec(content);
493486
if (!match || match.index === undefined) {

packages/test/build.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,18 @@ async function mergePackageJson(pluginExports: Array<{ exportPath: string; shimF
302302
// browser-provider exports. Browser code uses index.js which is safe.
303303
// This separation prevents Node.js-only code (like __vite__injectQuery) from being
304304
// loaded in the browser, which would cause "Identifier already declared" errors.
305+
//
306+
// IMPORTANT: The 'browser' condition must come BEFORE 'node' because vitest passes
307+
// custom --conditions (like 'browser') to worker processes when frameworks like Nuxt
308+
// set edge/cloudflare presets. Without the 'browser' condition here, Node.js would
309+
// match 'node' first, loading index-node.js which imports @vitest/browser/index.js,
310+
// which imports 'ws'. With --conditions browser active, 'ws' resolves to its browser
311+
// stub (ws/browser.js) that doesn't export WebSocketServer, causing a SyntaxError.
312+
// See: https://github.com/voidzero-dev/vite-plus/issues/831
305313
if (destPkg.exports['.'] && destPkg.exports['.'].import) {
306314
destPkg.exports['.'].import = {
307315
types: destPkg.exports['.'].import.types,
316+
browser: destPkg.exports['.'].import.default,
308317
node: './dist/index-node.js',
309318
default: destPkg.exports['.'].import.default,
310319
};

packages/test/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
".": {
3838
"import": {
3939
"types": "./dist/index.d.ts",
40+
"browser": "./dist/index.js",
4041
"node": "./dist/index-node.js",
4142
"default": "./dist/index.js"
4243
},

0 commit comments

Comments
 (0)