You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Including that would allow you to inline the original scripts, which would lead to a very long sourceURL, but would be much simpler from a user perspective. Since this should only really be used for debugging, I don't think it's an issue if the sourceURLs get really long.
So it looks indeed like it's still supported. Unfortunately the underlying source-map I'm using doesn't support it, so I have to do some tinkering.
I definitely agree however that his would simplify things for the user immensely and since this is for development only I wouldn't be too concerned about file-size (you would just not include sourcemaps in production).
If you want to debug production code however it makes sense to not include the sourceFiles only and load the actual sources via sourceRoot from any given url. Looks like I need to allow different options here.
If you launch the sample app and watch the logs, you'll see that it no longer loads the sources, since it already has them inlined in the source map.
Actually just realized, inlined sourcemaps are not used properly, however using a file://full/path/to/original.js source file solves this issue as well, since it now loads the files from the disk directly (no relative path to bundle necessary).
Will figure out tonight how to make inlined content work ;).
Actually I found the bug (it is sourcesContent - I had sourceContent).
At this point I can generate the bundle, delete all originals and still see/debug original code.
Good idea, I removed the static server from the example, however this doesn't prove much, since I am using file:// as the source root which enables chrome to load it without a server even if the source wasn't included.
The browserify sample I mentioned above is a better proof since it allows you to generate the bundle, then delete the original files and confirm that you can still see the original sources.
I'm super excited to see this stuff in the core of browserify. At that point I'll be ready to build a little middlware library and begin switching all my projects over from component to browserify.
I'll get this into a state where it can be merged in at least with just the debug option which for now will always inline the sources.
We should think about some advanced browserify options as well @substack, i.e.:
don't inline when desired to allow people to use sourcemaps in production (point sourceRoot to dev server)
set sourceRoot so files in sources appear as js/foo.js instead of /User/../../public/js/foo.js (in this case setting sourceRoot to /User/../../public would do the trick
Cool, looks like it's merged already. Very excited to start using it 😄
I think this issue is now fully resolved. I guess you might want to open a separate issue to get optional support for source maps in production too. I think they'll be quite a big additional challenge with that though as you'll need to also support pass through with uglify-js etc.
Activity
thlorenz commentedon Mar 11, 2013
Great idea!
Dug into chrome tools source (canary) and found:
So it looks indeed like it's still supported. Unfortunately the underlying source-map I'm using doesn't support it, so I have to do some tinkering.
I definitely agree however that his would simplify things for the user immensely and since this is for development only I wouldn't be too concerned about file-size (you would just not include sourcemaps in production).
If you want to debug production code however it makes sense to not include the sourceFiles only and load the actual sources via
sourceRootfrom any given url. Looks like I need to allow different options here.thlorenz commentedon Mar 11, 2013
Added in version 0.2.
I also updated the browser-pack and browserify forks and the sample app.
If you launch the sample app and watch the logs, you'll see that it no longer loads the sources, since it already has them inlined in the source map.
Actually just realized, inlined sourcemaps are not used properly, however using a
file://full/path/to/original.jssource file solves this issue as well, since it now loads the files from the disk directly (no relative path to bundle necessary).Will figure out tonight how to make inlined content work ;).
thlorenz commentedon Mar 11, 2013
Actually I found the bug (it is
sourcesContent- I hadsourceContent).At this point I can generate the bundle, delete all originals and still see/debug original code.
i.e. try the example in my browserify fork.
Do a
node build.js. Thenrm js/foo.js && rm js/main.js.open index.html, open dev tools (may have to refresh twice for the mapped files to show).Although the files no longer exist, their content is shown.
ForbesLindesay commentedon Mar 11, 2013
Excellent. A nice demo might be to just not serve up the original source files.
thlorenz commentedon Mar 11, 2013
Good idea, I removed the static server from the example, however this doesn't prove much, since I am using
file://as the source root which enables chrome to load it without a server even if the source wasn't included.The browserify sample I mentioned above is a better proof since it allows you to generate the bundle, then delete the original files and confirm that you can still see the original sources.
ForbesLindesay commentedon Mar 11, 2013
I'm super excited to see this stuff in the core of browserify. At that point I'll be ready to build a little middlware library and begin switching all my projects over from component to browserify.
thlorenz commentedon Mar 11, 2013
Nice!
I'll get this into a state where it can be merged in at least with just the debug option which for now will always inline the sources.
We should think about some advanced browserify options as well @substack, i.e.:
sourceRootto dev server)sourceRootso files in sources appear asjs/foo.jsinstead of/User/../../public/js/foo.js(in this case setting sourceRoot to/User/../../publicwould do the trickthlorenz commentedon Mar 12, 2013
Ok, the main functionality is in.
Until @substack pulls this, you could use my fork @ForbesLindesay to play with it.
ForbesLindesay commentedon Mar 12, 2013
Cool, looks like it's merged already. Very excited to start using it 😄
I think this issue is now fully resolved. I guess you might want to open a separate issue to get optional support for source maps in production too. I think they'll be quite a big additional challenge with that though as you'll need to also support pass through with uglify-js etc.