# Languages and technologies - [Languages and technologies](#languages-and-technologies) - [JavaScript](#javascript) - [Polyfills](#polyfills) - [Vue](#vue) - [Vue Router](#vue-router) - [Vuex (state management)](#vuex-state-management) - [JavaScript FAQ](#javascript-faq) - [HTML](#html) - [Templates](#templates) - [Render functions](#render-functions) - [HTML FAQ](#html-faq) - [CSS](#css) - [SCSS](#scss) - [Importing global modules](#importing-global-modules) - [Referencing aliased asset URLs](#referencing-aliased-asset-urls) - [Design variables and tooling](#design-variables-and-tooling) - [CSS modules](#css-modules) - [Styling subcomponents](#styling-subcomponents) - [Sharing SCSS variables with JavaScript](#sharing-scss-variables-with-javascript) - [Global CSS](#global-css) - [CSS FAQ](#css-faq) ## JavaScript Our JavaScript is compiled by Babel, using the [`@vue/babel-preset-app`](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/babel-preset-app) as a base configuration. You can update this configuration in `.babelrc.js`. If you're new to features such as `const`, `let`, and `=>` (arrow functions), take some time to read about the following features in Babel's ES2015 guide: - [Arrow functions](https://babeljs.io/docs/en/learn/#arrows-and-lexical-this) - [Template literals](https://babeljs.io/docs/en/learn/#template-strings) - [Destructuring](https://babeljs.io/docs/en/learn/#destructuring) - [Spread operator](https://babeljs.io/docs/en/learn/#default-rest-spread) - [`let`/`const`](https://babeljs.io/docs/en/learn/#let-const) - [`for`...`of`](https://babeljs.io/docs/en/learn/#iterators-forof) Reading these sections alone will get you 99% of the way to mastering Babel code. It's also a good idea to read about Promises, if you don't yet feel comfortable with them. Here's a [good intro](https://developers.google.com/web/fundamentals/getting-started/primers/promises). ### Polyfills This project uses Vue CLI's [modern mode](https://cli.vuejs.org/guide/browser-compatibility.html#modern-mode), which creates two bundles: one modern bundle targeting modern browsers that support [ES modules](https://jakearchibald.com/2017/es-modules-in-browsers/), and one legacy bundle targeting older browsers that do not. For each bundle, polyfills for any JavaScript features you use are included based on the target bundle and supported browsers defined by `browserslist` in `package.json`. ### Vue Since Vue is such a huge part of our app, I strongly recommend everyone read through at least the _Essentials_ of [Vue's guide](https://vuejs.org/v2/guide/). ### Vue Router To understand how to manage pages with Vue Router, I recommend reading through the _Essentials_ of [those docs](https://router.vuejs.org/en/essentials/getting-started.html). Then you can read more about [routing in this application](routing.md). ### Vuex (state management) To wrap your head around our state management, I recommend reading through [those docs](https://vuex.vuejs.org/guide), starting at _What is Vuex?_ and stopping before _Application Architecture_. Then skip down and read [_Form Handling_](https://vuex.vuejs.org/en/forms.html) and [_Testing_](https://vuex.vuejs.org/en/testing.html). Finally, read about [state management in this application](state.md). ### JavaScript FAQ **Why not use TypeScript instead of JavaScript? Isn't that more appropriate for enterprise environments?** At its current rate of development, I think TypeScript will eventually _become_ the standard, but I don't think it's there yet for application development. Here's my reasoning: - The vast majority of bugs I encounter are _not_ due to type violations. The most powerful tools against bugs remain linting, tests, and code reviews - none of which are made easier by TypeScript. - TypeScript doesn't guarantee type safety - that still requires discipline. You can still use hundreds of `any` annotations and libraries without any type definitions. - In Visual Studio Code, users can already get a lot of useful intellisense (including type information) without having to use TypeScript. [JSDoc comments](https://jsdoc.app/about-getting-started.html) can also be added to [serve the same purpose](https://blog.usejournal.com/type-vue-without-typescript-b2b49210f0b) on an as-needed basis. - Despite most bugs having nothing to do with type violations, developers can spend _a lot_ of time working towards full type safety, meaning teams unaccustomed to strongly typed languages may face significant drops in productivity. As I mentioned earlier, I think that time would be better spent on tests and code reviews. - While the next version of Vuex will be designed with TypeScript in mind, the current version can be particularly painful with TypeScript. ## HTML All HTML will exist within [`.vue` files](https://vuejs.org/v2/guide/single-file-components.html), either: - in a `