CodeVetter · Repo Unpack · Behavior traces
parcel-bundler/parcel
The source walks establish production startup, asset-to-output processing, watch rebuilds, lazy HTTP requests, and persistence restoration. Each trace names the actual execution order and relevant conditional branches. Builds and serving communicate through reporter events rather than a separate application backend. These are source-derived traces; no runtime behavior was exercised.
- Production startup follows bin.js → cli.runCommand() → run() → normalizeOptions() → new Parcel() → Parcel.run() → _init(); initialization awaits sourcemaps/Rust, resolves options, loads configuration, initializes workers/cache/reporters, then restores RequestTracker.
- The build enters _build() → createParcelBuildRequest() → createBundleGraphRequest() → createAssetGraphRequest(); AssetGraphRequest.build() traverses queued requests, then runAssetRequest() dispatches AssetRequest → worker.runTransform() → Transformation.run().
- For a fresh bundle graph, BundlerRunner.bundle() calls loadConfigs(), gets the bundler, converts AssetGraph, calls bundler.bundle(), conditionally calls bundler.optimize() in production, then names bundles and applies runtimes; an eligible previous graph instead receives changed asset updates.
- Output follows ParcelBuildRequest.run() → WriteBundlesRequest → PackageRequest → PackagerRunner.getBundleResult() → package() → optimize() → WriteBundleRequest; bundles without hash references can begin writing before complex name hashes are assigned.
- Watch startup calls watch() → _getWatcherSubscription() → report(watchStart) → queued _startNextBuild(); later filesystem events call respondToFSEvents(), abort an active build when invalidated, and enqueue one replacement build when none is waiting.
- An HTTP bundle request follows Server.respond() → serveBundle() → event.requestBundle(); a placeholder adds entry asset IDs and queues a rebuild, while a non-placeholder returns immediately, after which serveDist() serves outputFS content.
- Persistence follows Parcel._end() → RequestTracker.writeToCache() → serialized results/graph plus inputFS.writeSnapshot(); the next _init() calls RequestTracker.init() → loadRequestGraph(), with a fresh graph used when caching is disabled, missing, or restoration throws.
- _build() reports buildSuccess before running validation and checking reporter errors; subsequent exceptions become a reported buildFailure, except BuildAbortError is rethrown. Parcel.run() then shuts down before throwing BuildError for a failure result.