mozilla / tofino

Project Tofino is a browser interaction experiment.
https://mozilla.github.io/tofino
Apache License 2.0
647 stars 68 forks source link

Consider not using webpack at all, ot at least being consistent about what we webpack and what we don't #153

Closed victorporof closed 8 years ago

victorporof commented 8 years ago

Now that we're not gulping (https://github.com/mozilla/tofino/issues/76), and as of today babeling everything (https://github.com/mozilla/tofino/pull/142), we should consider not using webpack anymore. AFAICT, currently the only benefit of webpack is that we're able to use json loaders and import directly from json files. Since we're probably not going to rely on any other loaders [js and jsx are handled by babel, css is handled by react-free-style (https://github.com/mozilla/tofino/issues/113)], webpack has no real benefit.

victorporof commented 8 years ago

@jsantell @Mossop what do you think?

Mossop commented 8 years ago

Node already supports loading from json directly IIRC. My understanding is that the only thing webpack gives us at this point is packing all the module dependencies into one file. I don't know what that buys us. Maybe some perf? Probably only the same as if we used electron's asar thing but it complicated things.

I have heard that webpack has some support for dead code removal so maybe that might be useful, but at this early stage I don't think it is worth doing work for file size optimizations.

victorporof commented 8 years ago

At the very least we should be consistent. We're webpacking the browser ui code, but not the main process code.

victorporof commented 8 years ago

@Mossop Can we use require/import for files loaded in html documents? Currently we use webpack to bundle everything into lib/ui/browser.js, which is included as a script in static/browser.html, which is loaded by the main process code in app/main/browser.js. If we don't use webpack, do you know if modules would just work for the ui code, since that doesn't run in a node context? Maybe we can't get rid of webpack after all.

Mossop commented 8 years ago

Code loaded in BrowserWindows can use require and other node stuff just fine (unless you turn off nodeIntegration). Electron creates a node context and then appears to copy the require, process and other bits into the global for the html document.

victorporof commented 8 years ago

Nice!