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

Input sourcemaps seem to not be honored #64

Open
bytenik opened this issue Dec 15, 2015 · 11 comments
Open

Input sourcemaps seem to not be honored #64

bytenik opened this issue Dec 15, 2015 · 11 comments

Comments

@bytenik
Copy link

bytenik commented Dec 15, 2015

I'm running gulp-typescript before piping through gulp-babel. I init sourcemaps before piping through TypeScript. The output source map from TypeScript seems to be ignored by gulp-babel. Babel itself does support input type maps.

Am I doing something wrong or is this a bug?

@bytenik
Copy link
Author

bytenik commented Dec 15, 2015

return gulp.src(source)
    .pipe(sourcemaps.init())
    .pipe(ts({ noExternalResolve: true, target: "ES6" }))
    .pipe(babel({ presets: ["es2015"] }))
    .pipe(concat("ff-app.js"))
    .pipe(sourcemaps.write({ includeContent: false, sourceRoot: "/" }))
    .pipe(gulp.dest(paths.scriptDist));

@sindresorhus
Copy link
Member

// @pofigizm

@bytenik
Copy link
Author

bytenik commented Dec 15, 2015

It actually does not appear that you pass inputSourceMap into babel, so this would never be able to work as written. 😢

@pofigizm
Copy link
Contributor

@bytenik,
are you use version 6.1.1 of gulp-babel?
are you get right source map of each process separately?

@Rush
Copy link

Rush commented Dec 25, 2015

I confirm that it's broken.

@pofigizm
Copy link
Contributor

I can not reproduce.

https://github.com/Pofigizm/gbsm-bug

@bytenik, @Rush could you help?

@bytenik
Copy link
Author

bytenik commented Jan 30, 2016

I just revisited this. Its true that your virtually identical gulpfile does not have the issue, whereas mine does. But the build task is line-for-line identical. I can confirm, however, that commenting out the pipe(babel(...)) line produces a sourcemap for me with the proper sources. I'm on 6.1.1. My dev deps match yours:

    "babel-preset-es2015": "^6.3.13",
    "bower": "^1.7.2",
    "gulp": "^3.9.0",
    "gulp-babel": "^6.1.1",
    "gulp-concat": "^2.6.0",
    "gulp-less": "^3.0.5",
    "gulp-minify-css": "^0.3.13",
    "gulp-rename": "^1.2.2",
    "gulp-sass": "^2.1.1",
    "gulp-sourcemaps": "^1.6.0",
    "gulp-typescript": "^2.10.0",
    "gulp-util": "^2.2.14",
    "jspm": "^0.16.23",
    "shelljs": "^0.3.0",
    "tsd": "^0.6.5"

@pofigizm
Copy link
Contributor

pofigizm commented Feb 2, 2016

One diff which I found in deps is gulp-sourcemap, but when I change it to the same I won't reproduce the issue.
Also I can't find babel in yours dev list. Is you have the same version?

Can you extract a part of your project where the issue is reproduced? And push it?

p.s. Magic does not exist!

@asvetliakov
Copy link

Just encountered problem, but:
styles.ts is producing "sources":["app/styles.js","app/styles.ts"], << should be two sources here?
Root.tsx is producing "sources":["app/Root.js"],
Hope that helps

@pofigizm
Copy link
Contributor

@asvetliakov, I can't reproduce it, too.
Could you extract the minimal part of your project where your problem is reproduced?
Could you make separate repo with it or change my https://github.com/Pofigizm/gbsm-bug?

@dmurat
Copy link

dmurat commented Mar 31, 2017

I've just stumbled on this problem of invalid source maps. In general, I'm experiencing the same issues as other reporters do.

I've tried to use gulp-babel on pretty complex Angular/TypeScript projects (15 of them in total) with very similar manifestations. In my case, sourcemaps are generated for each TypeScript file individually.

In some cases sourcemaps were produced with two entries in sourcemap's sources
array (one for TypeScript file, and one for JavaScript file), while in other cases sources array contains only single entry for TypeScript file. Such sourcemaps were, in general, unusable in the browser for debugging.

After digging through gulp-babel code and babel documentation, I've come up with gulp-babel version which produces correct source maps for all my projects. The main thing is to use babel's inputSourceMap option set with input file's sourceMap object when one is present in the input file.

In cases when there is no input sourceMap, my implementation falls back to the current gulp-babel's defaults. In that later case, to produce sourcemaps for babel transformation only, user needs to specify babel's sourceMaps option (it can be truthy value, inline string or both string).

I tried to reproduce the problem with that github repo that you have provided, but without any luck. I guess, the problem manifests itself in more complex cases and I didn't found the actual thingy that triggers it. On the positive side, my implementation passes all tests currently provided in gulp-babel.

Here is pull request

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

No branches or pull requests

6 participants