Permalink
Browse files

Initial source map support.

  • Loading branch information...
1 parent fb37104 commit df202a058a5a322cbb63b4d06a9ae265bd85c770 @jcoglan committed Mar 24, 2012
View
@@ -88,7 +88,14 @@ def write!
@build.helper.build = name.to_s
FileUtils.mkdir_p(File.dirname(path))
- File.open(path, 'wb') { |f| f.write(code(name).strip) }
+
+ output_code = code(name)
+ source_map = output_code.source_map if output_code.respond_to?(:source_map)
+
+ File.open(path, 'w') { |f| f.write(output_code.strip) }
+ if source_map
+ File.open(source_map.filename, 'w') { |f| f.write(source_map.to_s.strip) }
+ end
@build.fire(:file_created, self, name, path)
View
@@ -25,13 +25,28 @@ def code(build_name, with_header = true)
return with_header ? cached[:with_header] : cached[:code]
end
- code = Jake.erb(source).result(@build.helper.scope)
- head = header
+ packer = packer_settings(build_name)
+ head = header
- if packer = packer_settings(build_name)
+ if packer
packer = packer.merge(:header => head)
+
+ if source_map = packer[: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,
+ :source_files => {source_path => 0}
+ )
+ code = code(source_map)
+ else
+ code = Jake.erb(source).result(@build.helper.scope)
+ end
+
code = Packr.pack(code, packer)
else
+ code = Jake.erb(source).result(@build.helper.scope)
code = head + "\n" + code if head
end
@@ -5,3 +5,4 @@
**/
Basic={VERSION:"0.5.0-min",function(a){var b=4;return b+this._0+a}};
+//@ sourceMappingURL=basic-min.js.map

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -5,4 +5,6 @@
**/
Foo=(function(b,c){var a=true;return{_0:null,field:a,global:foo}})(window,something);
+//@ sourceMappingURL=foo-min.js.map
Basic={VERSION:"0.5.0-min",function(a){var b=4;return b+this._foo+a}};Basic.Ext="MIN";
+//@ sourceMappingURL=ext-min.js.map
View
@@ -5,3 +5,4 @@
**/
Basic={VERSION:"0.5.0-min",function(a){var b=4;return b+this._foo+a}};Basic.Ext="MIN";
+//@ sourceMappingURL=ext-min.js.map
@@ -5,3 +5,4 @@
**/
Foo=(function(b,c){var a=true;return{_0:null,field:a,global:foo}})(window,something);
+//@ sourceMappingURL=foo-min.js.map
@@ -1,3 +1,4 @@
/** Alternate header 0.5.0-min **/
(function(object){var Bar={_0:object}})();
+//@ sourceMappingURL=bar-min.js.map

0 comments on commit df202a0

Please sign in to comment.