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): fix sourcemap content (fixes #8657) #8997

Merged
merged 4 commits into from
Jul 10, 2022

Conversation

sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Jul 8, 2022

Description

For js, sourcemapContent was including the transformed content.
For ts, sourcemapContent was not included.

fixes #8657

Additional context

I'm not sure if this is the best approach.


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 Commit 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.

@sapphi-red sapphi-red added has workaround p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) feat: ssr labels Jul 8, 2022
@netlify
Copy link

netlify bot commented Jul 8, 2022

Deploy Preview for vite-docs-main canceled.

Name Link
🔨 Latest commit 44ebeda
🔍 Latest deploy log https://app.netlify.com/sites/vite-docs-main/deploys/62c83b30c9748c00087c0b65

Comment on lines 305 to +315
test('sourcemap source', async () => {
expect(
(await ssrTransform(`export const a = 1`, null, 'input.js')).map.sources
).toStrictEqual(['input.js'])
const map = (
await ssrTransform(
`export const a = 1`,
null,
'input.js',
'export const a = 1 /* */'
)
)?.map
expect(map?.sources).toStrictEqual(['input.js'])
expect(map?.sourcesContent).toStrictEqual(['export const a = 1 /* */'])
Copy link
Member Author

Choose a reason for hiding this comment

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

Changes in this file except this change is just a refactor.

@@ -258,7 +259,7 @@ async function loadAndTransform(
}

const result = ssr
? await ssrTransform(code, map as SourceMap, url, {
? await ssrTransform(code, map as SourceMap, url, originalCode, {
Copy link
Member Author

Choose a reason for hiding this comment

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

Instead of passing originalCode, we could always generate sourcemaps. But that will cost a lot if the file is large.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: ssr has workaround p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong Source Map for js files in SSR mode
3 participants