liveBook · Manning

Babel

As explained in Web Components in Action

Babel is a JavaScript compiler and transpiler that converts modern JavaScript syntax and related language features into forms supported by older environments.

Babel is JavaScript build tooling that transpiles newer syntax, such as ES6 classes and fat-arrow functions, into older JavaScript for environments such as IE11. section 12.5

A minimal Babel setup uses:

  • @babel/core for Babel’s main feature set, @babel/cli for command-line execution, and @babel/preset-env for standard configuration. section 12.5
  • A Babel configuration containing { "presets": ["@babel/preset-env"] }. section 12.5
  • Development dependencies installed locally, keeping build tooling out of the released component. section 12.5

Separate IE output

Run Babel on a bundled component with ./node_modules/.bin/babel slider.js --out-file slider.build.js. Keep this output separate from the modern-browser build, then combine component-specific IE commands under npm run build-ie. section 12.5

npm install --save-dev @babel/core

npm install --save-dev @babel/cli

npm install --save-dev @babel/preset-env

Inspect the three npm installation commands for Babel’s core, CLI, and preset-env packages. section 12.5

How Web Components in Action covers it

How deep it goes
Explains package installation, preset configuration, CLI invocation, and npm scripts, but does not bundle modules.
Examples
Uses slider, coordinate-picker, and color-picker outputs plus npm scripts for an IE11 build.
What it assumes
Assumes npm and package.json familiarity while introducing Babel’s packages and configuration.
What you can do after
Operate/configure Babel through local CLI commands, preset-env, and npm build scripts.
How it connects
Connects transpilation with Rollup, npm, package.json, Web Components, and browser compatibility.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Components in Action. The section links point to the parts of the book it draws on.