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

source maps are off by 3 lines #410

Closed
Raynos opened this issue May 30, 2013 · 7 comments
Closed

source maps are off by 3 lines #410

Raynos opened this issue May 30, 2013 · 7 comments

Comments

@Raynos
Copy link
Contributor

Raynos commented May 30, 2013

I'm using browserify2 on a large project and the source map break points seem to be off by 3 lines for some reason.

Is this a known issue?

@thlorenz
Copy link
Collaborator

No, this is the first time I heard about this.
Could you try to figure out if this was the case in older browserify versions (i.e. right after source maps were added)?
Maybe something down the line broke it.

@Raynos
Copy link
Contributor Author

Raynos commented May 30, 2013

I'll get back to this once I have a reproduction case.

@andyperlitch
Copy link

Are you using any transforms? I had a similar issue, but realized that it was from a transform that actually added several lines of code. Just a thought...

@thlorenz
Copy link
Collaborator

thlorenz commented Jun 8, 2013

Since browserify will consume existing source maps and adjust them to account for the file's position inside the bundle, if the original source map is off, that couldn't be corrected.

If a transform is adding lines to a file without adjusting source maps if they exist, that could also be an issue. In that case I'd suggest to either fix that transform to stop doing that (i.e. put it on same line with semicolons separating statements) or don't use that transform.
However this should only be an issue if a file is transformed that has been transpiled previously. This kind of complexity is not recommended in general.

I doubt though that @Raynos is using a transpiler so the problem may lie elsewhere.

@Raynos
Copy link
Contributor Author

Raynos commented Jun 8, 2013

Oh wait. I do prefix like 3 lines of code at the top of my file for

(function () {
    window.NODE_ENV = {{process.env.NODE_ENV}}
})()

@thlorenz
Copy link
Collaborator

thlorenz commented Jun 8, 2013

@Raynos that's pretty funny.

Two options:

  • join the lines and stick it right in front of the first line but onto the same line (not changing line count)
  • use mold-source-map to pull out the source maps after bundling and add a 3 line offset to each (may slow down your bundle generation though)

@Raynos
Copy link
Contributor Author

Raynos commented Jun 8, 2013

I removed my new lines.

@Raynos Raynos closed this as completed Jun 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants