vxrn 2.7.7 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/getBaseViteConfigOnly.mjs +1 -1
- package/dist/config/getBaseViteConfigOnly.mjs.map +1 -1
- package/dist/config/getBaseViteConfigOnly.native.js +1 -1
- package/dist/config/getBaseViteConfigOnly.native.js.map +1 -1
- package/dist/config/getReactNativePlugins.mjs +1 -2
- package/dist/config/getReactNativePlugins.mjs.map +1 -1
- package/dist/config/getReactNativePlugins.native.js +4 -2
- package/dist/config/getReactNativePlugins.native.js.map +1 -1
- package/dist/exports/prebuildWithoutExpo.mjs +26 -97
- package/dist/exports/prebuildWithoutExpo.mjs.map +1 -1
- package/dist/exports/prebuildWithoutExpo.native.js +47 -133
- package/dist/exports/prebuildWithoutExpo.native.js.map +1 -1
- package/dist/plugins/autoDepOptimizePlugin.mjs +5 -2
- package/dist/plugins/autoDepOptimizePlugin.mjs.map +1 -1
- package/dist/plugins/autoDepOptimizePlugin.native.js +10 -7
- package/dist/plugins/autoDepOptimizePlugin.native.js.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.mjs +5 -4
- package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.native.js +5 -4
- package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
- package/dist/utils/createNativeDevEngine.mjs +17 -5
- package/dist/utils/createNativeDevEngine.mjs.map +1 -1
- package/dist/utils/createNativeDevEngine.native.js +17 -5
- package/dist/utils/createNativeDevEngine.native.js.map +1 -1
- package/package.json +27 -20
- package/src/config/getBaseViteConfigOnly.ts +1 -1
- package/src/config/getReactNativePlugins.ts +8 -4
- package/src/exports/prebuildWithoutExpo.test.ts +62 -157
- package/src/exports/prebuildWithoutExpo.ts +31 -125
- package/src/plugins/autoDepOptimizeExternal.test.ts +101 -0
- package/src/plugins/autoDepOptimizePlugin.ts +12 -6
- package/src/plugins/rnCodegenPlugin.ts +1 -2
- package/src/rn-commands/bundle/buildBundle.ts +8 -7
- package/src/utils/createNativeDevEngine.test.ts +228 -5
- package/src/utils/createNativeDevEngine.ts +35 -22
- package/types/config/getReactNativePlugins.d.ts +3 -2
- package/types/config/getReactNativePlugins.d.ts.map +1 -1
- package/types/exports/prebuildWithoutExpo.d.ts.map +1 -1
- package/types/plugins/autoDepOptimizePlugin.d.ts +1 -0
- package/types/plugins/autoDepOptimizePlugin.d.ts.map +1 -1
- package/types/plugins/rnCodegenPlugin.d.ts.map +1 -1
- package/types/rn-commands/bundle/buildBundle.d.ts +1 -1
- package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
- package/types/utils/createNativeDevEngine.d.ts +3 -4
- package/types/utils/createNativeDevEngine.d.ts.map +1 -1
- package/src/plugins/autoDepOptimizePlugin.test.ts +0 -42
|
@@ -303,6 +303,132 @@ it.each(['react-native-nitro-modules', 'react-native-worklets'])(
|
|
|
303
303
|
}
|
|
304
304
|
)
|
|
305
305
|
|
|
306
|
+
async function writeStubReactNative(
|
|
307
|
+
directory: string,
|
|
308
|
+
owner: string,
|
|
309
|
+
files: Record<string, string> = {}
|
|
310
|
+
) {
|
|
311
|
+
await mkdir(join(directory, 'src/private/assets'), { recursive: true })
|
|
312
|
+
await mkdir(join(directory, 'Libraries/Core'), { recursive: true })
|
|
313
|
+
await writeFile(
|
|
314
|
+
join(directory, 'package.json'),
|
|
315
|
+
JSON.stringify({
|
|
316
|
+
name: 'react-native',
|
|
317
|
+
main: './index.js',
|
|
318
|
+
exports: {
|
|
319
|
+
'.': './index.js',
|
|
320
|
+
'./Libraries/*': './Libraries/*.js',
|
|
321
|
+
'./asset-registry': './src/asset-registry.js',
|
|
322
|
+
'./setup-env': { default: './src/setup-env.js' },
|
|
323
|
+
'./package.json': './package.json',
|
|
324
|
+
},
|
|
325
|
+
})
|
|
326
|
+
)
|
|
327
|
+
await writeFile(
|
|
328
|
+
join(directory, 'index.js'),
|
|
329
|
+
`import './src/private/assets/AssetRegistry.js'\nexport const owner = '${owner}'\nexport const AppRegistry = { registerComponent() {} }\n`
|
|
330
|
+
)
|
|
331
|
+
await writeFile(
|
|
332
|
+
join(directory, 'src/private/assets/AssetRegistry.js'),
|
|
333
|
+
`globalThis.__owners = globalThis.__owners || []\nglobalThis.__owners.push('${owner}:AssetRegistry')\nexport const registryOwner = '${owner}'\n`
|
|
334
|
+
)
|
|
335
|
+
await writeFile(
|
|
336
|
+
join(directory, 'src/asset-registry.js'),
|
|
337
|
+
`export * from './private/assets/AssetRegistry.js'\n`
|
|
338
|
+
)
|
|
339
|
+
await writeFile(
|
|
340
|
+
join(directory, 'src/setup-env.js'),
|
|
341
|
+
`import './private/assets/AssetRegistry.js'\nglobalThis.__owners.push('${owner}:SetupEnv')\n`
|
|
342
|
+
)
|
|
343
|
+
await writeFile(
|
|
344
|
+
join(directory, 'Libraries/Core/InitializeCore.js'),
|
|
345
|
+
`globalThis.__owners.push('${owner}:InitializeCore')\nexport const core = '${owner}'\n`
|
|
346
|
+
)
|
|
347
|
+
for (const [name, code] of Object.entries(files)) {
|
|
348
|
+
await mkdir(join(directory, ...name.split('/').slice(0, -1)), { recursive: true })
|
|
349
|
+
await writeFile(join(directory, name), code)
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
async function writeStubExpo(directory: string, launchCode: string) {
|
|
354
|
+
await mkdir(join(directory, 'build/launch'), { recursive: true })
|
|
355
|
+
await writeFile(
|
|
356
|
+
join(directory, 'package.json'),
|
|
357
|
+
JSON.stringify({
|
|
358
|
+
name: 'expo',
|
|
359
|
+
main: './build/Expo.js',
|
|
360
|
+
exports: {
|
|
361
|
+
'.': './build/Expo.js',
|
|
362
|
+
'./launch/registerRootComponent': './build/launch/registerRootComponent.js',
|
|
363
|
+
'./package.json': './package.json',
|
|
364
|
+
},
|
|
365
|
+
})
|
|
366
|
+
)
|
|
367
|
+
await writeFile(join(directory, 'build/Expo.js'), `export const expo = true\n`)
|
|
368
|
+
await writeFile(join(directory, 'build/launch/registerRootComponent.js'), launchCode)
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
it('shares the app react-native singleton for bare and deep imports across nested installs', async () => {
|
|
372
|
+
const root = await mkdtemp(join(tmpdir(), 'vxrn-native-rn-singleton-'))
|
|
373
|
+
try {
|
|
374
|
+
await writeStubReactNative(join(root, 'node_modules/react-native'), 'app')
|
|
375
|
+
const expoDir = join(root, 'node_modules/expo')
|
|
376
|
+
await writeStubExpo(
|
|
377
|
+
expoDir,
|
|
378
|
+
`import { AppRegistry } from 'react-native'\nimport 'react-native/Libraries/Core/InitializeCore'\nimport 'react-native/setup-env'\nexport default function registerRootComponent(c) { return [c, AppRegistry] }\n`
|
|
379
|
+
)
|
|
380
|
+
await writeStubReactNative(join(expoDir, 'node_modules/react-native'), 'nested')
|
|
381
|
+
await writeFile(join(root, 'package.json'), '{}')
|
|
382
|
+
await writeFile(
|
|
383
|
+
join(root, 'entry.js'),
|
|
384
|
+
`import 'react-native'\nimport registerRootComponent from 'expo/launch/registerRootComponent'\nglobalThis.__register = typeof registerRootComponent\n`
|
|
385
|
+
)
|
|
386
|
+
const { code } = await buildNativeBundle({
|
|
387
|
+
root,
|
|
388
|
+
platform: 'ios',
|
|
389
|
+
dev: true,
|
|
390
|
+
entryFile: 'entry.js',
|
|
391
|
+
})
|
|
392
|
+
const context = { console, setTimeout, clearTimeout }
|
|
393
|
+
runInNewContext(code, context)
|
|
394
|
+
expect(Reflect.get(context, '__register')).toBe('function')
|
|
395
|
+
expect([...Reflect.get(context, '__owners')].sort()).toEqual([
|
|
396
|
+
'app:AssetRegistry',
|
|
397
|
+
'app:InitializeCore',
|
|
398
|
+
'app:SetupEnv',
|
|
399
|
+
])
|
|
400
|
+
} finally {
|
|
401
|
+
await rm(root, { recursive: true, force: true })
|
|
402
|
+
}
|
|
403
|
+
})
|
|
404
|
+
|
|
405
|
+
it('refuses the nested react-native copy when the app copy lacks the file', async () => {
|
|
406
|
+
const root = await mkdtemp(join(tmpdir(), 'vxrn-native-rn-skew-'))
|
|
407
|
+
try {
|
|
408
|
+
await writeStubReactNative(join(root, 'node_modules/react-native'), 'app')
|
|
409
|
+
const expoDir = join(root, 'node_modules/expo')
|
|
410
|
+
await writeStubExpo(
|
|
411
|
+
expoDir,
|
|
412
|
+
`import { AppRegistry } from 'react-native'\nimport 'react-native/Libraries/Skew/OnlyFile'\nexport default function registerRootComponent(c) { return [c, AppRegistry] }\n`
|
|
413
|
+
)
|
|
414
|
+
// the nested copy still ships a file the app copy removed. resolving it
|
|
415
|
+
// from the nested copy would initialize the native runtime twice.
|
|
416
|
+
await writeStubReactNative(join(expoDir, 'node_modules/react-native'), 'nested', {
|
|
417
|
+
'Libraries/Skew/OnlyFile.js': `import '../../src/private/assets/AssetRegistry.js'\nexport const skew = 'nested'\n`,
|
|
418
|
+
})
|
|
419
|
+
await writeFile(join(root, 'package.json'), '{}')
|
|
420
|
+
await writeFile(
|
|
421
|
+
join(root, 'entry.js'),
|
|
422
|
+
`import 'react-native'\nimport registerRootComponent from 'expo/launch/registerRootComponent'\nglobalThis.__register = typeof registerRootComponent\n`
|
|
423
|
+
)
|
|
424
|
+
await expect(
|
|
425
|
+
buildNativeBundle({ root, platform: 'ios', dev: true, entryFile: 'entry.js' })
|
|
426
|
+
).rejects.toThrow("missing from the app's react-native")
|
|
427
|
+
} finally {
|
|
428
|
+
await rm(root, { recursive: true, force: true })
|
|
429
|
+
}
|
|
430
|
+
})
|
|
431
|
+
|
|
306
432
|
const nativeTransformProbe = `
|
|
307
433
|
export const transformProbe = () => {
|
|
308
434
|
'worklet'
|
|
@@ -684,11 +810,8 @@ if (import.meta.hot) import.meta.hot.accept(() => {})
|
|
|
684
810
|
fn = runInContext(`(${worklet.__initData.code})`, ui)
|
|
685
811
|
compiled.set(worklet.__workletHash, fn!)
|
|
686
812
|
}
|
|
687
|
-
const closure =
|
|
688
|
-
|
|
689
|
-
name,
|
|
690
|
-
typeof value === 'function' ? reconstruct(value) : value,
|
|
691
|
-
])
|
|
813
|
+
const closure = worklet.__closure.map((value: unknown) =>
|
|
814
|
+
typeof value === 'function' ? reconstruct(value) : value
|
|
692
815
|
)
|
|
693
816
|
return fn!.bind({ __closure: closure })
|
|
694
817
|
}
|
|
@@ -2910,6 +3033,106 @@ globalThis.externalDefaults = [Component, marker, Scoped, Plain, require('extern
|
|
|
2910
3033
|
})
|
|
2911
3034
|
|
|
2912
3035
|
describe('native Flow sources', () => {
|
|
3036
|
+
it.each([true, false])(
|
|
3037
|
+
'preserves codegen, worklets and maps with dev=%s',
|
|
3038
|
+
async (dev) => {
|
|
3039
|
+
const compiler = await import('@vxrn/compiler')
|
|
3040
|
+
const root = await createWorkletsProject(false)
|
|
3041
|
+
const id = join(root, 'ProbeNativeComponent.js')
|
|
3042
|
+
const source = `/* library license */
|
|
3043
|
+
// @flow
|
|
3044
|
+
import type { ViewProps, HostComponent } from 'react-native';
|
|
3045
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
3046
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
3047
|
+
export type Value = number;
|
|
3048
|
+
type Props = $ReadOnly<{...ViewProps, enabled?: boolean}>;
|
|
3049
|
+
interface NativeCommands {
|
|
3050
|
+
reload: (ref: React.ElementRef<HostComponent<Props>>, value: number) => void;
|
|
3051
|
+
}
|
|
3052
|
+
export const Commands = codegenNativeCommands<NativeCommands>({supportedCommands: ['reload']});
|
|
3053
|
+
export function twice(x: Value): Value { 'worklet'; return x * 2; }
|
|
3054
|
+
export const marker = 'flow-map-marker';
|
|
3055
|
+
export default codegenNativeComponent<Props>('FlowProbe');
|
|
3056
|
+
`
|
|
3057
|
+
const rn = join(root, 'node_modules/react-native')
|
|
3058
|
+
await mkdir(join(rn, 'Libraries/NativeComponent'), { recursive: true })
|
|
3059
|
+
await mkdir(join(rn, 'Libraries/ReactNative'), { recursive: true })
|
|
3060
|
+
await mkdir(join(rn, 'Libraries/Utilities'), { recursive: true })
|
|
3061
|
+
await writeFile(
|
|
3062
|
+
join(rn, 'package.json'),
|
|
3063
|
+
JSON.stringify({ name: 'react-native', main: 'index.js' })
|
|
3064
|
+
)
|
|
3065
|
+
await writeFile(
|
|
3066
|
+
join(rn, 'Libraries/NativeComponent/NativeComponentRegistry.js'),
|
|
3067
|
+
'exports.get = (name, config) => ({name, config: config()})'
|
|
3068
|
+
)
|
|
3069
|
+
await writeFile(
|
|
3070
|
+
join(rn, 'Libraries/ReactNative/RendererProxy.js'),
|
|
3071
|
+
'exports.dispatchCommand = (ref, name, args) => { globalThis.command = [ref, name, args] }'
|
|
3072
|
+
)
|
|
3073
|
+
for (const name of ['codegenNativeComponent', 'codegenNativeCommands']) {
|
|
3074
|
+
await writeFile(
|
|
3075
|
+
join(rn, `Libraries/Utilities/${name}.js`),
|
|
3076
|
+
`module.exports = () => { throw new Error('codegen was not run') }`
|
|
3077
|
+
)
|
|
3078
|
+
}
|
|
3079
|
+
await writeFile(id, source)
|
|
3080
|
+
// ordinary published Flow without a pragma must also reach native lowering.
|
|
3081
|
+
await writeFile(
|
|
3082
|
+
join(root, 'fetch.js'),
|
|
3083
|
+
'export default function fetch(value: number) { return value + 1 }'
|
|
3084
|
+
)
|
|
3085
|
+
await writeFile(
|
|
3086
|
+
join(root, 'entry.js'),
|
|
3087
|
+
`import component, { Commands, twice, marker } from './ProbeNativeComponent';
|
|
3088
|
+
import fetch from './fetch';
|
|
3089
|
+
globalThis.flowProbe = { component, twice, marker, fetched: fetch(8) };
|
|
3090
|
+
Commands.reload('ref', 9);`
|
|
3091
|
+
)
|
|
3092
|
+
compiler.configureVXRNCompilerPlugin({
|
|
3093
|
+
enableReanimated: true,
|
|
3094
|
+
enableNativeWorklets: true,
|
|
3095
|
+
enableCompiler: false,
|
|
3096
|
+
})
|
|
3097
|
+
try {
|
|
3098
|
+
const output = await buildNativeBundle({
|
|
3099
|
+
root,
|
|
3100
|
+
platform: 'ios',
|
|
3101
|
+
entryFile: 'entry.js',
|
|
3102
|
+
dev,
|
|
3103
|
+
sourcemap: true,
|
|
3104
|
+
minify: false,
|
|
3105
|
+
})
|
|
3106
|
+
const context: any = { console }
|
|
3107
|
+
runInNewContext(output.code, context)
|
|
3108
|
+
expect(context.flowProbe.component.name).toBe('FlowProbe')
|
|
3109
|
+
expect(context.flowProbe.component.config.validAttributes.enabled).toBe(true)
|
|
3110
|
+
expect(context.command).toEqual(['ref', 'reload', [9]])
|
|
3111
|
+
expect(context.flowProbe.fetched).toBe(9)
|
|
3112
|
+
expect(context.flowProbe.twice(4)).toBe(8)
|
|
3113
|
+
expect(context.flowProbe.twice.__workletHash).toBeTypeOf('number')
|
|
3114
|
+
const ui = runInNewContext(`(${context.flowProbe.twice.__initData.code})`)
|
|
3115
|
+
expect(ui.call({ __closure: context.flowProbe.twice.__closure }, 5)).toBe(10)
|
|
3116
|
+
const lines = output.code.split('\n')
|
|
3117
|
+
const line = lines.findIndex((line) => line.includes('flow-map-marker'))
|
|
3118
|
+
expect(line).toBeGreaterThanOrEqual(0)
|
|
3119
|
+
const position = originalPositionFor(new TraceMap(output.map!), {
|
|
3120
|
+
line: line + 1,
|
|
3121
|
+
column: lines[line].indexOf('flow-map-marker'),
|
|
3122
|
+
})
|
|
3123
|
+
expect(position.source).toContain('ProbeNativeComponent.js')
|
|
3124
|
+
expect(position.line).toBe(
|
|
3125
|
+
source.split('\n').findIndex((line) => line.includes('flow-map-marker')) + 1
|
|
3126
|
+
)
|
|
3127
|
+
} finally {
|
|
3128
|
+
compiler.configureVXRNCompilerPlugin({
|
|
3129
|
+
enableReanimated: false,
|
|
3130
|
+
enableNativeWorklets: false,
|
|
3131
|
+
})
|
|
3132
|
+
await rm(root, { recursive: true, force: true })
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
)
|
|
2913
3136
|
it('strips typed arrows and class fields without a Flow pragma or type import', async () => {
|
|
2914
3137
|
const root = await mkdtemp(join(tmpdir(), 'vxrn-native-unmarked-flow-'))
|
|
2915
3138
|
await writeFile(
|
|
@@ -292,18 +292,11 @@ function getNativePlugins(
|
|
|
292
292
|
cssStubPlugin(),
|
|
293
293
|
// handle import.meta.glob (used by One's route system)
|
|
294
294
|
viteImportGlobPlugin({ root }),
|
|
295
|
-
//
|
|
296
|
-
// react-native codegen, react compiler, same pipeline as metro. runs before
|
|
297
|
-
// flowStripPlugin so react-native's Flow `.js` specs reach codegen with their
|
|
298
|
-
// type argument intact. stripping Flow first would erase it (which is why the
|
|
299
|
-
// codegen "didn't run for <Component>" warning fired).
|
|
300
|
-
vxrnCompilerPlugin(platform, dev, root, sourceMaps),
|
|
301
|
-
// react-native codegen: transforms TurboModule / Fabric specs before Flow stripping
|
|
295
|
+
// native codegen needs the original type declarations.
|
|
302
296
|
rnCodegenPlugin({ projectRoot: root }),
|
|
303
|
-
//
|
|
304
|
-
// handle, the guaranteed safety net before rolldown's oxc core parse (which
|
|
305
|
-
// can't parse Flow). now downstream of the compiler, so codegen sees the types.
|
|
297
|
+
// lower Flow before worklets and react compiler parse the source with oxc.
|
|
306
298
|
flowStripPlugin(),
|
|
299
|
+
vxrnCompilerPlugin(platform, dev, root, sourceMaps),
|
|
307
300
|
// guard undefined native methods in NativeAnimatedHelper
|
|
308
301
|
nativeAnimatedGuardPlugin(),
|
|
309
302
|
// handle asset imports (.png, .jpg, .ttf, etc.)
|
|
@@ -637,7 +630,7 @@ export async function createNativeDevEngine(
|
|
|
637
630
|
// is never minified.
|
|
638
631
|
...getNativeOutputOptions(prelude, true, false),
|
|
639
632
|
// open the HMR socket with RN's WebSocket module (not the global, which is
|
|
640
|
-
// only polyfilled once
|
|
633
|
+
// only polyfilled once setup-env has run) and hand it to the runtime,
|
|
641
634
|
// which owns every message it carries. handed over immediately rather than
|
|
642
635
|
// from an open handler: a host that does not honor `socket.onopen = fn`
|
|
643
636
|
// would otherwise silently never get Fast Refresh. the socket goes to the
|
|
@@ -1100,14 +1093,16 @@ globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
|
1100
1093
|
|
|
1101
1094
|
const entryCode = () => `
|
|
1102
1095
|
${refreshSetup}
|
|
1103
|
-
|
|
1096
|
+
// retain the namespace so rolldown dev eagerly initializes the RN environment
|
|
1097
|
+
// before app modules, even when the renderer also requires this entry.
|
|
1098
|
+
import * as ReactNativeEnvironment from 'react-native/setup-env';
|
|
1104
1099
|
import NativeWebSocket from 'react-native/Libraries/WebSocket/WebSocket';
|
|
1105
1100
|
import DevSettings from 'react-native/Libraries/Utilities/DevSettings';
|
|
1106
1101
|
${setupFileImport}
|
|
1107
1102
|
${routeImports}
|
|
1108
1103
|
import { createApp } from 'one';
|
|
1109
1104
|
|
|
1110
|
-
void
|
|
1105
|
+
void ReactNativeEnvironment;
|
|
1111
1106
|
globalThis.WebSocket = NativeWebSocket;
|
|
1112
1107
|
globalThis.__VXRN_RELOAD_NATIVE_DEV_BUNDLE__ = function(reason) {
|
|
1113
1108
|
DevSettings.reload(reason);
|
|
@@ -1589,7 +1584,7 @@ function nativePackageDedupePlugin(root: string): Plugin {
|
|
|
1589
1584
|
function reactNativeDedupePlugin(root: string): Plugin {
|
|
1590
1585
|
// package managers can install the same react native version at multiple
|
|
1591
1586
|
// physical paths. rolldown assigns each path a module identity, so resolving
|
|
1592
|
-
// every entry through the app's instance prevents
|
|
1587
|
+
// every entry through the app's instance prevents setup-env from running twice.
|
|
1593
1588
|
//
|
|
1594
1589
|
// resolving through the filesystem also keeps react native 0.87's narrow
|
|
1595
1590
|
// package.json `exports` (it dropped `./*` and `./src/*`) from rejecting deep
|
|
@@ -1599,7 +1594,7 @@ function reactNativeDedupePlugin(root: string): Plugin {
|
|
|
1599
1594
|
|
|
1600
1595
|
return {
|
|
1601
1596
|
name: 'vxrn:react-native-dedupe',
|
|
1602
|
-
async resolveId(source, importer) {
|
|
1597
|
+
async resolveId(source, importer, options) {
|
|
1603
1598
|
if (source !== 'react-native' && !source.startsWith('react-native/')) return
|
|
1604
1599
|
|
|
1605
1600
|
if (reactNativeRoot === undefined) {
|
|
@@ -1616,11 +1611,30 @@ function reactNativeDedupePlugin(root: string): Plugin {
|
|
|
1616
1611
|
}
|
|
1617
1612
|
if (!reactNativeRoot) return
|
|
1618
1613
|
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1614
|
+
// public subpaths can map to different filenames through package exports.
|
|
1615
|
+
// resolve them from the app before handling private filesystem imports.
|
|
1616
|
+
const exported = await this.resolve(source, join(root, 'package.json'), {
|
|
1622
1617
|
skipSelf: true,
|
|
1618
|
+
kind: options.kind,
|
|
1623
1619
|
})
|
|
1620
|
+
if (exported) return exported
|
|
1621
|
+
|
|
1622
|
+
const subpath =
|
|
1623
|
+
source === 'react-native' ? 'index.js' : source.slice('react-native/'.length)
|
|
1624
|
+
const unified = await this.resolve(
|
|
1625
|
+
normalizePath(resolve(reactNativeRoot, subpath)),
|
|
1626
|
+
importer,
|
|
1627
|
+
{ skipSelf: true, kind: options.kind }
|
|
1628
|
+
)
|
|
1629
|
+
if (unified) return unified
|
|
1630
|
+
// never fall through to importer-relative resolution: a nested copy
|
|
1631
|
+
// would load beside the app copy and initialize the runtime twice. a
|
|
1632
|
+
// file missing from the app copy is version skew, and skew must fail
|
|
1633
|
+
// loudly instead of forking the singleton.
|
|
1634
|
+
this.error(
|
|
1635
|
+
`[vxrn] '${source}' is missing from the app's react-native (${reactNativeRoot}), ` +
|
|
1636
|
+
`imported by '${importer}'. refusing the nested copy so the native runtime stays a singleton.`
|
|
1637
|
+
)
|
|
1624
1638
|
},
|
|
1625
1639
|
}
|
|
1626
1640
|
}
|
|
@@ -1644,10 +1658,9 @@ function cssStubPlugin(): Plugin {
|
|
|
1644
1658
|
}
|
|
1645
1659
|
|
|
1646
1660
|
/**
|
|
1647
|
-
*
|
|
1648
|
-
*
|
|
1649
|
-
* react
|
|
1650
|
-
* same pipeline as metro, single babel pass per file.
|
|
1661
|
+
* pipe files through @vxrn/compiler's babel transforms.
|
|
1662
|
+
* handles reanimated worklet compilation, async generator downleveling,
|
|
1663
|
+
* react compiler, and react-refresh (dev only).
|
|
1651
1664
|
*/
|
|
1652
1665
|
export function vxrnCompilerPlugin(
|
|
1653
1666
|
platform: string,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { MetroPluginOptions } from '@vxrn/vite-plugin-metro';
|
|
2
|
+
import type { PluginOption } from 'vite';
|
|
2
3
|
import type { VXRNOptionsFilled } from './getOptionsFilled';
|
|
3
4
|
export declare function getReactNativePlugins(config?: Partial<Pick<VXRNOptionsFilled, 'cacheDir' | 'debugBundle' | 'debugBundlePaths' | 'entries'>>, { metro, }?: {
|
|
4
5
|
/** Passing a non-null value will enable metro mode */
|
|
5
6
|
metro?: MetroPluginOptions | null;
|
|
6
|
-
}):
|
|
7
|
+
}): PluginOption[];
|
|
7
8
|
//# sourceMappingURL=getReactNativePlugins.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getReactNativePlugins.d.ts","sourceRoot":"","sources":["../../src/config/getReactNativePlugins.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"getReactNativePlugins.d.ts","sourceRoot":"","sources":["../../src/config/getReactNativePlugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAO3D,wBAAgB,qBAAqB,CACnC,MAAM,CAAC,EAAE,OAAO,CACd,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,aAAa,GAAG,kBAAkB,GAAG,SAAS,CAAC,CACrF,EACD,EACE,KAAK,GACN,GAAE;IACD,sDAAsD;IACtD,KAAK,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAA;CAC7B,GACL,YAAY,EAAE,CA4BhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prebuildWithoutExpo.d.ts","sourceRoot":"","sources":["../../src/exports/prebuildWithoutExpo.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,iBAAiB,EACjB,KAAK,iBAAiB,EAEvB,MAAM,+BAA+B,CAAA;AAsEtC,YAAY,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAE3F,eAAO,MAAM,mBAAmB,0BAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"prebuildWithoutExpo.d.ts","sourceRoot":"","sources":["../../src/exports/prebuildWithoutExpo.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,iBAAiB,EACjB,KAAK,iBAAiB,EAEvB,MAAM,+BAA+B,CAAA;AAsEtC,YAAY,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAE3F,eAAO,MAAM,mBAAmB,0BAAoB,CAAA;AA6EpD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAwChE;AA0ID,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,MAAM,CA8CrI;AAg8BD,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,MAAM,CAAA;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB;AAyfD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,QAAQ,EAAE,KAAK,GAAG,SAAS,CAAA;IAC3B,GAAG,EAAE,iBAAiB,CAAA;IACtB,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,GAAG,oBAAoB,CAg8BvB;AAED,eAAO,MAAM,mBAAmB,SACxB,MAAM,YACF,KAAK,GAAG,SAAS,OACtB,iBAAiB,WACd,MAAM,kBAqEf,CAAA;AAgCD,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,QA6EvD;AAID,wBAAsB,qBAAqB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,iBAsDzF;AAyFD,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,iBAAiB,CAAA;IACtB,SAAS,EAAE,SAAS,yBAAyB,EAAE,CAAA;CAChD,GAAG,IAAI,CA8BP;AAID,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,yBAAyB,EAAE,CAAC,CA+BtC;AAKD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE;IAC9C,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,MAAM,CAAA;CACtC,GAAG,IAAI,CAaP"}
|
|
@@ -9,6 +9,7 @@ export declare function autoDepOptimizePlugin(props: FindDepsOptions): Plugin;
|
|
|
9
9
|
export declare const getSSRExternalsCachePath: (root: string) => string;
|
|
10
10
|
type FindDepsOptionsByMode = FindDepsOptions & {
|
|
11
11
|
mode: string;
|
|
12
|
+
external?: string[] | true;
|
|
12
13
|
};
|
|
13
14
|
export declare function getScannedOptimizeDepsConfig(props: FindDepsOptionsByMode): Promise<{
|
|
14
15
|
ssr: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoDepOptimizePlugin.d.ts","sourceRoot":"","sources":["../../src/plugins/autoDepOptimizePlugin.ts"],"names":[],"mappings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AAO,GACR,EAAE,qBAAqB,2BA6EvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rnCodegenPlugin.d.ts","sourceRoot":"","sources":["../../src/plugins/rnCodegenPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"rnCodegenPlugin.d.ts","sourceRoot":"","sources":["../../src/plugins/rnCodegenPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAKlC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAA;AAE5D,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAW1E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { BundleCommandArgs } from '@vxrn/vite-plugin-metro/rn-commands';
|
|
2
2
|
export type { BundleCommandArgs };
|
|
3
3
|
export declare function buildBundle(_argv: Array<string>, ctx: any, args: BundleCommandArgs, bundleImpl?: any): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=buildBundle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildBundle.d.ts","sourceRoot":"","sources":["../../../src/rn-commands/bundle/buildBundle.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"buildBundle.d.ts","sourceRoot":"","sources":["../../../src/rn-commands/bundle/buildBundle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAK5E,YAAY,EAAE,iBAAiB,EAAE,CAAA;AAEjC,wBAAsB,WAAW,CAC/B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EACpB,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,iBAAiB,EACvB,UAAU,GAAE,GAAU,GACrB,OAAO,CAAC,IAAI,CAAC,CAiGf"}
|
|
@@ -127,10 +127,9 @@ export declare function nativeAnimatedGuardPlugin(): Plugin;
|
|
|
127
127
|
*/
|
|
128
128
|
export declare function hmrClientNoopPlugin(): Plugin;
|
|
129
129
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* react
|
|
133
|
-
* same pipeline as metro, single babel pass per file.
|
|
130
|
+
* pipe files through @vxrn/compiler's babel transforms.
|
|
131
|
+
* handles reanimated worklet compilation, async generator downleveling,
|
|
132
|
+
* react compiler, and react-refresh (dev only).
|
|
134
133
|
*/
|
|
135
134
|
export declare function vxrnCompilerPlugin(platform: string, dev: boolean, projectRoot?: string, sourceMaps?: boolean): Plugin;
|
|
136
135
|
type NativeAssetData = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNativeDevEngine.d.ts","sourceRoot":"","sources":["../../src/utils/createNativeDevEngine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkBH,OAAO,KAAK,EAA+B,MAAM,EAAkB,MAAM,UAAU,CAAA;AACnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAgCtD,yFAAyF;AACzF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,EAAE,CAE3D;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,KAAK,GAAG,SAAS,CAAA;IAC3B,GAAG,EAAE,OAAO,CAAA;CACb;AAED,UAAU,sBAAsB;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,KAAK,GAAG,SAAS,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,WAAW,CAAC,EAAE,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ID,wBAAgB,mBAAmB,IAAI,MAAM,CA6O5C"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { getScannedOptimizeDepsConfig } from './autoDepOptimizePlugin'
|
|
3
|
-
|
|
4
|
-
describe('getScannedOptimizeDepsConfig', () => {
|
|
5
|
-
it('filters excluded deps from scanned results', async () => {
|
|
6
|
-
// mock the scanning by passing a fake result
|
|
7
|
-
const mockResult = {
|
|
8
|
-
prebundleDeps: ['react', 'react-native-reanimated', 'lodash'],
|
|
9
|
-
hasReanimated: true,
|
|
10
|
-
hasNativewind: false,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// we need to mock findDepsToOptimize, so let's test the filtering logic directly
|
|
14
|
-
const excludeArray = ['react-native-reanimated']
|
|
15
|
-
const excludeStrings = excludeArray.filter((e): e is string => typeof e === 'string')
|
|
16
|
-
const excludeSet = new Set(excludeStrings)
|
|
17
|
-
|
|
18
|
-
const filteredDeps = mockResult.prebundleDeps.filter((dep) => !excludeSet.has(dep))
|
|
19
|
-
|
|
20
|
-
expect(filteredDeps).toContain('react')
|
|
21
|
-
expect(filteredDeps).toContain('lodash')
|
|
22
|
-
expect(filteredDeps).not.toContain('react-native-reanimated')
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
it('handles RegExp exclude patterns (ignores them for dep name filtering)', async () => {
|
|
26
|
-
const mockResult = {
|
|
27
|
-
prebundleDeps: ['react', 'react-native-reanimated'],
|
|
28
|
-
hasReanimated: true,
|
|
29
|
-
hasNativewind: false,
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// regexp patterns should be ignored for dep name filtering
|
|
33
|
-
const excludeArray: (string | RegExp)[] = [/some-pattern/, 'react-native-reanimated']
|
|
34
|
-
const excludeStrings = excludeArray.filter((e): e is string => typeof e === 'string')
|
|
35
|
-
const excludeSet = new Set(excludeStrings)
|
|
36
|
-
|
|
37
|
-
const filteredDeps = mockResult.prebundleDeps.filter((dep) => !excludeSet.has(dep))
|
|
38
|
-
|
|
39
|
-
expect(filteredDeps).toContain('react')
|
|
40
|
-
expect(filteredDeps).not.toContain('react-native-reanimated')
|
|
41
|
-
})
|
|
42
|
-
})
|