utoo

repository·next·Indexed 25 days ago

https://github.com/utooland/utoo

A high-performance, unified frontend toolchain featuring a Rust-based package manager, a Turbopack-powered bundler, and a flexible command system. It is designed for universal execution across Local, CI, and Browser (via WASM) environments and maintains compatibility with existing Webpack configurations.

Tokens
63.8K
Snippets
117
Records
407
Agent score
81%

What's inside utoo

  1. Overview of @utoo/web features

    next

    The @utoo/web package provides a high-performance bundling environment directly in the browser using WebAssembly and Turbopack. Key capabilities include:

    • Real File System: Utilizes Origin Private File System (OPFS) to simulate a Node.js-like file system.
    • Browser Dependency Resolution: Resolves dependencies from package.json without requiring a lock file. Supports npm, npmmirror, and private registries.
    • Browser-based Bundling: Executes the Utoo bundler within the browser environment.
    • Project Lifecycle Management: Provides a dispose() method to cancel active installs or builds and safely switch projects.
    • Hot Module Replacement (HMR): Supports full HMR via MessagePort communication with preview iframes.
    • Webpack Compatibility: Supports a subset of Webpack configurations and standard loaders like css-loader and style-loader.
    • CSS Processing: Built-in support for PostCSS and Tailwind CSS.
  2. What is Pack Schema

    next
    Pack Schema is a JSON Schema generator designed for utoopack.json configuration files. It provides type hints, auto-completion, and validation support by generating accurate JSON Schemas based on the Rust type system used in pack-core. It ensures that configuration files stay in sync with the core toolchain through a mirrored type architecture.
  3. Overview of @utoo/pack-shared features

    next

    The @utoo/pack-shared package provides common utilities and types used throughout the Utoo ecosystem. Key features include:

    • Issue Reporting: Standardized utilities for reporting issues and errors.
    • Magic Identifiers: Utilities for managing and handling internal identifiers.
    • Styled Strings: Helpers for styling strings in the terminal.
  4. Overview of Utoo core components

    next

    Utoo is composed of several specialized packages:

    • utoo (alias ut): The core Rust package manager designed for speed and parallelism.
    • @utoo/pack: The next-generation bundler powered by Turbopack, supporting TS/JSX, Less/Sass, and HMR.
    • @utoo/pack-cli: A lightweight CLI wrapper for the bundler, providing the up command shortcut.
    • @utoo/web: A WASM-based version of the toolchain that allows bundling to run directly in a web browser.
  5. Current Limitations and Skipped Test Categories in Arborist E2E

    next

    The Arborist E2E suite tracks features that the utoo Package Manager (PM) does not yet fully support. If you are debugging or extending the PM, be aware of these current limitations:

    • file: protocol dependencies: Some complex scenarios like dependency cycles (link-dep-cycle), lifecycle scripts in file dependencies (link-dep-lifecycle-scripts), and self-referencing dependencies (external-link-dep) are currently skipped.
    • file: resolver semantics: utoo cannot currently recover origin directories for transitive file: dependencies inside registry-published packages, and certain spec-parser behaviors (like GitHub shorthand parsing) are limited.
    • Optional dependency failure tolerance: Unlike standard behavior where missing transitive optional dependencies are silently skipped, utoo currently hard-fails the entire installation if an optional dependency's transitive dependency is unreachable.
    • Peer dependency validation: utoo does not currently validate if peer-dependency constraints are mutually satisfiable or emit ERESOLVE errors for conflicts.
    • Platform mismatch rejection: utoo does not check os, cpu, or libc fields against the current platform for non-optional dependencies.
    • Workspace validation: utoo does not detect duplicate workspace names (which should trigger EDUPLICATEWORKSPACE).
    • Dependency cycles: Deep recursive cycles (e.g., A→B→A→B) can cause a recursive fetch loop leading to OOM/SIGTERM.
    • Mock-registry-only packages: Packages that exist only in npm's mock registry (and not the real npm registry) are not supported.
  6. How Pack Schema handles type mapping

    next

    Pack Schema uses a mirrored type architecture to ensure compatibility with JSON Schema while maintaining synchronization with pack-core. It re-exports core types but maps internal Rust types to standard, JSON-compatible types:

    pack-core typepack-schema typeDescription
    RcStrStringJSON Schema compatible string type
    FxIndexMap<K,V>HashMap<K,V>Standard HashMap replacement
    FxHashSet<T>Vec<T>Array representation for sets
    turbo-tasks typesCorresponding standard typesRuntime-specific annotations removed
  7. Understand peer dependency duplication behavior

    next

    This package models a specific dependency resolution scenario where a dependency must have its own sub-dependencies duplicated to satisfy a peer dependency requirement from another of its own dependencies. This behavior mimics gatsby@2.24.53.

    The Conflict Scenario

    1. Initially, a package like @pmmmwh/react-refresh-webpack-plugin@0.4.1 is installed alongside gatsby and react-refresh@0.7.2 at the root.
    2. A peer dependency requirement (e.g., @pmmmwh/react-refresh-webpack-plugin@0.4.1 requiring react-refresh@0.7.2) is evaluated.
    3. If the required version cannot be placed at the root without colliding with an existing version, the package manager may attempt to move the existing version under the parent (e.g., under gatsby) or duplicate it.

    Resolution with --force

    When a collision occurs (e.g., override -> (a@2, v@1) where v@1 requires a@1), the installation will fail by default. Using the --force flag allows the package manager to override the peer dependency with the direct root dependency, resulting in a structure where the root maintains its version while the sub-dependency uses its own.

  8. Understand the peer dependency conflict scenario in 'override'

    next

    The override package is a test case designed to model specific dependency resolution behaviors, such as those seen in gatsby@2.24.53. It simulates a scenario where a dependency must have its own version of a package dupe to accommodate a peer dependency requirement from another of its own dependencies.

    The Conflict Model

    In the override model:

    • override depends on a@2 and v@1.
    • v@1 has a peer dependency on a@1.

    Initially, this fails to install by default because the a dependency collides (the root wants a@2 but the peer requirement wants a@1).

    Resolution via --force

    Using the --force flag allows the installer to override the peer dependency with the direct root dependency. This results in a structure where the root maintains its version, even if it is invalid for the peer-dependent module:

    override
    +-- v@1
    +-- a@2 (valid for root, invalid for v)
    +-- b@2, c@2, ...

    Compliant Resolution

    When override is installed as a dependency of another package (e.g., push-dep), a compliant resolution is achieved where every module receives the specific version of the dependency it declares:

    push-dep
    +-- v@1
    +-- a@1
    +-- b@1, c@1, ...
    +-- override
        +-- a@2
        +-- b@2, c@2, ...
  9. Maintain compatibility with PM CLI JSON schema

    next

    To ensure robust integration with utoo --json:

    1. Ignore unknown fields: Consumers must ignore any object fields they do not recognize.
    2. Schema Versioning: Within schemaVersion: 1, adding optional fields is considered a compatible change. Removing fields, renaming fields, changing types, or changing the semantic meaning of fields requires a new major schema version.
    3. Deterministic Ordering: Collections and maps have deterministic ordering. Execution results preserve topological order, and same-layer workspaces are ordered by their canonical name.
  10. Use runtime assertions with assert.js

    next
    To perform runtime validation on generated output, add an assert.js file to a specific snapshot case directory. After the test runner confirms that the generated output matches its recorded snapshot, it will automatically execute the assert.js file using Node.js within that same case directory.