Search code examples
javatypescriptwebpackweb-component

Should I use webpack or just html imports when building a single page app (large scale)


I have been reading this tutorial about html imports. However I became more confused after it. I'm coming from an Angular 1 & 2 background with some React recently. I have been progressing trough all the stages of javascript evolution. Using scripts in the header than require.js than system.js and now I've been doing just fine with webpack.

Reading about these imports it becomes a bit fuzzy. I don't have a clear image when to or not to use them. If webpack is used, do I still need html imports (probably for 3rd party stuff)? Certainly I love typescript and I definitely don't want to build the js artefacts myself using the command line like in the early days. I feel webpack is a must-have.

I know this question can be viewed as vague and closed, but I'm really stuck. Right now resources on web components are few and I can't manage to find my way towards a clear and confident answer.

P.S I want to use vanila components, not polymer stuff.


Solution

  • Some of the major browsers(i.e. Firefox) are not planning to ship HTML imports, ever. Quoting from https://hacks.mozilla.org/2014/12/mozilla-and-web-components/

    Mozilla will not ship an implementation of HTML Imports. We expect that once JavaScript modules — a feature derived from JavaScript libraries written by the developer community — is shipped, the way we look at this problem will have changed.

    It will still be good to learn about the standard though, because of its unique feature of HTML parsing, which won't be possible with any representation of HTML in JS modules(which are being pioneered as replacement for HTML imports)

    But for now, it seems like HTML imports are not getting anywhere, until something comes out of HTML Modules proposal, which plans to rebuild HTML Imports functionality using the ES Modules.