Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!doctype html>
<html>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "command-dev-bundled-dev-test",
"private": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Regression test for PR #2384: the core build rewrites CLIENT_ENTRY and
# ENV_ENTRY to dist/vite/client/, but it left BUNDLED_DEV_CLIENT_ENTRY at
# dist/client/. With `experimental.bundledDev` enabled, Vite reads that
# path with fs.readFileSync, so `vp dev` fails at startup with ENOENT.
[[case]]
name = "command_dev_bundled_dev"
vp = "local"
skip-platforms = ["windows"]
steps = [
{ argv = ["vp", "dev", "--host", "127.0.0.1", "--port", "0"], comment = "dev server with experimental.bundledDev enabled starts and serves the bundled dev client", continue-on-failure = true, interactions = [
{ "expect-milestone" = "dev-server:ready" },
{ "write-key" = "ctrl-c" },
] },
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# command_dev_bundled_dev

## `vp dev --host 127.0.0.1 --port 0`

dev server with experimental.bundledDev enabled starts and serves the bundled dev client

**Exit code:** 130

**→ expect-milestone:** `dev-server:ready`

```

VITE+ <version>

➜ Local: http://127.0.0.1:<port>/
➜ press h + enter to show help
```

**← write-key:** `ctrl-c`

```

VITE+ <version>

➜ Local: http://127.0.0.1:<port>/
➜ press h + enter to show help

```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
document.querySelector('#app')!.textContent = 'hello';
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default {
clearScreen: false,
experimental: {
bundledDev: true,
},
plugins: [
{
name: 'dev-server-ready-milestone',
configureServer(server) {
server.httpServer?.once('listening', () => {
// Let Vite print its startup banner after server.listen() resolves.
setImmediate(() => {
const name = Buffer.from('dev-server:ready').toString('base64url');
process.stdout.write(`\x1b]2;pty-terminal-test:${'0'.repeat(32)}:${name}\x1b\\`);
});
});
},
},
],
};
3 changes: 2 additions & 1 deletion packages/core/BUNDLING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ This is the most complex step, using the upstream `vite-rolldown.config` with mo

1. **Filter externals** - Bundles `picomatch`, `tinyglobby`, `fdir`, `rolldown`, `yaml` instead of keeping them external
2. **Add RewriteImportsPlugin** - Rewrites vite/rolldown imports at build time
3. **Rewrite static paths** - Fixes `VITE_PACKAGE_DIR`, `CLIENT_ENTRY`, `ENV_ENTRY` constants
3. **Rewrite static paths** - Fixes `VITE_PACKAGE_DIR`, `CLIENT_ENTRY`, `BUNDLED_DEV_CLIENT_ENTRY`, `ENV_ENTRY` constants
4. **Copy additional files** - `misc/`, `.d.ts` files, `types/`, `client.d.ts`

**Input**: `vite/packages/vite/`
Expand Down Expand Up @@ -219,6 +219,7 @@ dist/
│ │ ├── module-runner.js
│ │ └── chunks/
│ ├── client/
│ │ ├── bundledDevClient.mjs
│ │ ├── client.mjs
│ │ └── env.mjs
│ ├── misc/
Expand Down
7 changes: 7 additions & 0 deletions packages/core/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ async function buildVite() {
)`,
`export const CLIENT_ENTRY = path.join(VITE_PACKAGE_DIR, 'dist/vite/client/client.mjs')`,
);
magicString.replace(
`export const BUNDLED_DEV_CLIENT_ENTRY: string = resolve(
VITE_PACKAGE_DIR,
'dist/client/bundledDevClient.mjs',
)`,
`export const BUNDLED_DEV_CLIENT_ENTRY = path.join(VITE_PACKAGE_DIR, 'dist/vite/client/bundledDevClient.mjs')`,
);
magicString.replace(
`export const ENV_ENTRY: string = resolve(
VITE_PACKAGE_DIR,
Expand Down
Loading