Build Time | Software.Land

Build Time

Overview

Build Time is a window of time in the Application Development and Release Lifecycle. The exact sequence of events in this Lifecycle depends on the project and project maintainers, with Requirement Gathering and Design typically at the beginning, and Runtime at the very end (following Release, and Deployment). Exactly what takes place in Build Time depends on the application, its language, and DevOps pipeline. The following is an example of what might take place.

Table of Contents

Front-End
1. Linting and Static Analysis
2. Pre-Processing
3. Transpilation
4. Module Bundling and Linking
5. Asset Optimization
6. Testing
7. Packaging
Back-End (Java)
1. Dependency Resolution
2. Pre-Compilation
3. Compilation
4. Testing
5. Packaging

Front-End
^

1. Linting and Static Analysis
^

  • Tools like ESLint help to catch syntax errors, enforce coding standards, and identify potential bugs.
  • Static Type Checking: If TypeScript is used, type-checking catches type-related errors.

2. Pre-Processing
^

  • Component Scaffolding: Front-End frameworks like React generate boilerplate code for components. This allows writing at a higher level of code that provides consistent underlying functionality with best practices.
  • CSS Preprocessing: Tools like Sass or LESS generate CSS code at Build Time. They provide features to enable greater modularization of code.
  • HTML Templating: Tools like Handlebars can be used to generate HTML code dynamically based on templates. This is especially useful in projects where source code could otherwise experience combinatorial explosion from all the permutations.

3. Transpilation
^

  • Transpilation (JavaScript): Typescript is transpiled into JavaScript. JavaScript code written in ES6+ is transpiled into ES5, which makes it compatible with older browsers.
  • Polyfilling: Includes features that are not supported by older browsers.

4. Module Bundling and Linking
^

  • Bundling and Minification: Front-End assets like JavaScript, CSS, and HTML are often bundled into fewer files. These files are minified (e.g. variable names reduced, whitespace and comments removed) to reduce their size. Webpack is one of the most popular bundling tools to automate this. Other performance enhancements include lazy loading.
  • Tree Shaking: Related to the bundling process, tree shaking is a form of dead-code elimination to reduce the final release artifact size.

5. Asset Optimization
^

  • Image and Asset Optimization: Images and other assets (e.g. fonts, icons) can be optimized to reduce file sizes and enhance page load times and overall performance.
  • Asset Copying: Copies assets to the distribution folder.

6. Testing
^

  • Unit Testing: Running pre-merge tests (e.g. unit tests).

7. Packaging
^

  • Move remaining necessary files into the distribution folder.

Back-End (Java)
^

1. Dependency Resolution
^

  • Before compilation, build tools like Maven or Gradle resolve and download dependencies required by the application from repositories.

2. Pre-Compilation
^

  • Resource Processing: Static assets like properties files, XML configurations are copied into the build directory.
  • Code Generation Tools: Tools like Jinja2 can be used to generate Java code dynamically based on templates. This is especially useful in projects where source code could otherwise experience combinatorial explosion from all the permutations.
  • Serialization and Remote Procedure Call (RPC) Frameworks: Tools like Protocol Buffers use a Domain-Specific Language to define message types that are very efficiently serialized into byte-level schema during transit between microservices. Furthermore, their .proto files can generate client and server-side source code that can be imported into your project in a multitude of languages to create remote procedural calls (RPC).

3. Compilation
^

  • Source Code Parsing: Raw source code is parsed into an Abstract Syntax Tree for analysis.
  • Annotation Processors: Java supports annotations to classes, methods, and other constructs that produce additional source code or configuration files before the actual compilation begins. Examples of tools and frameworks that provide these features are: Java’s built-in libraries in java.lang and java.lang.annotation. Spring and Lombok are popular frameworks that offer annotations.
  • Compiling Source Code to Bytecode: Java source code is translated into bytecode (.class), which can be executed by the JVM.

4. Testing
^

  • Automated pre-merge tests (unit tests).

5. Packaging
^

  • The compiled bytecode and all processed resources are packaged into a JAR (Java Archive) for libraries and applications, and WAR (Web Application Archive) for some web applications.

Updated: 2024-02-03


Author

Sam Malayek

Sam Malayek works in Vancouver, using this space to fill in a few gaps. Opinions are his own.