I recently setup a typescript > webpack project and I was really disappointed with the dev-tools debugging experience.
Webpack renames imported bindings, so
import {foo} from './bar';
becomes something like this
let __webpack_require_foo_bar = _webpack_modules[5 /* foo */].bar;
So if you are paused in the debugger and want to use foo in a watch statement, or use it in a computation you'll have to reference the real source instead of the source maps.
I found questions on SO, and it seems like a known and accepted problem, but I know I won't be able to sell my team on Webpack because of this.
lib-main-dev.js is an example of the output when running 'webpack -d', which is short for '--devtool sourcemap --debug --output-pathinfo', it has the same problem*
There are really two problems contributing to this.
First, webpack rewrites import/export statments and never introduces a variable binding with the same name as the bindings used in the original import/export.
Second sourcemaps _do_ map lines of compiled code to lines of original source, but they _do not_ map renamed variables to original names. As an example, enable minifiaction and soucemaps then try to debug a function. You might notice that the variables are all called a, b, c, and other short uglified strings now.
* I just realized that the file I uploaded is missing the ends of each line, so that file is incorrect.
Doesn't this have more to do with Babel and less to do with Webpack? I think this originates with how Babel treats ES6 Modules differently from CommonJS, and if you were to instead do:
I don't think Babel is the cause, not in this case. Im using typescript in full es6 mode, module and target are both es6. Babel isn't even in my node_modules.
Stuff like this is the reason the Unix Philosophy of small "composable" tools doesn't work in this ecosystem. Because if you run your code through three different preprocessor steps, everything breaks and your source maps aren't even close to usable anymore, so you can't debug anymore.
I've been campaigning for more of a monolithic design in the TS ecosystem. Not that the architecture of the TS compiler needs to be monolithic, but rather that TS users should have a blessed and supported stack for everything. We should be able to rely on TS components for linking/packaging, polyfills, optimization, conditional compilation, minification, source map packaging, asset prepackaging and loading, ES6+ standards compliance, etc.
But since advocating for anything rhyming with -olith is heresy in the programming world, I'm not confident we'll get there.
This is a big benefit of Meteor's build system - it has several improvements that make debugging more straightforward than with Webpack and default Babel import compilation.
According to sokra, this ought to be the final rc. From the release notes: "This is probably the last RC. We released it as final test. If no critial bugs are discovered, we release 2.2.0 in < 10 days."
I tried the dynamic import/require once and it was really nice.
I could just write a normal SPA and require some stuff in every route, so the client only downloads the code that is used for the current page and things worked fine without extras needed.
If each page has different dependencies, you're not sending much duplicate content. Also, SSR supports incremental rendering (due to HTTP streaming), something that is currently impossible to do with SPAs.
Webpack renames imported bindings, so
becomes something like this So if you are paused in the debugger and want to use foo in a watch statement, or use it in a computation you'll have to reference the real source instead of the source maps.I found questions on SO, and it seems like a known and accepted problem, but I know I won't be able to sell my team on Webpack because of this.