diff --git a/package.json b/package.json index 12f1159e639..2d3af0f27d2 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,8 @@ "test-dts": "run-s build-dts test-dts-only", "test-dts-only": "tsc -p packages-private/dts-built-test/tsconfig.json && tsc -p ./packages-private/dts-test/tsconfig.test.json", "test-coverage": "vitest run --project unit --coverage", + "prebench": "node scripts/build.js -pf esm-browser reactivity", + "prebench-compare": "node scripts/build.js -pf esm-browser reactivity", "bench": "vitest bench --project=unit --outputJson=temp/bench.json", "bench-compare": "vitest bench --project=unit --compare=temp/bench.json", "release": "node scripts/release.js", diff --git a/packages/reactivity/__benchmarks__/computed.bench.ts b/packages/reactivity/__benchmarks__/computed.bench.ts index d9757501f81..a2a49486a89 100644 --- a/packages/reactivity/__benchmarks__/computed.bench.ts +++ b/packages/reactivity/__benchmarks__/computed.bench.ts @@ -1,5 +1,10 @@ import { bench, describe } from 'vitest' -import { type ComputedRef, type Ref, computed, effect, ref } from '../src' +import type { ComputedRef, Ref } from '../src' +import { computed, effect, ref } from '../dist/reactivity.esm-browser.prod' + +declare module '../dist/reactivity.esm-browser.prod' { + function computed(...args: any[]): any +} describe('computed', () => { bench('create computed', () => { diff --git a/packages/reactivity/__benchmarks__/effect.bench.ts b/packages/reactivity/__benchmarks__/effect.bench.ts index 8d3d6ecfbfc..a1026db2153 100644 --- a/packages/reactivity/__benchmarks__/effect.bench.ts +++ b/packages/reactivity/__benchmarks__/effect.bench.ts @@ -1,5 +1,6 @@ import { bench, describe } from 'vitest' -import { type Ref, effect, ref } from '../src' +import type { Ref } from '../src' +import { effect, ref } from '../dist/reactivity.esm-browser.prod' describe('effect', () => { { diff --git a/packages/reactivity/__benchmarks__/reactiveArray.bench.ts b/packages/reactivity/__benchmarks__/reactiveArray.bench.ts index f5032cf7ae9..910c10015e9 100644 --- a/packages/reactivity/__benchmarks__/reactiveArray.bench.ts +++ b/packages/reactivity/__benchmarks__/reactiveArray.bench.ts @@ -1,5 +1,9 @@ import { bench } from 'vitest' -import { effect, reactive, shallowReadArray } from '../src' +import { + effect, + reactive, + shallowReadArray, +} from '../dist/reactivity.esm-browser.prod' for (let amount = 1e1; amount < 1e4; amount *= 10) { { diff --git a/packages/reactivity/__benchmarks__/reactiveMap.bench.ts b/packages/reactivity/__benchmarks__/reactiveMap.bench.ts index f8b4611153e..5af03ba4b14 100644 --- a/packages/reactivity/__benchmarks__/reactiveMap.bench.ts +++ b/packages/reactivity/__benchmarks__/reactiveMap.bench.ts @@ -1,5 +1,6 @@ import { bench } from 'vitest' -import { type ComputedRef, computed, reactive } from '../src' +import type { ComputedRef } from '../src' +import { computed, reactive } from '../dist/reactivity.esm-browser.prod' function createMap(obj: Record) { const map = new Map() diff --git a/packages/reactivity/__benchmarks__/reactiveObject.bench.ts b/packages/reactivity/__benchmarks__/reactiveObject.bench.ts index a326a111b49..1b444d4fec6 100644 --- a/packages/reactivity/__benchmarks__/reactiveObject.bench.ts +++ b/packages/reactivity/__benchmarks__/reactiveObject.bench.ts @@ -1,5 +1,5 @@ import { bench } from 'vitest' -import { reactive } from '../src' +import { reactive } from '../dist/reactivity.esm-browser.prod' bench('create reactive obj', () => { reactive({ a: 1 }) diff --git a/packages/reactivity/__benchmarks__/ref.bench.ts b/packages/reactivity/__benchmarks__/ref.bench.ts index 0c05890179b..4c1d2b5b82f 100644 --- a/packages/reactivity/__benchmarks__/ref.bench.ts +++ b/packages/reactivity/__benchmarks__/ref.bench.ts @@ -1,5 +1,5 @@ import { bench, describe } from 'vitest' -import { ref } from '../src/index' +import { ref } from '../dist/reactivity.esm-browser.prod' describe('ref', () => { bench('create ref', () => { diff --git a/packages/server-renderer/__tests__/createBuffer.bench.ts b/packages/server-renderer/__tests__/createBuffer.bench.ts index fff20f927fb..002626d9e12 100644 --- a/packages/server-renderer/__tests__/createBuffer.bench.ts +++ b/packages/server-renderer/__tests__/createBuffer.bench.ts @@ -1,6 +1,10 @@ import { bench, describe } from 'vitest' -import { createBuffer } from '../src/render' +import { createBuffer as _createBuffer } from '../src/render' + +// move to local const to avoid import access overhead +// https://github.com/vitest-dev/vitest/issues/6903 +const createBuffer = _createBuffer describe('createBuffer', () => { let stringBuffer = createBuffer() diff --git a/packages/server-renderer/__tests__/unrollBuffer.bench.ts b/packages/server-renderer/__tests__/unrollBuffer.bench.ts index b5e03cea602..b26ab9b28ef 100644 --- a/packages/server-renderer/__tests__/unrollBuffer.bench.ts +++ b/packages/server-renderer/__tests__/unrollBuffer.bench.ts @@ -1,7 +1,11 @@ import { bench, describe } from 'vitest' import { type SSRBuffer, createBuffer } from '../src/render' -import { unrollBuffer } from '../src/renderToString' +import { unrollBuffer as _unrollBuffer } from '../src/renderToString' + +// move to local const to avoid import access overhead +// https://github.com/vitest-dev/vitest/issues/6903 +const unrollBuffer = _unrollBuffer function createSyncBuffer(levels: number, itemsPerLevel: number): SSRBuffer { const buffer = createBuffer()