# Source Maps with steal build

**URL:** <https://forums.bitovi.com/t/source-maps-with-steal-build/636>\
**Category:** StealJS\
**Created:** [May 11, 2017, 7:18am UTC](https://forums.bitovi.com/t/source-maps-with-steal-build/636 "2017-05-11T07:18:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nithanaroy](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/nithanaroy/32/225_2.png) [@Nithanaroy](https://forums.bitovi.com/u/Nithanaroy)\
**Post date:** [May 11, 2017, 7:18am UTC](https://forums.bitovi.com/t/source-maps-with-steal-build/636/1 "2017-05-11T07:18:35Z")

</div>

Trying to use source maps in Chrome generated by steal build. After build, folder structure and less files are recognized by browser but not the corresponding component JS files nor Model folders / files in source folder tree.

Also do not see a special request for .js.map file in Network panel

---

<div class="post-metadata">

**Author:** ![jeroencornelissen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/jeroencornelissen/32/180_2.png) [@jeroencornelissen](https://forums.bitovi.com/u/jeroencornelissen)\
**Post date:** [August 30, 2017, 2:59pm UTC](https://forums.bitovi.com/t/source-maps-with-steal-build/636/2 "2017-08-30T14:59:13Z")

</div>

We have the same problem.

We track javascript errors with [TrackJS](https://trackjs.com/) and they use the sourcemaps to highlight the error. But TrackJS can’t match the error.

The error happens on line 2 and column xxx in `main.js`. But `main.js` only has 1 line.

Any ideas?

Running out of time now, but I will try to investigate some more.

---

<div class="post-metadata">

**Author:** ![matthewp](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/matthewp/32/77_2.png) [@matthewp](https://forums.bitovi.com/u/matthewp)\
**Post date:** [August 30, 2017, 3:03pm UTC](https://forums.bitovi.com/t/source-maps-with-steal-build/636/3 "2017-08-30T15:03:21Z")

</div>

Source maps are turned off by default. You can generate them in your build script like:

```auto
stealTools.build({}, {
  sourceMaps: true,
  sourceMapsContent: true
});

```

Note that `sourceMapsContent` is not needed, it’s only helpful if the original source files are not available from the server (which is often the case if you package the `dist/` folder).

The docs [are here](https://stealjs.com/docs/steal-tools.BuildOptions.html).

---

<div class="post-metadata">

**Author:** ![jeroencornelissen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/jeroencornelissen/32/180_2.png) [@jeroencornelissen](https://forums.bitovi.com/u/jeroencornelissen)\
**Post date:** [August 31, 2017, 8:08am UTC](https://forums.bitovi.com/t/source-maps-with-steal-build/636/4 "2017-08-31T08:08:19Z")

</div>

Hi, @matthewp. I know how to generate sourcemaps, we use it. But something seems wrong.  
I’ve investigated a little more and this is what I found:

This is my `main.js` throwing an error at line 3 (foo is undefined):

```auto
'use strict';

const a = window.foo.length;

for(let i = 0; i < 10; i++) {
	console.log(i);
}

```

If I build it with `minify: false` and `sourceMaps: false` the error in the console leads me to the right position.  
 ![01 minify-false-sourcemaps-false](https://canada1.discourse-cdn.com/flex035/uploads/donejs/original/1X/d34937fd41bdceb1a68fc6ef0d80d342b905707d.png)

If I build with `sourceMaps: true`  
The error message says it fails at line 5.

 ![error-message](https://canada1.discourse-cdn.com/flex035/uploads/donejs/original/1X/1f374c08ba4882a5fed4c8b2a12dcfb83a283a3b.png)

But at line 5 ( **sourcemapped main.js** ) is the for loop and not the error.  
 ![02 minify-false-sourcemaps-true](https://canada1.discourse-cdn.com/flex035/uploads/donejs/original/1X/589fd606c7ea49c89863a200d2cc408b1588baaa.png)

Hope that clarifies the issue.

---

<div class="post-metadata">

**Author:** ![jeroencornelissen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/jeroencornelissen/32/180_2.png) [@jeroencornelissen](https://forums.bitovi.com/u/jeroencornelissen)\
**Post date:** [September 6, 2017, 6:52am UTC](https://forums.bitovi.com/t/source-maps-with-steal-build/636/5 "2017-09-06T06:52:00Z")

</div>

Anyone an idea?  
Sourcemaps are useless, the error always points to the last line of the `main.js` file…

---

<div class="post-metadata">

**Author:** ![pYr0x](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/pyr0x/32/95_2.png) [@pYr0x](https://forums.bitovi.com/u/pYr0x)\
**Post date:** [September 7, 2017, 7:23am UTC](https://forums.bitovi.com/t/source-maps-with-steal-build/636/6 "2017-09-07T07:23:36Z")

</div>

please file an issue on github. i will create a sample app and a breaking test if something goes wrong.

---

<div class="post-metadata">

**Author:** ![jeroencornelissen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/jeroencornelissen/32/180_2.png) [@jeroencornelissen](https://forums.bitovi.com/u/jeroencornelissen)\
**Post date:** [September 7, 2017, 6:26pm UTC](https://forums.bitovi.com/t/source-maps-with-steal-build/636/7 "2017-09-07T18:26:54Z")

</div>

Done: [#832](https://github.com/stealjs/steal-tools/issues/832)
