Repository navigation
Description
Summary
A React Native library whose manifest doesn't declare react-native (in dependencies or peerDependencies) isn't detected by the native engine's ecosystem auto-inline, and neither is anything in its dependency closure. Projects have to keep transform: [...] lists by hand for it.
Status
- Done in fix(native): compile JSX in a package's .js file that Vite serves uncompiled #767 (0.15.1): JSX in such a package's
.jsfile no longer fails Vite's import analysis. A file Vite's parser rejects is compiled as JSX at load and stays in Vite; files that parse are untouched. - Left for 0.16: the two parts below.
react-native-calendars@1.1314.0still needsreactNative({ transform: ['react-native-calendars'] }). Without it, the run now stops at an error that names the package and that fix.
Remaining 1: detect undeclared React Native libraries
dependsOnReactNative (native/ecosystem.ts) is the only signal for a declared package, and the closure walk starts only from detected packages.
Candidate: a runtime-imports signal. Detect a declared package whose runtime graph imports react-native, reusing runtimeImports(), which today serves the closure walk's peer edge.
- Across three real apps it finds about 10 undeclared React Native libraries per app (moti, @react-native-community/slider, react-native-animatable, react-native-keychain, react-native-picker-select …).
- It costs 258–671 ms per config evaluation (1.3k–2.5k files walked), so it needs a cache keyed by package directory and version.
- Risk: each package it catches moves from Vite to Node ownership. That needs a corpus comparison against main before it ships.
A cheaper but narrower alternative: a source-entry signal (the entry the plugin resolves is .ts/.tsx/.jsx). It costs 12–24 ms and catches react-native-calendars, but it also moves packages that work today, such as Expo modules with a TypeScript entry.
Remaining 2: Metro-only source served by Vite
Past the JSX, react-native-calendars' src/interface.js uses require inside ES module source. Metro and babel-jest accept that mix; Vite's module runner and Node don't:
ReferenceError: require is not defined in ES module scope, you can use import instead
node_modules/react-native-calendars/src/interface.js:1:15
Compiling the package as a detected one (Babel, CommonJS output) handles it, which is what transform: [...] does today. So part 2 is solved by part 1 for any package detection catches. A package left in Vite would need a load-time CommonJS compile of mixed source, which is not proposed.
Evidence (registry manifests)
react-native-calendars@1.1314.0: noreact-nativedependency or peer, and noreact-nativefield or export condition. Itsmainissrc/index.ts(TypeScript source), and it publishes JSX in.jsfiles (src/calendar/index.js). Dependencies:recyclerlistview@^4.0.0,react-native-swipe-gestures@^1.0.5,xdate,lodash,prop-types,memoize-one,hoist-non-react-statics.recyclerlistview@4.2.3: peerreact-native, so it is detected when declared directly. It ships compileddist/, so missing it through the closure doesn't break this package.react-native-swipe-gestures@1.0.5: noreact-nativedeclaration; plainindex.js.
Reproduced on main (6dbaa56) with React Native 0.86.3, React 19.2.3, @testing-library/react-native 13.3.3 and Vitest 5.0.5. Listing only react-native-calendars in transform makes <Calendar /> render.
Activity
danfry1 commentedon Nov 11, 2026
Reproduced on main (6dbaa56, packed tarball), engine
nativechosen by default, with React Native 0.86.3, React 19.2.3,@testing-library/react-native13.3.3, Vitest 5.0.5 andreact-native-calendars1.1314.0 (withrecyclerlistview4.2.3 andreact-native-swipe-gestures1.0.5).A test that renders
<Calendar current="2026-11-11" />with a zero-configreactNative()fails before any test runs:The package publishes JSX in
.jsfiles undersrc/(mainissrc/index.ts), and since it isn't detected, it stays in Vite's graph uncompiled.transform: ['react-native-calendars']alone makes it render and pass.recyclerlistviewandreact-native-swipe-gesturesmakes no difference here:recyclerlistviewships compileddist/.So for this package the gap is the direct detection. Missing the closure would matter only for a dependency that also ships untranspiled source.
danfry1 commentedon Nov 11, 2026
Part of this lands in #767 (0.15.1): a package's
.jsfile with JSX that Vite can't parse is now compiled at load under the native engine, so that parse error no longer stops the run. Onreact-native-calendars1.1314.0 the run then reachessrc/interface.js, which usesrequireinside ES module source. That needs the full compile a detected package gets, and the error names the package andreactNative({ transform: ['react-native-calendars'] }). Zero-config support for such packages stays open here for 0.16.