6 ms·
Because the code you write is not what is loaded into the browser, it’s bundled and loaded in chunks.
by Dangeranger 7y ago
Because the code you write is not what is loaded into the browser, it’s bundled and loaded in chunks.
- 5cott0 7y agoI still don’t see how that’s not vanilla.js
- TuringTest 7y agoBecause webpack is not part of the language specification.
- 5cott0 7y agoSo I guess using VSCode isn’t vanilla either cause it’s not part of the language spec?
- __ryan__ 7y agoEpic point being made here. TypeScript is Vanilla JS as well because it outputs JS.
- 5cott0 7y agoSo now VSCode only writes TypeScript just like Webpack only bundles React?
- deleted 7y ago[deleted]
- uryga 7y agohow are an editor and a code preprocessor comparable here? they serve entirely different purposes, unless you stretch "producing code" reaally far
- 5cott0 7y agoThey're both tools. As in webpack is a tool that allows you to use a preprocessor like babel but you don't have to if you don't want to.
- uryga 7y agoyeah, so is git. would it make sense to say "So I guess using Git isn’t vanilla either cause it’s not part of the language spec?"? my point is, i can't understand why you would bring VSCode up at all in a discussion about webpack's relationship to "vanilla js" (whatever that is). (btw i was using the term "preprocessor" loosely - i meant source-transforming tools in general)
- 5cott0 7y agoThat is exactly the point, using a tool like git has absolutely nothing to do with how you interact with the DOM. Just like using webpack has nothing to do with how you interact with the DOM.
- uryga 7y agotrue, it doesn't. but imo when people say "vanilla js" they mean both no framework to abstract DOM manipulation and no build steps, whether they be transpiling from ES7 or bundling stuff. perhaps webpack can be used to just minify+concatenate a few files together, but that's not how it's usually used, and i guess not what most people mean when they talk about webpack. i am a bit biased, based on my recent experience of trying to load a webpacked library's `dist/foobar.js` into a WordPress thing via a normal <script src="..."> and having it barf all over the console, yelling about `window.module` missing and loaders and stuff. i never managed to get the bundled version to load, which reinforces my opinion - it's not "vanilla" if it needs some custom infrastructure and can't just be dropped into an existing plain js environment. i did however manage to load the unbundled source with a native ES6 <script type="module">, and it worked great! vanilla js can be pretty pleasant these days :)
- TuringTest 7y agoThe programming environment usually is not deployed to the runtime environment, so it's not a part of the built program. Libraries are. "Vanilla" language or tool has a precise meaning of using the official tool without external customizations. If you are importing a library that is not part of the language standard specification, that's by definition not vanilla. Using a development environment is not a "customization" of the language, because javascript has no official development environment that you could customize by using a different one, so the environment is not a part of the language. For languages like Smalltalk implementations that have an IDE+runtime that is THE official development environment and specification, switching the code to a different IDE+runtime would indeed be using a non-vanilla version. https://en.wikipedia.org/wiki/Vanilla_software https://en.wikipedia.org/wiki/Vanilla_software
- 5cott0 7y agoTechnically the runtime is the browser. index.js var foo = document.body.getElementById("bar"); That is dom manipulation using vanilla javascript in all modern browsers. I can use webpack, rollup, parcel, or load it in a script tag, it doesn't matter it's still just plain old javascript.
- __ryan__ 7y agoBecause you end up with Webpack runtime code in your bundles. No different than if you included a library’s source code in your code— it would not be vanilla JS.
- 5cott0 7y agoIs JSONP vanilla.js?
- Jasp3r 7y agoNo you don't, that's not how webpack works. You can use webpack's live reloading during development, but that's it. It's just a module bundler
- __ryan__ 7y ago> It's just a module bundler. It is how Webpack works, actually. Webpack does not support bundling to native ES6 modules [0], it has to bundle into a format which requires runtime code being injected to execute properly, handling imports, and whatnot instead of relying purely on native ES6 modules. Have you ever looked at the contents of a bundle? [1] Long story short, Webpack circumvents native ES6 modules in favor of other module formats. It provides a great amount of utility, but it is not Vanilla JS. [0] https://github.com/webpack/webpack/issues/2933 https://github.com/webpack/webpack/issues/2933 [1] https://pastebin.com/C2qPunwV https://pastebin.com/C2qPunwV
- dahart 7y agoI started trying to answer your first question, when I realized it’s a reasonably good question. Webpack doesn’t automatically change your JavaScript, so it is possible to use vanilla js and also Webpack. Colloquially though, “vanilla” is also referring to not using a pre-processing step of any kind, and not having project dependencies, basically directly writing the files that are loaded by browser.
- 5cott0 7y agoAnd yet people wonder why HN has a reputation as a community of pedantic dorks.
- yjftsjthsd-h 7y ago... why would people wonder that? You expect a community of hackers to not nitpick? A group largely populated by programming people who are entirely accustomed to a single character changing the entire function of a statement and who frequently expect natural language to work the same way?
- dahart 7y agoHey dammit, we’re autistic programmers, not pedantic dorks! ;) But seriously, I’m not sure that’s entirely fair. I do think Webpack feels not-vanilla, even if it doesn’t change how you manipulate the DOM.
- 5cott0 7y agoFine I'll use rollup instead.