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] use consistent relative source filename for js sourcemaps #6598

Merged

Conversation

dominikg
Copy link
Member

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

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with [feat], [fix], [chore], or [docs].
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with npm test and lint the project with npm run lint

sveltekit issue for vite printing warnings about wrong sourcemap paths: sveltejs/kit#2029
and vite issue here: vitejs/vite#4423 (comment)

also this PR/discussion if a change should be reverted that could also fix it: #6572

note while i did test that with this change vite no longer logs that warning in kit, i'm not 100% sure that this fix is 100% correct. I'm confused why there were 3 different ways to handle it before and it may very well have been on purpose.

cc @dummdidumm @tanhauhau

Copy link
Member

@benmccann benmccann left a comment

Choose a reason for hiding this comment

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

lgtm. I'm not sure if there's an easy way to add a test for this?

src/compiler/compile/Component.ts Outdated Show resolved Hide resolved
@dominikg
Copy link
Member Author

lgtm. I'm not sure if there's an easy way to add a test for this?

there is https://github.com/sveltejs/svelte/tree/master/test/sourcemaps and a new sample could be added, but it requires some rethinking / extra work on index.ts too because currently outputFilename is hardcoded and the existing samples never use filenames with paths.

@dominikg
Copy link
Member Author

turns out you can override it in sample config, so i've added a sample that fails without the changes in Component.ts and passes with them.

Now that i spent more time looking at this i wonder if a missing outputFilename in compilerOptions is an error in itself or if it should fall back to filename instead 🤔

@ralyodio
Copy link

ralyodio commented Jul 31, 2021

I'm seeing this error too.

Sourcemap for "/home/ettinger/www/chovy.neocities.org/src/routes/index.svelte" points to missing source files

I'm using adapter-static

Copy link

@ralyodio ralyodio left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@tanhauhau tanhauhau left a comment

Choose a reason for hiding this comment

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

probably include some tests for different combinations of compile_options.filename, compile_options.outputFilename and compile_options.cssOutputFilename?

@benmccann
Copy link
Member

@milahu @dmitrage would you like to take a look at this one since it deals with sourcemaps?

@milahu
Copy link
Contributor

milahu commented Jul 31, 2021

since it deals with sourcemaps

not really, this is just pretty-printing file paths ... but yepp @tanhauhau

@benmccann
Copy link
Member

this is just pretty-printing file paths

it's actually fixing the pointer in the source map to the source file. Vite is complaining that Svelte's source maps are broken because that file path is relative to the project root and not the source map. there's some more details about that in the links provided in the PR description

@dominikg
Copy link
Member Author

dominikg commented Aug 2, 2021

probably include some tests for different combinations of compile_options.filename, compile_options.outputFilename and compile_options.cssOutputFilename?

basic combinations for filename + outputFilename are covered by sourcemap-basename and sourcemap-basename-without-outputname samples.
Adding more samples would blow it out of proportion i think, unless we could somehow define arrays of configs in a single sample. 🤷‍♂️

I have added a css preprocessor to sourcemap-basename-without-outputname aswell, but it seems like cssOutputFilename is never used (the option is defined but not used in preprocess or compile to rebase/rewrite the source of css maps). I feel like that warrants it's own PR though as this one here is mostly aimed at fixing the issue with the js sourcemap.

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.

None yet

6 participants