Yinuo Snowball Technical Blog

website·Indexed 31 days ago

https://blog.yinuosnowball.top/

A comprehensive collection of technical notes and guides covering frontend engineering. Key topics include deep dives into Webpack (basic, advanced, and custom loader/plugin implementation), TypeScript fundamentals, design patterns (creational, structural, and behavioral), sorting algorithms, HTTP status codes, browser caching, and mobile development concepts. It also provides practical setup guides for React and Vue CLIs, as well as tool configurations for Prettier and VS Code.

Tokens
71.6K
Snippets
315
Records
389
Agent score
55%

What's inside Yinuo Snowball Blog

  1. Overview of Gitflow Branching Model

    Gitflow is a strict branching model designed for managing large-scale projects and releases. It assigns specific roles to different branches to isolate feature development, release preparation, and emergency maintenance, ensuring that the main production code remains stable while development continues in parallel.
  2. Overview of EditorConfig

    EditorConfig is a system for maintaining consistent coding styles (such as indentation, line endings, and character sets) across various editors and IDEs. It consists of a specific file format (.editorconfig) and editor plugins that read these files to override the editor's local settings, ensuring all team members use the same formatting regardless of their tool choice.
  3. Overview of Webpack functionality

    Webpack is a static asset bundling tool that takes one or more entry files and compiles the project's dependencies into one or more output files called 'bundles' that can run in a browser. By default, Webpack's native capabilities are limited to processing JavaScript ES Modules: in development mode, it compiles ES Modules; in production mode, it compiles ES Modules and minifies the resulting JavaScript code. It cannot process non-JS assets (like CSS) without additional configuration.
  4. Understand the three core characteristics of Object-Oriented Programming

    Object-Oriented Programming (OOP) is built upon three primary characteristics:

    1. Inheritance: Allowing a class to inherit properties and behaviors from another class.
    2. Encapsulation: Bundling data and the methods that operate on that data into a single unit and restricting access to some of the object's components.
    3. Polymorphism: The ability of different classes to be treated as instances of the same class through a common interface.
  5. Understand Webpack Plugin Architecture

    Webpack plugins extend the build process by hooking into specific events triggered during compilation. This event-driven system is powered by Tapable, a core library that defines the hook types. Plugins register tasks to these hooks, allowing them to modify resources or change the build behavior at specific stages of the production line.
  6. Understand JavaScript Decorators

    Decorators are functions used to enhance the functionality of JavaScript classes. They are applied using the @functionName syntax and can be used to decorate four specific types of targets: classes, class properties, class methods, and property accessors.
  7. Algorithm applications in Vue and React

    Modern frontend frameworks rely heavily on specific algorithms and data structures for performance and architecture:

    • Virtual DOM Diffing: Both Vue and React use tree-diffing algorithms. Vue 3 specifically utilizes the Longest Increasing Subsequence (LIS) for its diffing process.
    • Fiber Architecture: React 16 transforms the component tree into a linked list to enable incremental rendering.
    • JSX Parsing: Uses a stack data structure.
    • Caching: Module caching and Vue's KeepAlive component utilize linked lists and LRU (Least Recently Used) caches respectively.
  8. Understand the role of build tools in modern web development

    Build tools are necessary to transform modern development code into a format that browsers can execute. They perform the following critical tasks:

    1. Compilation: Converting frameworks (React, Vue), ES6 module syntax, and CSS pre-processors (Less, Sass) into standard JavaScript and CSS.
    2. Optimization: Compressing code to reduce file size and improving overall runtime performance.
    3. Compatibility: Applying polyfills and transformations to ensure the code runs across different browser versions.
  9. Architecture for separating static and dynamic resources with Ali-OSS and CDN

    To optimize performance and reduce server load, separate resources into dynamic and static categories:

    1. Dynamic Resources (e.g., index.html): Deployed to ECS servers. Use HTTP conditional caching (Cache-Control: private no-cache) to ensure users always retrieve the latest version.
    2. Static Resources: Stored in Alibaba Cloud OSS and distributed via CDN to edge nodes. This reduces server traffic and improves access speed.

    CDN Configuration Recommendations:

    • Static Assets (jpg, jpeg, png, svg, mp3, txt, json, webp): Set expiration to 365 days with a high weight (99). Add a custom HTTP response header Cache-Control: max-age=31536000.
    • HTML Files (html, htm): Set expiration to 0 seconds to prevent caching of the entry point.
  10. Understand TypeScript basic and special types

    TypeScript provides several fundamental and special types:

    • number, string, boolean: Standard primitive types.
    • any: Can be assigned any value and assigned to any other type (except never).
    • unknown: A type-safe alternative to any. A value of type unknown cannot be assigned to other types (except any) without a type assertion or type guard.
    • void: Used for functions that do not return a value. It can be assigned undefined.
    • never: Represents values that will never occur (e.g., a function that always throws an error or has an infinite loop). It is a subtype of every type.
    • undefined and null: Specific types for missing or null values.
    let num: number = 123;
    let s: string = '123';
    let b: boolean = false;
    
    // unknown requires type assertion or check
    function div(params: unknown) {
        return (params as number) / 2;
    }
    
    // void for no return value
    function wel(): void {
        console.log(123);
    }
    
    // never for functions that never return
    function fn(msg: string): never {
        while(true) { console.log(msg); }
    }
  11. CI/CD Pipeline for Ali-OSS and ECS Deployment

    When configuring a Jenkins pipeline for this architecture, follow this sequence to ensure zero-downtime resource availability: build the project, upload static assets to OSS, and finally package the HTML for ECS deployment.
    # Example Jenkins steps
    yarn install --registry=https://registry.npm.taobao.org
    yarn build:prod                      # Build production bundle
    yarn oss --config alioss.production.js # Upload static assets to OSS first
    tar -zcvf dist.tar.gz dist            # Package for ECS deployment (index.html)
  12. Understand the Same-Origin Policy and CORS

    A cross-origin HTTP request occurs when a resource is requested from a different domain, protocol, or port than the one where the resource is hosted. Browsers restrict cross-origin HTTP requests made via scripts (XMLHttpRequest and Fetch API) for security reasons unless the server provides specific CORS (Cross-Origin Resource Sharing) headers. Browser restrictions can manifest in two ways: preventing the request from being sent if a preflight check fails, or blocking the response from being read by the script even if the request was successful.