Skip to content

Export runtime-vapor to support unit-test for Vapor ModeΒ #14416

@zhiyuanzmj

Description

@zhiyuanzmj

Vue version

3.6.0-beta.5

Link to minimal reproduction

https://github.com/zhiyuanzmj/router

Steps to reproduce

1 . git clone https://github.com/zhiyuanzmj/router -b vapor-issue
2. pnpm install && pnpm test

What is expected?

Export runtime-vapor from vue's cjs-bundler.

What is actually happening?

Will report a defineVaporComponent is not a function error

Image

System Info

System:
    OS: macOS 26.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 129.38 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.8.0 - /usr/local/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.9.2 - /usr/local/bin/npm
    pnpm: 10.28.2 - ~/Library/pnpm/pnpm
    bun: 1.3.6 - ~/.bun/bin/bun
  Browsers:
    Chrome: 144.0.7559.133
    Safari: 26.2

Any additional comments?

A temporary solution

// vitest.config.ts
export default defineConfig({
  // FIXME: shouldn't be needed
  resolve: {
    alias: {
      // cjs does not export vapor runtime, use esm instead.
      "@vue/runtime-core": require.resolve('@vue/runtime-core').replace('index.js', 'dist/runtime-core.esm-bundler.js'),
       "@vue/runtime-dom": require.resolve('@vue/runtime-dom').replace('index.js', 'dist/runtime-dom.esm-bundler.js'),
      vue: 'vue/dist/vue.runtime.esm-bundler.js',
    },
  },
})

Since runtime-vapor doesn't export from cjs-bundler. We must use vitest to alias vue as esm-bundler.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions