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

Handle source maps for nested assets where sourceMappingURL contains the subdirectory #212

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/propshaft/compiler/source_mapping_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def compile(asset, input)

private
def asset_path(source_mapping_url, logical_path)
source_mapping_url.gsub!(/^(.+\/)?#{url_prefix}\//, "")
source_mapping_url = ::File.basename(source_mapping_url)

if logical_path.dirname.to_s == "."
source_mapping_url
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var fun; //# sourceMappingURL=/assets/nested/sourceMappingURL-already-prefixed-nested-with-subdirectory.js.map
2 changes: 2 additions & 0 deletions test/propshaft/compiler/source_mapping_urls_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class Propshaft::Compiler::SourceMappingUrlsTest < ActiveSupport::TestCase
compile_asset(find_asset("sourceMappingURL-already-prefixed.js", fixture_path: "mapped"))
assert_match %r{//# sourceMappingURL=/assets/nested/sourceMappingURL-already-prefixed-nested-[a-z0-9]{8}\.js\.map},
compile_asset(find_asset("nested/sourceMappingURL-already-prefixed-nested.js", fixture_path: "mapped"))
assert_match %r{//# sourceMappingURL=/assets/nested/sourceMappingURL-already-prefixed-nested-with-subdirectory-[a-z0-9]{8}\.js\.map},
compile_asset(find_asset("nested/sourceMappingURL-already-prefixed-nested-with-subdirectory.js", fixture_path: "mapped"))
end

test "sourceMapURL is already prefixed with an incorrect url_prefix" do
Expand Down