Skip to content

[pull] canary from vercel:canary#1084

Merged
pull[bot] merged 4 commits into
code:canaryfrom
vercel:canary
May 29, 2026
Merged

[pull] canary from vercel:canary#1084
pull[bot] merged 4 commits into
code:canaryfrom
vercel:canary

Conversation

@pull

@pull pull Bot commented May 29, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

sokra and others added 4 commits May 29, 2026 07:34
…#94179)

### What?

`import.meta.url` evaluated in a Turbopack-compiled module on Windows
produced
an invalid file URI: the path portion contained backslashes (`\`) and
was not
URL-encoded, e.g.

```
file://C:\Users\me\project\apps\web\app\page.tsx
```

This affects any code that hands the value to `URL`, `fileURLToPath`,
source
maps, dev tools, or anything else that expects a [valid file
URI](https://en.wikipedia.org/wiki/File_URI_scheme).

This PR makes `import.meta.url` return a correct, percent-encoded file
URI on
all platforms, e.g. `file:///C:/Users/me/project/apps/web/app/page.tsx`.

### Why?

The existing codegen in `references/esm/meta.rs` emitted

```js
`file://${__turbopack_context__.P("<rel/path>")}`
```

where `__turbopack_context__.P` is the runtime helper
`resolveAbsolutePath`.
On the Node-side runtime (`shared-node/node-externals-utils.ts`) that
helper
returns `path.join(ABSOLUTE_ROOT, modulePath)`, which is OS-native — so
on
Windows it returns a backslash-separated path with no percent-encoding.
The
result was then concatenated into a `file://...` template literal,
producing
an invalid URI.

The initial hint that `turbopack-core/src/source_map/utils.rs` was the
culprit
turned out to be a false lead: that code path uses
`FileSystemPath::try_join`, which already normalizes `\` to `/` on
Windows.
The bug is in the codegen + runtime helper for `import.meta.url`, not in
source-map handling.

### How?

- Introduce a new runtime function `__turbopack_resolve_file_url__`
(shortcut `F`) whose contract is to return a complete `file://` URI for
a
  given relative module path.
  - Node implementation (`shared-node/node-externals-utils.ts`): uses
`url.pathToFileURL(resolveAbsolutePath(modulePath)).href`.
`pathToFileURL`
    handles drive letters (`file:///C:/...`), normalizes slashes, and
    percent-encodes path segments.
- Browser implementation (`browser/runtime/base/runtime-base.ts`):
returns
    `` `file:///ROOT/${modulePath ?? ''}` `` — the browser runtime
intentionally does not expose the real filesystem path, so it returns
the
same stable placeholder as before, just with a valid `file:///` prefix
    instead of having callers concatenate one.
- Change the `import.meta.url` codegen in `references/esm/meta.rs` to
call
  `__turbopack_resolve_file_url__($formatted)` directly instead of
concatenating a `file://` prefix to the absolute path. The pre-existing
  `encode_path` is kept only to keep the embedded JS string literal safe
  (the runtime helper is responsible for the URI-level encoding).
- Update `TurbopackBaseContext` and add a `ResolveFileUrl` type alias in
  `runtime-types.d.ts` so the new shortcut is typed.
- Register the new shortcut in `TURBOPACK_RUNTIME_FUNCTION_SHORTCUTS` so
user
code can also reference `__turbopack_resolve_file_url__` (mirroring the
existing `__turbopack_resolve_absolute_path__`). `P` is left in place
and
  unchanged because it's still used elsewhere.
- Regenerate the affected Turbopack snapshot fixtures (`import-meta/*`,
`comptime/typeof`, `runtime/default_*_runtime`, `workers/*`,
`debug-ids/*`,
  etc.). The functional change in the generated code is uniform:
  `` `file://${__turbopack_context__.P(<rel>)}` `` →
  `__turbopack_context__.F(<rel>)`.
- Drop the `// TODO: These file URIs are wrong on turbopack+windows`
comment
  and the `.replaceAll('\\', '/')` workarounds from

`test/e2e/app-dir/non-root-project-monorepo/non-root-project-monorepo.test.ts`,
so the assertion now verifies that the URI is correctly slashed and
encoded
  on all platforms.

### Verification

- `cargo clippy --workspace --all-targets` — clean
- `cargo fmt --check` — clean
- `cargo test -p turbopack-tests --test snapshot` — 87/87 pass
- `cargo test -p turbopack-tests --test execution` — 219/219 pass (1
ignored)
- `pnpm test-dev-turbo
test/e2e/app-dir/non-root-project-monorepo/non-root-project-monorepo.test.ts`
— 9/9 pass
- `pnpm test-start-turbo
test/e2e/app-dir/non-root-project-monorepo/non-root-project-monorepo.test.ts`
— 6/6 pass
- `pnpm test-dev-webpack
test/e2e/app-dir/non-root-project-monorepo/non-root-project-monorepo.test.ts`
— 9/9 pass (verifying webpack path still works)

Windows itself can't be exercised in the sandbox, but the new code path
no
longer depends on `path.sep` or any OS-native string manipulation for
the
URI: `url.pathToFileURL` is the canonical Node API for producing a file
URI
from any OS-native path, and the test assertion has been tightened so
that a
regression on Windows would fail in CI rather than be papered over.

<!-- NEXT_JS_LLM_PR -->

---------

Co-authored-by: v-work-app[bot] <262237222+v-work-app[bot]@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Tobias Koppers <sokra@users.noreply.github.com>
…ion::span (#94057)

### What?

Track the cause of task invalidation in turbo-tasks and surface it to
the tracing span when a task executes, so traces can show *why* a task
was re-run.

A new `task_dirty_cause` Cargo feature gates the storage and parameter
plumbing for this information. The existing `trace_task_dirty` feature
now depends on it.

### Why?

When investigating Turbopack performance and incremental-recompute
behavior, traces show which tasks ran but not what invalidated them.
Recording the `TaskDirtyCause` on the `turbo_tasks::function` span makes
it possible to attribute task re-runs to their triggering change (cell
update, output change, collectible change, etc.) directly from a trace.

### How?

- Replace `Dirtyness::Dirty(TaskPriority)` with a struct variant `Dirty
{ parent_priority, cause: TaskDirtyCause }`. The `cause` field is only
present when the `task_dirty_cause` feature is enabled.
- Move `TaskDirtyCause` from `turbo-tasks-backend` into `turbo-tasks` so
the span signature in `turbo-tasks` can reference it.
- Replace `OutputChange { task_description }` with `OutputChange {
function: FunctionId }`, and add a new `ResolveOutputChange { function:
FunctionId }` variant used when the task's output is
`OutputValue::Output(_)`. This avoids constructing a `String` for the
cause at invalidation time.
- `NativeFunction::span` now accepts a feature-gated `cause:
Option<&TaskDirtyCause>` argument and records it as a `cause` field on
the `turbo_tasks::function` span. The cause is read from the dirty state
in `try_start_task_execution` before execution starts.
- Split the `trace_task_dirty` feature: the new `task_dirty_cause`
feature owns the storage/parameter plumbing, and `trace_task_dirty` now
depends on it. This lets consumers opt into the storage cost without the
full tracing overhead, and keeps the default build unaffected.

Closes PACK-
<!-- NEXT_JS_LLM_PR -->
No need for a separate `pub async fn resolve()`, just call
`ModuleReference.resolve_reference` directly
…js Docker official guide. (#94185)

## What?

Updates the Docker section in the deploying guide.

- Rewrites the Docker intro sentence to be more concise and adds a link
to Docker's official [React.js
guide](https://docs.docker.com/guides/reactjs) alongside the existing
[Next.js guide](https://docs.docker.com/guides/nextjs).

## Why?
Add reference to new Next.js Docker guide in the deploying docs.

## How?

Documentation-only change. No code changes.

CC: @icyJoseph
@pull pull Bot locked and limited conversation to collaborators May 29, 2026
@pull pull Bot added the ⤵️ pull label May 29, 2026
@pull pull Bot merged commit 57ddbf8 into code:canary May 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants