TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Back End Apps with Webpack: Part I

67 pointsby jlongsterabout 10 years ago

11 comments

danabramovabout 10 years ago
<i>&gt;For example, hot module replacement allows you to change a module and update the existing instance live. This is the juice within react-hot-loader and this is the kind of stuff we need to be building. You&#x27;ll never look back after experiencing this.</i><p>I second this. (Disclaimer: I wrote React Hot Loader.)<p>Webpack&#x27;s live reloading system is not browser-specific, does not depend on attaching debuggers or doing anything else invasive.<p>All it does is represent module cache as (id) -&gt; (function) map and give you the tools to “handle” module updates, as if modules were Observables and you subscribed to “new versions” of them. If update is unhandled, it bubbles.<p>This is what allows Hot Module Replacement to work for React components, CSS and Markdown files, and even classes on backend.
_greim_about 10 years ago
I&#x27;m trying to boil this down to an easily-digestable list of benefits for server-side development, since I&#x27;m completely unfamiliar with webpack. So far I have this:<p><pre><code> * Transpiles code that runs in node, not just code that runs in browsers. * Hot-reloads modules, so I don&#x27;t have to restart my server a lot. * Does source maps, presumably which are exposed via tools like node-debug. </code></pre> Anything else?
jlongsterabout 10 years ago
I don&#x27;t know why the title was changed to &quot;back end&quot;, that&#x27;s the worst way to say it. If you don&#x27;t like &quot;backend&quot;, at least use &quot;back-end&quot;.
评论 #9212504 未加载
coderzachabout 10 years ago
I guess I&#x27;d like to know more about the benefits of this approach. Packaging up a single js file seems unnecessary when you&#x27;re running on the server.
评论 #9212301 未加载
_greim_about 10 years ago
I&#x27;m also trying to wrap my brain around what webpack <i>is</i>, since I&#x27;ve been thus far conditioned to think of the build runner (e.g. gulp) and the bundle maker (e.g. browserify) as being separate.<p>The article seems to be saying this, but am I correct to come away thinking of webpack as a &quot;module-aware build runner&quot; that replaces both gulp and browserify (for example)?
评论 #9213608 未加载
评论 #9213479 未加载
juliennakacheabout 10 years ago
I&#x27;ve been playing with this a for a few months now. Thanks to webpack &#x2F; react starter (<a href="https://github.com/webpack/react-starter" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;webpack&#x2F;react-starter</a>), you get that for free (with server-side rendering of your apps).<p>What I&#x27;d like to see is for webpack to add features from Pants like self-bootstrapping executables (PEX) or run tests based on which part of the code was affected by a commit. For the executable part, I guess Docker kind of solve that issue. See <a href="http://pantsbuild.github.io/" rel="nofollow">http:&#x2F;&#x2F;pantsbuild.github.io&#x2F;</a> for more info<p>To be continued :)
latchkeyabout 10 years ago
Webpack is pretty nice, but it feels so 2014.<p>In 2015, we have ES6 modules now. Instead of define&#x2F;require, we have import&#x2F;export and it is standards based now, which is nice.<p>For systems that do not support ES6 syntax directly, this is provided today with tools like SystemJS [1] and jspm [2]. SystemJS is great because it supports all of the module formats for backwards compatibility. jspm is great because it doesn&#x27;t matter where you grab your dependencies from (npm&#x2F;github&#x2F;bower&#x2F;etc).<p>I agree with the authors comment about gulpfiles being hacky and not very DRY (don&#x27;t repeat yourself). That said, his examples felt very hacked together as well, there is too much programming in there. Do I copy that build file across every new project I create?<p>gulpfiles are great because they provide extra functionality that is missing, like only re-transpiling files that change. For large projects this can really be a time saver. webpack has that by running a separate server process, complicated! Projects like gulp-helpers [3] try to bring a tiny bit of sanity and re-usability to gulpfiles by making things a bit more DRY and configuration based. It is just an example of one way to do things, but hopefully you see my point.<p>[1] <a href="https://github.com/systemjs/systemjs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;systemjs&#x2F;systemjs</a> [2] <a href="http://jspm.io/" rel="nofollow">http:&#x2F;&#x2F;jspm.io&#x2F;</a> [3] <a href="https://github.com/lookfirst/gulp-helpers" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lookfirst&#x2F;gulp-helpers</a>
评论 #9212656 未加载
评论 #9212607 未加载
评论 #9213267 未加载
评论 #9212673 未加载
TheAceOfHeartsabout 10 years ago
I&#x27;m using webpack with iojs for an isomorphic react app, why don&#x27;t you just add a regexp to ignore all non-relative modules?<p>I use the following regexp: &#x2F;^[a-z\-0-9]+$&#x2F;<p>Any reason to get the full module list over just using this regexp?
评论 #9213274 未加载
pichalsiabout 10 years ago
OT: anyone can teach what this construct is useful for? [&#x27;.bin&#x27;].indexOf(x) === -1<p>Same as &#x27;.bin&#x27; === x?
评论 #9213279 未加载
liviuabout 10 years ago
Webpack is awesome but I prefer gulp with babeljs and browserify.
djfmabout 10 years ago
Why would you want to combine JS files from the back-end?