Skip to content
This repository has been archived by the owner on May 14, 2018. It is now read-only.

Commit

Permalink
fixed file property in sourceMap #20
Browse files Browse the repository at this point in the history
  • Loading branch information
Norman Rzepka committed Oct 17, 2014
1 parent 0deae32 commit d41f5f5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
6 changes: 6 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ function logger() {
}


gulp.task("sample", function () {
return gulp.src("test/fixtures/core/**/*.js")
.pipe(rjs("nested_requirejs"))
.pipe(gulp.dest(".tmp"));
})

gulp.task("example", function () {
return gulp.src("build/{javascripts,bower_components}/**/*.{js,coffee}")
.pipe(gif(function (file) { return path.extname(file.path) == ".coffee"; }, coffee()))
Expand Down
7 changes: 5 additions & 2 deletions lib/export.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function() {
var b, escodegen, fixModule, through, vinylSourcemapsApply, _;
var b, escodegen, fixModule, path, through, vinylSourcemapsApply, _;

_ = require("lodash");

Expand All @@ -9,6 +9,8 @@

through = require("through2");

path = require("path");

vinylSourcemapsApply = require("vinyl-sourcemaps-apply");

module.exports = fixModule = function(options) {
Expand Down Expand Up @@ -64,7 +66,8 @@
if (sourceFile.sourceMap) {
generatedCode = escodegen.generate(ast, {
sourceMap: true,
sourceMapWithCode: true
sourceMapWithCode: true,
file: sourceFile.sourceMap.file
});
sourceFile.contents = new Buffer(generatedCode.code, "utf8");
vinylSourcemapsApply(sourceFile, generatedCode.map.toJSON());
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
"author": "Norman Rzepka <norman@scm.io> (http://scm.io)",
"license": "MIT",
"dependencies": {
"acorn": "~0.5.0",
"acorn": "^0.9.0",
"ast-types": "~0.3.16",
"async": "~0.2.10",
"escodegen": "^1.3.3",
"escodegen": "^1.4.1",
"lodash": "~2.4.1",
"through2": "~0.4.1",
"vinyl": "^0.2.3",
"vinyl-fs": "^0.3.0",
"vinyl-sourcemaps-apply": "^0.1.1"
"vinyl-fs": "^0.3.9",
"vinyl-sourcemaps-apply": "^0.1.4"
},
"devDependencies": {
"coffee-script": "~1.7.1",
Expand Down
2 changes: 2 additions & 0 deletions src/export.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ _ = require("lodash")
b = require("ast-types").builders
escodegen = require("escodegen")
through = require("through2")
path = require("path")
vinylSourcemapsApply = require("vinyl-sourcemaps-apply")

module.exports = fixModule = (options = {}) ->
Expand Down Expand Up @@ -106,6 +107,7 @@ module.exports = fixModule = (options = {}) ->
ast,
sourceMap : true
sourceMapWithCode : true
file : sourceFile.sourceMap.file
)

sourceFile.contents = new Buffer(generatedCode.code, "utf8")
Expand Down
1 change: 1 addition & 0 deletions test/expected/foo.js.map.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"version": 3,
"sources": [ "foo.js" ],
"file": "foo.js",
"names": [ "define", "call" ],
"mappings": "AACA,aAAY;AAAA,IACVA,MAAA,C,KAAA,E,EAAA,EAAO,KAAP,EADU;AAAA,CAAZ,CAGGC,IAHH,CAGQ,IAHR",
"sourcesContent": [ "// Generated by CoffeeScript 1.7.1\n(function() {\n define(\"FOO\");\n\n}).call(this);\n" ]
Expand Down
1 change: 1 addition & 0 deletions test/expected/index.js.map.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"version": 3,
"sources": [ "index.js" ],
"file": "index.js",
"names": [ "define", "foo", "console", "log", "call" ],
"mappings": "AACA,aAAY;AAAA,IACVA,MAAA,C,OAAA,E,OAAA,EAAgB,UAASC,GAAT,EAAc;AAAA,QAC5BC,OAAA,CAAQC,GAAR,CAAYF,GAAZ,EAD4B;AAAA,QAE5B,SAF4B;AAAA,KAA9B,EADU;AAAA,CAAZ,CAMGG,IANH,CAMQ,IANR",
"sourcesContent": [ "// Generated by CoffeeScript 1.7.1\n(function() {\n define([\"foo\"], function(foo) {\n console.log(foo);\n debugger;\n });\n\n}).call(this);\n" ]
Expand Down

0 comments on commit d41f5f5

Please sign in to comment.