Skip to content
Browse files

Implement source mapping against original source files.

  • Loading branch information...
1 parent d6dafa9 commit b97fe6640c1d2c30fa92635c8d754c976266f5aa @jcoglan committed Mar 25, 2012
Showing with 26 additions and 6 deletions.
  1. +17 −6 lib/jake/package.rb
  2. +8 −0 test/expected/ext-min.js.map
  3. +1 −0 test/jake.yml
View
23 lib/jake/package.rb
@@ -33,13 +33,24 @@ def code(build_name, with_header = true)
if source_map = packer.delete(:source_map)
output_path = build_path(build_name)
- source_path = Packr::FileSystem.relative_path(build_path(source_map), output_path)
+ packer.update(:output_file => output_path)
- packer.update(
- :output_file => output_path,
- :source_files => {source_path => 0}
- )
- code = code(source_map)
+ if source_map == :source
+ source_offsets = {}
+ code = head ? head + "\n" : ''
+
+ files.each do |file|
+ source_path = Packr::FileSystem.relative_path(file, output_path)
+ source_offsets[source_path] = code.size
+ code << Jake.erb(Jake.read(file)).result(@build.helper.scope) << "\n"
+ end
+
+ packer.update(:source_files => source_offsets)
+ else
+ source_path = Packr::FileSystem.relative_path(build_path(source_map), output_path)
+ packer.update(:source_files => {source_path => 0})
+ code = code(source_map)
+ end
else
code = Jake.erb(source).result(@build.helper.scope)
end
View
8 test/expected/ext-min.js.map
@@ -0,0 +1,8 @@
+{
+ "version": 3,
+ "file": "ext-min.js",
+ "sourceRoot": "",
+ "sources": ["../src/basic-ext.js", "../src/basic.js"],
+ "names": ["myVar", "something"],
+ "mappings": ";;;;;;ACAA,OACE,eAAiB,KAEjB,SAASC,GACP,IAAID,IACJ,OAAOA,EAAQ,KAAK,KAAOC,IDL/B,MAAM,KAAO;"
+}
View
1 test/jake.yml
@@ -20,6 +20,7 @@ packages:
extends: basic
packer:
private: false
+ source_map: :source
files:
- basic-ext
meta:

0 comments on commit b97fe66

Please sign in to comment.
Something went wrong with that request. Please try again.