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
3 changes: 2 additions & 1 deletion packages/cli/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const { task } = await cli.build({
const output = (await task).find((o) => o.kind === 'node');

await build({
input: ['./src/bin.ts', './src/index.ts'],
input: ['./src/bin.ts', './src/index.ts', './src/test.ts'],
external: [/^node:/, 'rolldown-vite'],
output: {
format: 'esm',
Expand All @@ -64,6 +64,7 @@ const program = createProgram({
rootNames: [
join(srcDir, 'index.ts'),
join(srcDir, 'client.ts'),
join(srcDir, 'test.ts'),
],
options: {
...options,
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
},
"./client": {
"types": "./dist/client.d.ts"
},
"./test": {
"import": "./dist/test.js",
"types": "./dist/test.d.ts"
}
},
"engines": {
Expand Down
93 changes: 54 additions & 39 deletions packages/cli/snap-tests/associate-existing-cache/snap.txt
Original file line number Diff line number Diff line change
@@ -1,54 +1,69 @@
> vite run script1 # create the cache for 'echo hello'
$ echo hello
hello
[1]> vite run script1 # create the cache for 'echo hello'
file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10260
if (!workerState) throw new Error("Vitest failed to access its internal state.\n\nOne of the following is possible:\n- \"vitest\" is imported directly without running \"vitest\" command\n- \"vitest\" is imported inside \"globalSetup\" (to fix this, use \"setupFiles\" instead, because \"globalSetup\" runs in a different context)\n- \"vitest\" is imported inside Vite / Vitest config file\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n");
^

Error: Vitest failed to access its internal state.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
One of the following is possible:
- "vitest" is imported directly without running "vitest" command
- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)
- "vitest" is imported inside Vite / Vitest config file
- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues

Statistics: 1 tasks • 0 cache hits • 1 cache misses
Performance: 0% cache hit rate
at getWorkerState (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10260:26)
at getCurrentEnvironment (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10264:9)
at createExpect (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:12526:16)
at file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:12562:22
at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:651:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

Task Details:
────────────────────────────────────────────────
[1] script1: $ echo hello ✓
→ Cache miss: no previous cache entry found
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Node.js v<semver>

> vite run script2 # script2 has the same command as script1, should hit and associate the cache
$ echo hello (✓ cache hit, replaying)
hello
[1]> vite run script2 # script2 has the same command as script1, should hit and associate the cache
file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10260
if (!workerState) throw new Error("Vitest failed to access its internal state.\n\nOne of the following is possible:\n- \"vitest\" is imported directly without running \"vitest\" command\n- \"vitest\" is imported inside \"globalSetup\" (to fix this, use \"setupFiles\" instead, because \"globalSetup\" runs in a different context)\n- \"vitest\" is imported inside Vite / Vitest config file\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n");
^

Error: Vitest failed to access its internal state.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
One of the following is possible:
- "vitest" is imported directly without running "vitest" command
- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)
- "vitest" is imported inside Vite / Vitest config file
- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues

Statistics: 1 tasks • 1 cache hits • 0 cache misses
Performance: 100% cache hit rate, <variable>ms saved in total
at getWorkerState (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10260:26)
at getCurrentEnvironment (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10264:9)
at createExpect (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:12526:16)
at file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:12562:22
at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:651:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

Task Details:
────────────────────────────────────────────────
[1] script2: $ echo hello ✓
→ Cache hit - output replayed - <variable>ms saved
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Node.js v<semver>

> json-edit package.json '_.scripts.script2 = "echo world"' # update the command of script2
> vite run script2 # should report cache miss due to command mismatch with the cache associated in step 2
$ echo world (✗ cache miss: command changed, executing)
world
[1]> vite run script2 # should report cache miss due to command mismatch with the cache associated in step 2
file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10260
if (!workerState) throw new Error("Vitest failed to access its internal state.\n\nOne of the following is possible:\n- \"vitest\" is imported directly without running \"vitest\" command\n- \"vitest\" is imported inside \"globalSetup\" (to fix this, use \"setupFiles\" instead, because \"globalSetup\" runs in a different context)\n- \"vitest\" is imported inside Vite / Vitest config file\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n");
^

Error: Vitest failed to access its internal state.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
One of the following is possible:
- "vitest" is imported directly without running "vitest" command
- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)
- "vitest" is imported inside Vite / Vitest config file
- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues

Statistics: 1 tasks • 0 cache hits • 1 cache misses
Performance: 0% cache hit rate
at getWorkerState (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10260:26)
at getCurrentEnvironment (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10264:9)
at createExpect (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:12526:16)
at file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:12562:22
at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:651:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

Task Details:
────────────────────────────────────────────────
[1] script2: $ echo world ✓
→ Cache miss: command changed from echo hello to echo world
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Node.js v<semver>
98 changes: 84 additions & 14 deletions packages/cli/snap-tests/builtin-different-cwd/snap.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,92 @@
> cd folder1 && vite lint
Found 0 warnings and 0 errors.
Finished in <variable>ms on 1 file with <variable> rules using <variable> threads.
[1]> cd folder1 && vite lint
file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10260
if (!workerState) throw new Error("Vitest failed to access its internal state.\n\nOne of the following is possible:\n- \"vitest\" is imported directly without running \"vitest\" command\n- \"vitest\" is imported inside \"globalSetup\" (to fix this, use \"setupFiles\" instead, because \"globalSetup\" runs in a different context)\n- \"vitest\" is imported inside Vite / Vitest config file\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n");
^

Error: Vitest failed to access its internal state.

> cd folder2 && vite lint # should create different cache even though the package is the same
Found 0 warnings and 0 errors.
Finished in <variable>ms on 1 file with <variable> rules using <variable> threads.
One of the following is possible:
- "vitest" is imported directly without running "vitest" command
- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)
- "vitest" is imported inside Vite / Vitest config file
- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues

at getWorkerState (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10260:26)
at getCurrentEnvironment (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10264:9)
at createExpect (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:12526:16)
at file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:12562:22
at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:651:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

Node.js v<semver>

[1]> cd folder2 && vite lint # should create different cache even though the package is the same
file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10260
if (!workerState) throw new Error("Vitest failed to access its internal state.\n\nOne of the following is possible:\n- \"vitest\" is imported directly without running \"vitest\" command\n- \"vitest\" is imported inside \"globalSetup\" (to fix this, use \"setupFiles\" instead, because \"globalSetup\" runs in a different context)\n- \"vitest\" is imported inside Vite / Vitest config file\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n");
^

Error: Vitest failed to access its internal state.

One of the following is possible:
- "vitest" is imported directly without running "vitest" command
- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)
- "vitest" is imported inside Vite / Vitest config file
- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues

at getWorkerState (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10260:26)
at getCurrentEnvironment (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10264:9)
at createExpect (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:12526:16)
at file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:12562:22
at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:651:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

Node.js v<semver>

> echo 'console.log(1);' > folder2/a.js
> cd folder1 && vite lint
✓ cache hit, replaying
Found 0 warnings and 0 errors.
Finished in <variable>ms on 1 file with <variable> rules using <variable> threads.
[1]> cd folder1 && vite lint
file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10260
if (!workerState) throw new Error("Vitest failed to access its internal state.\n\nOne of the following is possible:\n- \"vitest\" is imported directly without running \"vitest\" command\n- \"vitest\" is imported inside \"globalSetup\" (to fix this, use \"setupFiles\" instead, because \"globalSetup\" runs in a different context)\n- \"vitest\" is imported inside Vite / Vitest config file\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n");
^

Error: Vitest failed to access its internal state.

One of the following is possible:
- "vitest" is imported directly without running "vitest" command
- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)
- "vitest" is imported inside Vite / Vitest config file
- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues

at getWorkerState (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10260:26)
at getCurrentEnvironment (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10264:9)
at createExpect (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:12526:16)
at file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:12562:22
at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:651:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

Node.js v<semver>

[1]> cd folder2 && vite lint
file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10260
if (!workerState) throw new Error("Vitest failed to access its internal state.\n\nOne of the following is possible:\n- \"vitest\" is imported directly without running \"vitest\" command\n- \"vitest\" is imported inside \"globalSetup\" (to fix this, use \"setupFiles\" instead, because \"globalSetup\" runs in a different context)\n- \"vitest\" is imported inside Vite / Vitest config file\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n");
^

Error: Vitest failed to access its internal state.

One of the following is possible:
- "vitest" is imported directly without running "vitest" command
- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)
- "vitest" is imported inside Vite / Vitest config file
- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues

> cd folder2 && vite lint
✗ cache miss: content of input 'folder2/a.js' changed, executing
Found 0 warnings and 0 errors.
Finished in <variable>ms on 1 file with <variable> rules using <variable> threads.
at getWorkerState (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10260:26)
at getCurrentEnvironment (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:10264:9)
at createExpect (file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:12526:16)
at file:///Users/fengmk2/git/github.com/voidzero-dev/vite-plus/packages/cli/dist/test-uKWxeUUt.js:12562:22
at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:651:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

Node.js v<semver>
Loading
Loading