Repository navigation
fix(core): keep the loader initialization APIs for embedders - #895
Merged
Brooooooklyn merged 1 commit intoOct 30, 2026
Merged
Conversation
An embedder that links oxc-node with `default-features = false` cannot call `initialize_loader_js` or `freeze_tsconfig_js`, because `#[cfg(feature = "napi")]` removes them. The plain `initialize_loader` does not keep the diagnostic source, and the plain `freeze_tsconfig` does not read the calling JavaScript thread's environment. The helpers that do both are private, so an embedder cannot rebuild the functions. Use `cfg_attr` for the two `#[napi]` registrations, as the other exports do. The functions compile either way, and only the registration depends on the feature. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brooooooklyn
approved these changes
Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
default-features = false,#[cfg(feature = "napi")]removesinitialize_loader_jsandfreeze_tsconfig_js. An embedder then has only the plain functions:initialize_loaderdoes not keep the diagnostic source (setTsconfigPath(),TS_NODE_PROJECT, orOXC_TSCONFIG_PATH).freeze_tsconfigreads the native process environment, not theprocess.envof the calling JavaScript thread.The helpers that do both,
set_tsconfig_overrideandLoaderEnvironmentGuard, are private. An embedder therefore cannot write forwarders that matchinitializeLoaderandfreezeTsconfig.This PR uses
cfg_attrfor the two#[napi]registrations, as the other exports do. The functions now compile with or without the feature, and only their registration depends on it. The embedder list inCargo.tomlnow names the_jsfunctions.🤖 Generated with Claude Code