Skip to content

Sourcemaps are not emitted when using ssr and vite 4.0 #11344

Closed
@thebanjomatic

Description

@thebanjomatic

Describe the bug

When enabling SSR mode by setting:

{
  build: {
    ssr: true,
    sourcemap: true,
  }
}

Sourcemaps are no longer being emitted to the output directory. This appears to be the result of the rollup 3 upgrade since that change made sourcemaps into proper assets within the bundle, and vite has existing code that removes assets from the bundle for SSR builds which was not updated to go along with this change.

I have fixed this in the following PR: #11343

Reproduction

https://stackblitz.com/edit/vitejs-vite-bqd6xy?file=vite.config.ts

Steps to reproduce

Run npm install followed by npm run build and check the output produced in the ./dist folder. you will only see index.js and index.cjs, but there should also be index.js.map and index.cjs.map.

If you set ssr: false in the vite.config.ts file and re-run the steps above, the sourcemaps are produced correctly.

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12800H
    Memory: 13.68 GB / 31.64 GB
  Binaries:
    Node: 18.12.1 - ~\AppData\Local\Volta\tools\image\node\18.12.1\node.EXE
    Yarn: 1.22.19 - ~\AppData\Local\Volta\tools\image\yarn\1.22.19\bin\yarn.CMD
    npm: 8.19.2 - ~\AppData\Local\Volta\tools\image\node\18.12.1\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.819.0), Chromium (107.0.1418.56)
    Internet Explorer: 11.0.22621.1

Used Package Manager

yarn

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions