Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ssr): load sourcemaps alongside modules (fix: #3288) #11576

Merged
merged 6 commits into from
Jan 16, 2023

Conversation

Vap0r1ze
Copy link
Contributor

@Vap0r1ze Vap0r1ze commented Jan 3, 2023

Description

Fixes #3288

This PR adds runtime sourcemaps to SSR modules inline.
This isn't a very large change as vite's request transformer provides source maps. The only modification that needed to be made to the source maps was prepending ';;;' to the mappings, as the first three lines of every module will look like this:

async function(a, b, c
) {
'use strict';

Before Changes

image

After Changes

image


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@Vap0r1ze
Copy link
Contributor Author

Vap0r1ze commented Jan 4, 2023

It may be worth noting that this also allows me to use breakpoints in VSCode without any debugger; statements

@Vap0r1ze
Copy link
Contributor Author

Vap0r1ze commented Jan 4, 2023

Video of me setting a breakpoint in a TS file in an Astro project with my changes and saving the file (to cause the module to be reloaded)

Code_NCoKzatZOR.mp4

@jere2101
Copy link

jere2101 commented Jan 4, 2023

Just tested it with SvelteKit and it works great (EDIT: for me ;D)🎉
Thank for the fast implementation

@patak-dev
Copy link
Member

@manucorporat would you review this one in the context of Qwik?

@jere2101
Copy link

jere2101 commented Jan 4, 2023

Don't know if it helps.

In my test with Qwik debugging worked perfectly fine🤩 but I'm not an Qwik expert.

@Vap0r1ze
Copy link
Contributor Author

@patak-dev is there anything blocking this pr, testing?

Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!
The behavior looks good to me.

packages/vite/src/node/ssr/ssrModuleLoader.ts Outdated Show resolved Hide resolved
packages/vite/src/node/ssr/ssrModuleLoader.ts Outdated Show resolved Hide resolved
packages/vite/src/node/ssr/ssrModuleLoader.ts Outdated Show resolved Hide resolved
packages/vite/src/node/ssr/ssrModuleLoader.ts Outdated Show resolved Hide resolved
Vap0r1ze and others added 2 commits January 11, 2023 11:52
Co-authored-by: 翠 / green <green@sapphi.red>
@pasqui23
Copy link

pasqui23 commented Jan 12, 2023

@jere2101 what was the launch.json you used to debug SvelteKit's SSR?

@jere2101
Copy link

jere2101 commented Jan 12, 2023

@jere2101 what was the launch.json you used to debug SvelteKit's SSR?

I tested it without a launch.json. I started npm run dev in the Javascript Debug Terminal of vscode.
Hope this help's you

@Vap0r1ze
Copy link
Contributor Author

@sapphi-red I think I've addressed your concerns now

Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@patak-dev patak-dev merged commit dc05e97 into vitejs:main Jan 16, 2023
@Vap0r1ze Vap0r1ze deleted the fix/ssr-sourcemaps branch January 16, 2023 06:18
@benmccann
Copy link
Collaborator

This PR seems to have broken source maps for SvelteKit as SvelteKit's test suite is now failing:

Screenshot from 2023-01-20 06-55-18

I think we should probably revert this PR and add it back only with tests ensuring the source map locations it generates are correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSR SourceMap not loaded when debugging
7 participants