Skip to content

Prep for only parsing es modules once in jsc - #73

Merged
Jarred-Sumner merged 3 commits into
mainfrom
pfg/only-parse-once
Dec 14, 2024
Merged

Jarred-Sumner merged 3 commits into
mainfrom
pfg/only-parse-once

Conversation

@pfgithub

Copy link
Copy Markdown

Adds an extern function Bun__analyzeTranspiledModule that is used get the ModuleRecord for a module if it is of type BunTranspiledModule

@Jarred-Sumner
Jarred-Sumner merged commit 35cba43 into main Dec 14, 2024
robobun added a commit that referenced this pull request Aug 10, 2026
…gger/cache/completion switches

#73 added SourceProviderSourceType::BunTranspiledModule so Bun
can attach a pre-computed module record to a SourceProvider and skip JSC's
analyze-phase re-parse. Three sites that branch on the provider's sourceType()
still match only ::Module, so a BunTranspiledModule provider falls through:

- debugger/DebuggerParseData.cpp gatherDebuggerParseDataForSource: falls to the
  default:false arm, Debugger::resolveBreakpoint gets empty pause positions,
  and Debugger.setBreakpoint replies "Could not resolve breakpoint" for every
  line in the script.
- runtime/CachedTypes.cpp CachedSourceProvider encode/decode: would
  RELEASE_ASSERT_NOT_REACHED() if JSC bytecode caching encoded one of these
  providers.
- runtime/Completion.cpp getSourceType: returns ScriptFetchParameters::Type::None
  instead of JavaScript.

(InspectorDebuggerAgent::didParseSource, the fourth site in the original
version of this change, is covered since the upstream merge in #383 by
scriptTypeForScript.)

Currently reachable in Bun via `bun test --isolate` and `--compile` standalone
executables; oven-sh/bun#35605 routes every runtime ESM provider through this
type and is blocked on this.

Each site adds a BUN_JSC_ADDITIONS-gated case that falls through to the Module
arm.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants