Skip to content

Navigation Menu

Sign in
Sign up

fix(repack): wrap babel-loader fallback value in an array - #1456

Open
ilteoood wants to merge 1 commit into
callstack:main from
ilteoood:fix/rsdoctor-resolve-loader-fallback
Open

fix(repack): wrap babel-loader fallback value in an array #1456
ilteoood wants to merge 1 commit into
callstack:main from
ilteoood:fix/rsdoctor-resolve-loader-fallback

Conversation

@ilteoood

@ilteoood ilteoood commented Sep 8, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Summary

BabelPlugin previously set resolveLoader.fallback['babel-loader'] to a bare string path (e.g. /path/to/babel-loader). Rspack's resolver and downstream tooling that consumes the resolved loader config (notably RSDoctor) expects the value to be an array, so the bare string caused:

error Given napi value is not an array on NapiResolveOptions.fallback

The fix wraps the value in a single-element array. The record shape is unchanged, which still satisfies:

  • Rspack's ResolveAlias = { [x: string]: string | false | (string | false)[] } | false
  • Webpack's resolve loader fallback (record { [name]: string | false | string[] })

Changes

  • packages/repack/src/plugins/BabelPlugin.ts — wrap require.resolve('babel-loader') in [ ] so the value is string[] rather than string.
  • packages/repack/src/plugins/__tests__/BabelPlugin.test.ts — new tests covering the empty and pre-populated record paths.
  • .changeset/babel-loader-resolve-loader-fallback-array.md — patch changeset for @callstack/repack.

Why

Rspack's resolver pipeline and RSDoctor's loader intercept expect the value of each resolveLoader.fallback entry to be an array. A bare string passes the TS types (which allow string | string[]) but trips Rspack's NAPI binding when downstream consumers try to use it.

Test plan

  • pnpm typecheck passes for all 11 packages
  • pnpm lint:ci passes
  • pnpm test in packages/repack passes 314 tests (added 2 new tests for BabelPlugin)
  • Manual: verify RSDoctor works in a fresh Rspack project

Closes #1455

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown

@ilteoood is attempting to deploy a commit to the Callstack Team on Vercel.

A member of the Team first needs to authorize it.

changeset-bot Bot commented Sep 8, 2026
edited
Loading

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 02ecf58

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@callstack/repack Patch
@callstack/repack-plugin-expo-modules Patch
@callstack/repack-plugin-nativewind Patch
@callstack/repack-plugin-reanimated Patch
@callstack/repack-dev-server Patch
@callstack/repack-init Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Rspack's resolver and downstream tools that consume the resolved loader
config (notably `RSDoctor`) expect `resolveLoader.fallback[name]` to be
an array; a bare string triggered
`Given napi value is not an array on NapiResolveOptions.fallback`. The
record form is unchanged — only the value for `babel-loader` is now
wrapped in a single-element array. This matches Rspack's `ResolveAlias`
shape (`{ [x: string]: string | false | (string | false)[] }`) and
Webpack's resolve loader fallback shape.
Closes callstack#1455 
ilteoood force-pushed the fix/rsdoctor-resolve-loader-fallback branch from d00285b to 02ecf58 Compare September 8, 2026 15:33
@ilteoood ilteoood changed the title (削除) fix(repack): use array form for resolveLoader.fallback (削除ここまで) (追記) fix(repack): wrap babel-loader fallback value in an array (追記ここまで) Sep 8, 2026

dannyhw commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

@ilteoood is it due to some change is rspack or it was already incorrect before?

ilteoood commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

@ilteoood is it due to some change is rspack or it was already incorrect before?

I think some changes have been made on rspack, because the first time I configured it it was working fine.

ilteoood commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

FYI I've also opened this

dannyhw commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Seems like on rsdoctor they merged a fix referencing your issue do you think it will be resolved by that?

ilteoood commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Not 100%: when the napi bridge is invoked directly it will still throw an error.
I know for sure that the fix we have here always works: it's the same one I've applied in my local patches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Regression - unable to use RSDoctor

2 participants

AltStyle によって変換されたページ (->オリジナル) /