vxrn 1.2.47 → 1.2.48
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/cli.js +6 -2
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/cli.native.js.map +1 -1
- package/dist/config/getBaseVitePlugins.js.map +1 -1
- package/dist/config/getBaseVitePlugins.mjs.map +1 -1
- package/dist/config/getBaseVitePlugins.native.js.map +1 -1
- package/dist/config/getOptionsFilled.js +2 -2
- package/dist/config/getOptionsFilled.js.map +1 -1
- package/dist/config/getOptionsFilled.mjs +2 -2
- package/dist/config/getOptionsFilled.mjs.map +1 -1
- package/dist/config/getOptionsFilled.native.js +2 -2
- package/dist/config/getOptionsFilled.native.js.map +1 -1
- package/dist/config/getReactNativeBuildConfig.js +7 -2
- package/dist/config/getReactNativeBuildConfig.js.map +1 -1
- package/dist/config/getReactNativeBuildConfig.mjs.map +1 -1
- package/dist/config/getReactNativeBuildConfig.native.js.map +1 -1
- package/dist/config/getViteServerConfig.js.map +1 -1
- package/dist/config/getViteServerConfig.mjs.map +1 -1
- package/dist/config/getViteServerConfig.native.js.map +1 -1
- package/dist/config/mergeUserConfig.js +3 -3
- package/dist/config/mergeUserConfig.js.map +1 -1
- package/dist/config/mergeUserConfig.mjs +3 -3
- package/dist/config/mergeUserConfig.mjs.map +1 -1
- package/dist/config/mergeUserConfig.native.js +3 -3
- package/dist/config/mergeUserConfig.native.js.map +1 -1
- package/dist/exports/build.js +12 -4
- package/dist/exports/build.js.map +1 -1
- package/dist/exports/build.mjs.map +1 -1
- package/dist/exports/build.native.js.map +1 -1
- package/dist/exports/dev.js +1 -1
- package/dist/exports/dev.js.map +1 -1
- package/dist/exports/dev.mjs +1 -1
- package/dist/exports/dev.mjs.map +1 -1
- package/dist/exports/dev.native.js +1 -1
- package/dist/exports/dev.native.js.map +1 -1
- package/dist/exports/loadEnv.js.map +1 -1
- package/dist/exports/loadEnv.mjs.map +1 -1
- package/dist/exports/loadEnv.native.js.map +1 -1
- package/dist/exports/prebuild.js +4 -1
- package/dist/exports/prebuild.js.map +1 -1
- package/dist/exports/prebuild.mjs.map +1 -1
- package/dist/exports/prebuild.native.js.map +1 -1
- package/dist/exports/serveStaticAssets.js.map +1 -1
- package/dist/exports/serveStaticAssets.mjs.map +1 -1
- package/dist/exports/serveStaticAssets.native.js.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js.map +1 -1
- package/dist/patches/builtInDepPatches.js +13 -3
- package/dist/patches/builtInDepPatches.js.map +1 -1
- package/dist/patches/builtInDepPatches.mjs.map +1 -1
- package/dist/patches/builtInDepPatches.native.js.map +1 -1
- package/dist/plugins/autoDepOptimizePlugin.js +17 -4
- package/dist/plugins/autoDepOptimizePlugin.js.map +1 -1
- package/dist/plugins/autoDepOptimizePlugin.mjs.map +1 -1
- package/dist/plugins/autoDepOptimizePlugin.native.js.map +1 -1
- package/dist/plugins/expoManifestRequestHandlerPlugin.js +12 -11
- package/dist/plugins/expoManifestRequestHandlerPlugin.js.map +1 -1
- package/dist/plugins/expoManifestRequestHandlerPlugin.mjs +1 -1
- package/dist/plugins/expoManifestRequestHandlerPlugin.mjs.map +1 -1
- package/dist/plugins/expoManifestRequestHandlerPlugin.native.js +1 -1
- package/dist/plugins/expoManifestRequestHandlerPlugin.native.js.map +1 -1
- package/dist/plugins/reactNativeCommonJsPlugin.js +4 -2
- package/dist/plugins/reactNativeCommonJsPlugin.js.map +1 -1
- package/dist/plugins/reactNativeCommonJsPlugin.mjs +1 -1
- package/dist/plugins/reactNativeCommonJsPlugin.mjs.map +1 -1
- package/dist/plugins/reactNativeCommonJsPlugin.native.js +1 -1
- package/dist/plugins/reactNativeCommonJsPlugin.native.js.map +1 -1
- package/dist/plugins/reactNativeDevAssetPlugin.js +16 -2
- package/dist/plugins/reactNativeDevAssetPlugin.js.map +1 -1
- package/dist/plugins/reactNativeDevAssetPlugin.mjs.map +1 -1
- package/dist/plugins/reactNativeDevAssetPlugin.native.js.map +1 -1
- package/dist/plugins/reactNativeHMRPlugin.js +17 -3
- package/dist/plugins/reactNativeHMRPlugin.js.map +1 -1
- package/dist/plugins/reactNativeHMRPlugin.mjs.map +1 -1
- package/dist/plugins/reactNativeHMRPlugin.native.js.map +1 -1
- package/dist/plugins/resolveIdScan.test.js +3 -6
- package/dist/plugins/resolveIdScan.test.js.map +1 -1
- package/dist/plugins/resolveIdScan.test.mjs.map +1 -1
- package/dist/plugins/resolveIdScan.test.native.js.map +1 -1
- package/dist/plugins/rollupRemoveUnusedImports.js +1 -1
- package/dist/plugins/rollupRemoveUnusedImports.js.map +1 -1
- package/dist/plugins/rollupRemoveUnusedImports.mjs +1 -1
- package/dist/plugins/rollupRemoveUnusedImports.mjs.map +1 -1
- package/dist/plugins/rollupRemoveUnusedImports.native.js +1 -1
- package/dist/plugins/rollupRemoveUnusedImports.native.js.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.js +3 -5
- package/dist/rn-commands/bundle/buildBundle.js.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.mjs +10 -13
- package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.native.js +3 -5
- package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
- package/dist/user-interface/index.js +15 -6
- package/dist/user-interface/index.js.map +1 -1
- package/dist/user-interface/index.mjs.map +1 -1
- package/dist/user-interface/index.native.js.map +1 -1
- package/dist/utils/expoRun.js +4 -2
- package/dist/utils/expoRun.js.map +1 -1
- package/dist/utils/expoRun.mjs.map +1 -1
- package/dist/utils/expoRun.native.js.map +1 -1
- package/dist/utils/getReactNativeBundle.js +12 -7
- package/dist/utils/getReactNativeBundle.js.map +1 -1
- package/dist/utils/getReactNativeBundle.mjs.map +1 -1
- package/dist/utils/getReactNativeBundle.native.js.map +1 -1
- package/dist/utils/getVitePath.js.map +1 -1
- package/dist/utils/getVitePath.mjs.map +1 -1
- package/dist/utils/getVitePath.native.js.map +1 -1
- package/dist/utils/patches.js +12 -3
- package/dist/utils/patches.js.map +1 -1
- package/dist/utils/patches.mjs.map +1 -1
- package/dist/utils/patches.native.js.map +1 -1
- package/dist/utils/scanDepsToOptimize.js +8 -3
- package/dist/utils/scanDepsToOptimize.js.map +1 -1
- package/dist/utils/scanDepsToOptimize.mjs +1 -1
- package/dist/utils/scanDepsToOptimize.mjs.map +1 -1
- package/dist/utils/scanDepsToOptimize.native.js +1 -1
- package/dist/utils/scanDepsToOptimize.native.js.map +1 -1
- package/dist/utils/swapPrebuiltReactModules.js +8 -2
- package/dist/utils/swapPrebuiltReactModules.js.map +1 -1
- package/dist/utils/swapPrebuiltReactModules.mjs.map +1 -1
- package/dist/utils/swapPrebuiltReactModules.native.js.map +1 -1
- package/dist/utils/utils.js.map +1 -1
- package/dist/utils/utils.mjs.map +1 -1
- package/dist/utils/utils.native.js.map +1 -1
- package/dist/worker.js +15 -12
- package/dist/worker.js.map +1 -1
- package/dist/worker.mjs.map +1 -1
- package/dist/worker.native.js.map +1 -1
- package/expo-js-native-debugging-plugin.cjs +9 -2
- package/expo-plugin.cjs +26 -9
- package/package.json +13 -13
- package/react-native-template.js +25 -13
- package/src/cli.ts +12 -5
- package/src/config/getBaseVitePlugins.ts +4 -1
- package/src/config/getOptionsFilled.ts +9 -4
- package/src/config/getReactNativeBuildConfig.ts +7 -2
- package/src/config/getViteServerConfig.ts +4 -1
- package/src/config/mergeUserConfig.ts +3 -3
- package/src/exports/build.ts +16 -5
- package/src/exports/dev.ts +3 -2
- package/src/exports/loadEnv.ts +17 -11
- package/src/exports/prebuild.ts +13 -3
- package/src/exports/serveStaticAssets.ts +4 -1
- package/src/index.ts +5 -1
- package/src/patches/builtInDepPatches.ts +14 -4
- package/src/plugins/autoDepOptimizePlugin.ts +18 -5
- package/src/plugins/clientInjectPlugin.ts +1 -1
- package/src/plugins/expoManifestRequestHandlerPlugin.ts +23 -19
- package/src/plugins/reactNativeCommonJsPlugin.ts +4 -2
- package/src/plugins/reactNativeDevAssetPlugin.ts +22 -4
- package/src/plugins/reactNativeHMRPlugin.ts +18 -4
- package/src/plugins/resolveIdScan.test.ts +8 -7
- package/src/plugins/rollupRemoveUnusedImports.ts +1 -1
- package/src/rn-commands/bundle/buildBundle.ts +1 -3
- package/src/types.ts +14 -3
- package/src/user-interface/index.ts +21 -6
- package/src/utils/expoRun.ts +8 -2
- package/src/utils/getReactNativeBundle.ts +13 -7
- package/src/utils/getVitePath.ts +4 -1
- package/src/utils/patches.ts +20 -6
- package/src/utils/scanDepsToOptimize.ts +16 -6
- package/src/utils/swapPrebuiltReactModules.ts +13 -3
- package/src/utils/utils.ts +4 -1
- package/src/worker.ts +19 -16
- package/types/config/getBaseVitePlugins.d.ts.map +1 -1
- package/types/config/getOptionsFilled.d.ts.map +1 -1
- package/types/config/getViteServerConfig.d.ts.map +1 -1
- package/types/exports/build.d.ts.map +1 -1
- package/types/exports/dev.d.ts.map +1 -1
- package/types/exports/loadEnv.d.ts.map +1 -1
- package/types/exports/prebuild.d.ts.map +1 -1
- package/types/exports/serveStaticAssets.d.ts.map +1 -1
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/patches/builtInDepPatches.d.ts.map +1 -1
- package/types/plugins/autoDepOptimizePlugin.d.ts +1 -1
- package/types/plugins/autoDepOptimizePlugin.d.ts.map +1 -1
- package/types/plugins/expoManifestRequestHandlerPlugin.d.ts.map +1 -1
- package/types/plugins/reactNativeCommonJsPlugin.d.ts.map +1 -1
- package/types/plugins/reactNativeDevAssetPlugin.d.ts.map +1 -1
- package/types/plugins/reactNativeHMRPlugin.d.ts.map +1 -1
- package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
- package/types/types.d.ts.map +1 -1
- package/types/utils/expoRun.d.ts.map +1 -1
- package/types/utils/getReactNativeBundle.d.ts.map +1 -1
- package/types/utils/getVitePath.d.ts.map +1 -1
- package/types/utils/patches.d.ts.map +1 -1
- package/types/utils/scanDepsToOptimize.d.ts.map +1 -1
- package/types/utils/swapPrebuiltReactModules.d.ts.map +1 -1
- package/types/utils/utils.d.ts.map +1 -1
- /package/types/utils/{filterPluginsForNative.d.ts → filterPluginsforNative.d.ts} +0 -0
package/src/exports/loadEnv.ts
CHANGED
|
@@ -9,7 +9,11 @@ type Mode = 'development' | 'production' | string
|
|
|
9
9
|
|
|
10
10
|
const DEFAULT_PREFIX = /^(ONE|VITE|TAMAGUI)_/
|
|
11
11
|
|
|
12
|
-
export async function loadEnv(
|
|
12
|
+
export async function loadEnv(
|
|
13
|
+
mode: Mode,
|
|
14
|
+
root = process.cwd(),
|
|
15
|
+
userPrefix?: string | string[]
|
|
16
|
+
) {
|
|
13
17
|
const loadedEnv = await loadJustEnvFiles(mode)
|
|
14
18
|
const prefix = userPrefix ? (Array.isArray(userPrefix) ? userPrefix : [userPrefix]) : []
|
|
15
19
|
const isPublicKey = (key: string) => {
|
|
@@ -69,22 +73,24 @@ function getEnvFilesForMode(mode: Mode) {
|
|
|
69
73
|
|
|
70
74
|
async function loadJustEnvFiles(mode: Mode) {
|
|
71
75
|
const envFiles = getEnvFilesForMode(mode)
|
|
72
|
-
|
|
76
|
+
|
|
73
77
|
// load all env files and merge them
|
|
74
78
|
const parsed = Object.fromEntries(
|
|
75
|
-
(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
(
|
|
80
|
+
await Promise.all(
|
|
81
|
+
envFiles.map(async (filePath) => {
|
|
82
|
+
if (!tryStatSync(filePath)?.isFile()) return []
|
|
83
|
+
const contents = await readFile(filePath, 'utf-8')
|
|
84
|
+
return Object.entries(parse(contents))
|
|
85
|
+
})
|
|
86
|
+
)
|
|
87
|
+
).flat()
|
|
82
88
|
)
|
|
83
|
-
|
|
89
|
+
|
|
84
90
|
// support dotenv-expand for variable expansion
|
|
85
91
|
const processEnv = { ...process.env } as DotenvPopulateInput
|
|
86
92
|
expand({ parsed, processEnv })
|
|
87
|
-
|
|
93
|
+
|
|
88
94
|
return parsed
|
|
89
95
|
}
|
|
90
96
|
|
package/src/exports/prebuild.ts
CHANGED
|
@@ -41,7 +41,10 @@ export const prebuild = async ({
|
|
|
41
41
|
let packageJsonContents = await FSExtra.readFile(packageJsonPath, 'utf8')
|
|
42
42
|
|
|
43
43
|
packageJsonContents = packageJsonContents.replace(/expo run:ios/g, 'one run:ios')
|
|
44
|
-
packageJsonContents = packageJsonContents.replace(
|
|
44
|
+
packageJsonContents = packageJsonContents.replace(
|
|
45
|
+
/expo run:android/g,
|
|
46
|
+
'one run:android'
|
|
47
|
+
)
|
|
45
48
|
|
|
46
49
|
await FSExtra.writeFile(packageJsonPath, packageJsonContents, 'utf8')
|
|
47
50
|
} catch (error) {
|
|
@@ -204,7 +207,10 @@ Android:
|
|
|
204
207
|
}
|
|
205
208
|
|
|
206
209
|
function isMissingCliDependency(error) {
|
|
207
|
-
return
|
|
210
|
+
return (
|
|
211
|
+
error.code === 'MODULE_NOT_FOUND' &&
|
|
212
|
+
/@react-native-community\/cli/.test(error.message)
|
|
213
|
+
)
|
|
208
214
|
}
|
|
209
215
|
|
|
210
216
|
function warnMissingCliDependency() {
|
|
@@ -218,7 +224,11 @@ ${colors.white(
|
|
|
218
224
|
)}`)
|
|
219
225
|
}
|
|
220
226
|
|
|
221
|
-
export async function replaceInUTF8File(
|
|
227
|
+
export async function replaceInUTF8File(
|
|
228
|
+
filePath: string,
|
|
229
|
+
findThis: string,
|
|
230
|
+
replaceWith: string
|
|
231
|
+
) {
|
|
222
232
|
const fileContent = await FSExtra.readFile(filePath, 'utf8')
|
|
223
233
|
const replacedFileContent = fileContent.replace(findThis, replaceWith)
|
|
224
234
|
if (fileContent !== replacedFileContent) {
|
|
@@ -4,7 +4,10 @@ import type { Context } from 'hono'
|
|
|
4
4
|
export async function serveStaticAssets({
|
|
5
5
|
context,
|
|
6
6
|
next,
|
|
7
|
-
}: {
|
|
7
|
+
}: {
|
|
8
|
+
context: Context
|
|
9
|
+
next?: () => Promise<void>
|
|
10
|
+
}) {
|
|
8
11
|
let didCallNext = false
|
|
9
12
|
|
|
10
13
|
const response = await serveStatic({
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,11 @@ export { patch } from './exports/patch'
|
|
|
9
9
|
export { loadEnv } from './exports/loadEnv'
|
|
10
10
|
export { serveStaticAssets } from './exports/serveStaticAssets'
|
|
11
11
|
|
|
12
|
-
export {
|
|
12
|
+
export {
|
|
13
|
+
type VXRNOptionsFilled,
|
|
14
|
+
getOptionsFilled,
|
|
15
|
+
fillOptions,
|
|
16
|
+
} from './config/getOptionsFilled'
|
|
13
17
|
export * from './config/getOptimizeDeps'
|
|
14
18
|
export * from './config/getBaseViteConfigOnly'
|
|
15
19
|
export * from './config/getBaseVitePlugins'
|
|
@@ -25,7 +25,9 @@ export const builtInDepPatches: DepPatch[] = [
|
|
|
25
25
|
const existingExports = { ...pkg.exports }
|
|
26
26
|
|
|
27
27
|
if (!pkg.exports['.']) {
|
|
28
|
-
throw new Error(
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Expected a version of React that has package.json exports defined`
|
|
30
|
+
)
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
pkg.exports['.'] = {
|
|
@@ -126,7 +128,9 @@ ${contents}
|
|
|
126
128
|
const existingExports = { ...pkg.exports }
|
|
127
129
|
|
|
128
130
|
if (!pkg.exports['.']) {
|
|
129
|
-
throw new Error(
|
|
131
|
+
throw new Error(
|
|
132
|
+
`Expected a version of React that has package.json exports defined`
|
|
133
|
+
)
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
pkg.exports['.'] = {
|
|
@@ -450,8 +454,14 @@ export const addCustomSourceTransformer = resolveAssetSource.addCustomSourceTran
|
|
|
450
454
|
patchFiles: {
|
|
451
455
|
'**/*.js': (contents) =>
|
|
452
456
|
contents
|
|
453
|
-
?.replace(
|
|
454
|
-
|
|
457
|
+
?.replace(
|
|
458
|
+
/punycode\.ucs2\.decode/gm,
|
|
459
|
+
'(punycode.ucs2decode || punycode.ucs2.decode)'
|
|
460
|
+
)
|
|
461
|
+
?.replace(
|
|
462
|
+
/punycode\.ucs2\.encode/gm,
|
|
463
|
+
'(punycode.ucs2encode || punycode.ucs2.encode)'
|
|
464
|
+
),
|
|
455
465
|
},
|
|
456
466
|
},
|
|
457
467
|
|
|
@@ -3,7 +3,11 @@ import FSExtra from 'fs-extra'
|
|
|
3
3
|
import path from 'node:path'
|
|
4
4
|
import { createFilter, type Plugin } from 'vite'
|
|
5
5
|
import type { AutoDepOptimizationOptions } from '../types'
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
EXCLUDE_LIST,
|
|
8
|
+
type ScanDepsResult,
|
|
9
|
+
scanDepsToOptimize,
|
|
10
|
+
} from '../utils/scanDepsToOptimize'
|
|
7
11
|
import { getFileHash, lookupFile } from '../utils/utils'
|
|
8
12
|
import { getCacheDir } from '../utils/getCacheDir'
|
|
9
13
|
|
|
@@ -75,7 +79,12 @@ export async function getScannedOptimizeDepsConfig(props: FindDepsOptionsByMode)
|
|
|
75
79
|
|
|
76
80
|
let sessionCacheVal: ScanDepsResult | null = null
|
|
77
81
|
|
|
78
|
-
export async function findDepsToOptimize({
|
|
82
|
+
export async function findDepsToOptimize({
|
|
83
|
+
root,
|
|
84
|
+
mode,
|
|
85
|
+
exclude,
|
|
86
|
+
include,
|
|
87
|
+
}: FindDepsOptionsByMode) {
|
|
79
88
|
const cacheFilePath = getSSRExternalsCachePath(root)
|
|
80
89
|
const startedAt = debug ? Date.now() : 0
|
|
81
90
|
|
|
@@ -102,8 +111,10 @@ export async function findDepsToOptimize({ root, mode, exclude, include }: FindD
|
|
|
102
111
|
|
|
103
112
|
if (lockFileHash && !noCache) {
|
|
104
113
|
try {
|
|
105
|
-
const {
|
|
106
|
-
|
|
114
|
+
const {
|
|
115
|
+
lockFileHash: cachedLockFileHash,
|
|
116
|
+
depsToPreBundleForSsr: cachedDepsToPreBundle,
|
|
117
|
+
} = await FSExtra.readJSON(cacheFilePath)
|
|
107
118
|
|
|
108
119
|
if (
|
|
109
120
|
lockFileHash === cachedLockFileHash &&
|
|
@@ -143,7 +154,9 @@ export async function findDepsToOptimize({ root, mode, exclude, include }: FindD
|
|
|
143
154
|
: ` (Focus on this debug scope, "DEBUG=${debug.namespace}", to see more details.)`)
|
|
144
155
|
)
|
|
145
156
|
|
|
146
|
-
debugDetails?.(
|
|
157
|
+
debugDetails?.(
|
|
158
|
+
`Deps discovered to be pre-bundled for SSR: ${value.prebundleDeps.join(', ')}`
|
|
159
|
+
)
|
|
147
160
|
|
|
148
161
|
return value
|
|
149
162
|
}
|
|
@@ -6,7 +6,7 @@ import { getResolvedConfig, setResolvedConfig } from './getResolvedConfigSubset'
|
|
|
6
6
|
|
|
7
7
|
let config: ResolvedConfig | null
|
|
8
8
|
|
|
9
|
-
const isObject = (x: any): x is
|
|
9
|
+
const isObject = (x: any): x is object => x && typeof x === 'object'
|
|
10
10
|
|
|
11
11
|
export function getServerConfigPlugin() {
|
|
12
12
|
return {
|
|
@@ -34,7 +34,8 @@ export function expoManifestRequestHandlerPlugin(
|
|
|
34
34
|
return next()
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const protocol =
|
|
37
|
+
const protocol =
|
|
38
|
+
req.socket instanceof TLSSocket && req.socket.encrypted ? 'https' : 'http'
|
|
38
39
|
const host = `${req.headers['x-forwarded-host'] || req.headers.host || '127.0.0.1'}`
|
|
39
40
|
|
|
40
41
|
// Try to dynamically import the internal Expo manifest handler from expo packages installed in the user's project.
|
|
@@ -57,7 +58,8 @@ export function expoManifestRequestHandlerPlugin(
|
|
|
57
58
|
if (!ExpoGoManifestHandlerMiddleware) {
|
|
58
59
|
if (
|
|
59
60
|
expoGoManifestHandlerMiddlewareImportError instanceof Error &&
|
|
60
|
-
(expoGoManifestHandlerMiddlewareImportError as any).code ===
|
|
61
|
+
(expoGoManifestHandlerMiddlewareImportError as any).code ===
|
|
62
|
+
'MODULE_NOT_FOUND'
|
|
61
63
|
) {
|
|
62
64
|
logger.warn(
|
|
63
65
|
colors.yellow(
|
|
@@ -95,15 +97,19 @@ export function expoManifestRequestHandlerPlugin(
|
|
|
95
97
|
return
|
|
96
98
|
}
|
|
97
99
|
|
|
98
|
-
const manifestHandlerMiddleware = new ExpoGoManifestHandlerMiddleware(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
const manifestHandlerMiddleware = new ExpoGoManifestHandlerMiddleware(
|
|
101
|
+
projectRoot,
|
|
102
|
+
{
|
|
103
|
+
constructUrl: () => {
|
|
104
|
+
return `${protocol}://${host}`
|
|
105
|
+
},
|
|
106
|
+
}
|
|
107
|
+
)
|
|
103
108
|
|
|
104
109
|
// Override the `_getBundleUrl` method ensure the same host and protocol are used for the bundle URL.
|
|
105
|
-
const origGetBundleUrl =
|
|
106
|
-
manifestHandlerMiddleware
|
|
110
|
+
const origGetBundleUrl = manifestHandlerMiddleware._getBundleUrl.bind(
|
|
111
|
+
manifestHandlerMiddleware
|
|
112
|
+
)
|
|
107
113
|
manifestHandlerMiddleware._getBundleUrl = (...args) => {
|
|
108
114
|
/** Will be something like `http://127.0.0.1:8081/index.bundle?platform=ios&dev=true&hot=false&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app`. */
|
|
109
115
|
const origBundleUrl = origGetBundleUrl(...args)
|
|
@@ -123,11 +129,13 @@ export function expoManifestRequestHandlerPlugin(
|
|
|
123
129
|
|
|
124
130
|
manifestHandlerMiddleware._getManifestResponseAsync = async (...args) => {
|
|
125
131
|
try {
|
|
126
|
-
const results = await manifestHandlerMiddleware._origGetManifestResponseAsync(
|
|
132
|
+
const results = await manifestHandlerMiddleware._origGetManifestResponseAsync(
|
|
133
|
+
...args
|
|
134
|
+
)
|
|
127
135
|
|
|
128
136
|
// Seems that results.body may have a leading and trailing string that is not JSON, so we need to extract the JSON from it.
|
|
129
137
|
const [, beforeBodyJson, bodyJson, afterBodyJson] =
|
|
130
|
-
results.body.match(/([
|
|
138
|
+
results.body.match(/([^{]*)({.*})([^}]*)/) || []
|
|
131
139
|
if (!bodyJson) {
|
|
132
140
|
throw new Error(`Unrecognized manifest response from expo: ${results.body}`)
|
|
133
141
|
}
|
|
@@ -141,16 +149,12 @@ export function expoManifestRequestHandlerPlugin(
|
|
|
141
149
|
}
|
|
142
150
|
|
|
143
151
|
if (typeof parsedBody.extra.expoClient.hostUri === 'string') {
|
|
144
|
-
parsedBody.extra.expoClient.hostUri =
|
|
145
|
-
/^https?:\/\//,
|
|
146
|
-
''
|
|
147
|
-
)
|
|
152
|
+
parsedBody.extra.expoClient.hostUri =
|
|
153
|
+
parsedBody.extra.expoClient.hostUri.replace(/^https?:\/\//, '')
|
|
148
154
|
}
|
|
149
155
|
if (typeof parsedBody.extra.expoGo.debuggerHost === 'string') {
|
|
150
|
-
parsedBody.extra.expoGo.debuggerHost =
|
|
151
|
-
/^https?:\/\//,
|
|
152
|
-
''
|
|
153
|
-
)
|
|
156
|
+
parsedBody.extra.expoGo.debuggerHost =
|
|
157
|
+
parsedBody.extra.expoGo.debuggerHost.replace(/^https?:\/\//, '')
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
// TODO: Using a static icon and splash for branding for now.
|
|
@@ -78,7 +78,9 @@ export function reactNativeCommonJsPlugin(options: {
|
|
|
78
78
|
base: undefined,
|
|
79
79
|
|
|
80
80
|
define: {
|
|
81
|
-
'process.env.REACT_NATIVE_SERVER_PUBLIC_PORT': JSON.stringify(
|
|
81
|
+
'process.env.REACT_NATIVE_SERVER_PUBLIC_PORT': JSON.stringify(
|
|
82
|
+
`${options.port}`
|
|
83
|
+
),
|
|
82
84
|
},
|
|
83
85
|
|
|
84
86
|
build: {
|
|
@@ -162,7 +164,7 @@ export function reactNativeCommonJsPlugin(options: {
|
|
|
162
164
|
for (const line of code.split('\n')) {
|
|
163
165
|
if (line.startsWith('export * from')) {
|
|
164
166
|
const [_, exportedName] =
|
|
165
|
-
line.match(/export \* from [
|
|
167
|
+
line.match(/export \* from ['"]([^'"]+)['"]/) || []
|
|
166
168
|
if (exportedName) {
|
|
167
169
|
found++
|
|
168
170
|
const name = `__vxrnExp${found}`
|
|
@@ -5,7 +5,18 @@ import type { Plugin, ResolvedConfig } from 'vite'
|
|
|
5
5
|
import colors from 'picocolors'
|
|
6
6
|
import { isNativeEnvironment } from '../utils/environmentUtils'
|
|
7
7
|
|
|
8
|
-
const IMAGE_ASSET_EXTS = [
|
|
8
|
+
const IMAGE_ASSET_EXTS = [
|
|
9
|
+
'png',
|
|
10
|
+
'jpg',
|
|
11
|
+
'jpeg',
|
|
12
|
+
'bmp',
|
|
13
|
+
'gif',
|
|
14
|
+
'webp',
|
|
15
|
+
'psd',
|
|
16
|
+
'svg',
|
|
17
|
+
'tiff',
|
|
18
|
+
'ktx',
|
|
19
|
+
]
|
|
9
20
|
const IMAGE_ASSET_EXTS_SET = new Set(IMAGE_ASSET_EXTS)
|
|
10
21
|
|
|
11
22
|
const ASSET_DEST_DIR = 'assets'
|
|
@@ -21,7 +32,9 @@ type ReactNativeDevAssetPluginConfig = {
|
|
|
21
32
|
assetsDest?: string
|
|
22
33
|
}
|
|
23
34
|
|
|
24
|
-
export function reactNativeDevAssetPlugin(
|
|
35
|
+
export function reactNativeDevAssetPlugin(
|
|
36
|
+
options: ReactNativeDevAssetPluginConfig
|
|
37
|
+
): Plugin {
|
|
25
38
|
const { assetExts } = options
|
|
26
39
|
|
|
27
40
|
const assetExtsRegExp = new RegExp(`\\.(${assetExts.join('|')})$`)
|
|
@@ -91,7 +104,10 @@ export function reactNativeDevAssetPlugin(options: ReactNativeDevAssetPluginConf
|
|
|
91
104
|
assetData.relativeFileSystemLocation
|
|
92
105
|
)
|
|
93
106
|
await FSExtra.ensureDir(assetsDestDir)
|
|
94
|
-
await FSExtra.copyFile(
|
|
107
|
+
await FSExtra.copyFile(
|
|
108
|
+
id,
|
|
109
|
+
path.join(assetsDestDir, `${assetData.name}.${assetData.type}`)
|
|
110
|
+
)
|
|
95
111
|
}
|
|
96
112
|
|
|
97
113
|
/**
|
|
@@ -148,7 +164,9 @@ export default asset;
|
|
|
148
164
|
)
|
|
149
165
|
|
|
150
166
|
res.statusCode =
|
|
151
|
-
e instanceof Error && (e as NodeJS.ErrnoException).code === 'ENOENT'
|
|
167
|
+
e instanceof Error && (e as NodeJS.ErrnoException).code === 'ENOENT'
|
|
168
|
+
? 404
|
|
169
|
+
: 500
|
|
152
170
|
res.end()
|
|
153
171
|
}
|
|
154
172
|
})
|
|
@@ -114,7 +114,9 @@ export function reactNativeHMRPlugin({
|
|
|
114
114
|
|
|
115
115
|
source = transformResult.code
|
|
116
116
|
} catch (e) {
|
|
117
|
-
console.warn(
|
|
117
|
+
console.warn(
|
|
118
|
+
`Error transforming source for HMR: ${e}. Retrying without plugins.`
|
|
119
|
+
)
|
|
118
120
|
source = (await transformSWCStripJSX(id, source))?.code || ''
|
|
119
121
|
}
|
|
120
122
|
|
|
@@ -155,11 +157,20 @@ export function reactNativeHMRPlugin({
|
|
|
155
157
|
const resolver: ResolveFn = idResolver.bind(null, environment)
|
|
156
158
|
const resolverWithPlugins: ResolveFn = async (id, importer) => {
|
|
157
159
|
// Need this since `idResolver` will not run through user plugins, but we might need plugins like `vite-tsconfig-paths` to work if they are used
|
|
158
|
-
const resolvedIdData = await environment.pluginContainer.resolveId(
|
|
160
|
+
const resolvedIdData = await environment.pluginContainer.resolveId(
|
|
161
|
+
id,
|
|
162
|
+
importer
|
|
163
|
+
)
|
|
159
164
|
return resolvedIdData?.id
|
|
160
165
|
}
|
|
161
166
|
|
|
162
|
-
let id = await getVitePath(
|
|
167
|
+
let id = await getVitePath(
|
|
168
|
+
entryRoot,
|
|
169
|
+
file,
|
|
170
|
+
importName,
|
|
171
|
+
resolver,
|
|
172
|
+
resolverWithPlugins
|
|
173
|
+
)
|
|
163
174
|
if (!id) {
|
|
164
175
|
console.warn('???')
|
|
165
176
|
continue
|
|
@@ -207,7 +218,10 @@ export function reactNativeHMRPlugin({
|
|
|
207
218
|
${source
|
|
208
219
|
.replace(`import.meta.hot.accept(() => {})`, ``)
|
|
209
220
|
// replace import.meta.glob with empty array in hot reloads
|
|
210
|
-
.replaceAll(
|
|
221
|
+
.replaceAll(
|
|
222
|
+
/import.meta.glob\(.*\)/gi,
|
|
223
|
+
`globalThis['__importMetaGlobbed'] || {}`
|
|
224
|
+
)};
|
|
211
225
|
return exports })({})`
|
|
212
226
|
|
|
213
227
|
if (process.env.DEBUG) {
|
|
@@ -20,7 +20,11 @@ describe('resolveId hooks should skip during dep optimization scan', () => {
|
|
|
20
20
|
|
|
21
21
|
// Find the platform-specific-resolve plugin
|
|
22
22
|
const plugin = plugins.find(
|
|
23
|
-
(p) =>
|
|
23
|
+
(p) =>
|
|
24
|
+
typeof p === 'object' &&
|
|
25
|
+
p !== null &&
|
|
26
|
+
'name' in p &&
|
|
27
|
+
p.name === 'platform-specific-resolve'
|
|
24
28
|
)
|
|
25
29
|
|
|
26
30
|
expect(plugin).toBeDefined()
|
|
@@ -37,12 +41,9 @@ describe('resolveId hooks should skip during dep optimization scan', () => {
|
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
// When scan is true, should return undefined (skip processing)
|
|
40
|
-
const result = await resolveId.call(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
'/importer.ts',
|
|
44
|
-
{ scan: true }
|
|
45
|
-
)
|
|
44
|
+
const result = await resolveId.call(mockContext, 'some-module', '/importer.ts', {
|
|
45
|
+
scan: true,
|
|
46
|
+
})
|
|
46
47
|
|
|
47
48
|
expect(result).toBeUndefined()
|
|
48
49
|
// Should NOT have called resolve when scan is true
|
|
@@ -4,7 +4,7 @@ export const rollupRemoveUnusedImportsPlugin = {
|
|
|
4
4
|
// Use a simple regex or AST parser to remove unused imports
|
|
5
5
|
// Here, we use a regex to remove all imports, adapt as needed
|
|
6
6
|
return {
|
|
7
|
-
code: code.replace(/import\s+['"][a-zA-Z0-
|
|
7
|
+
code: code.replace(/import\s+['"][a-zA-Z0-9_\-@]+['"];\n/g, ''),
|
|
8
8
|
map: null,
|
|
9
9
|
}
|
|
10
10
|
},
|
|
@@ -92,9 +92,7 @@ export async function buildBundle(
|
|
|
92
92
|
const optionsIn = {
|
|
93
93
|
root,
|
|
94
94
|
host: '0.0.0.0', // TODO: Hardcoded for now.
|
|
95
|
-
entries: {
|
|
96
|
-
...(nativeEntry ? { native: nativeEntry } : {}),
|
|
97
|
-
},
|
|
95
|
+
entries: nativeEntry ? { native: nativeEntry } : {},
|
|
98
96
|
}
|
|
99
97
|
|
|
100
98
|
const options = await fillOptions(optionsIn, { mode: dev ? 'dev' : 'prod' })
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { Hono } from 'hono'
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
OutputAsset,
|
|
4
|
+
OutputChunk,
|
|
5
|
+
TreeshakingOptions,
|
|
6
|
+
TreeshakingPreset,
|
|
7
|
+
} from 'rollup'
|
|
3
8
|
import type { FilterPattern, InlineConfig, UserConfig } from 'vite'
|
|
4
9
|
|
|
5
10
|
type RollupOutputList = [OutputChunk, ...(OutputChunk | OutputAsset)[]]
|
|
@@ -137,6 +142,12 @@ export type VXRNServeOptionsFilled = Required<VXRNServeOptionsBase> & {
|
|
|
137
142
|
|
|
138
143
|
export type VXRNServeOptions = VXRNServeOptionsBase & {
|
|
139
144
|
app?: Hono
|
|
140
|
-
beforeRegisterRoutes?: (
|
|
141
|
-
|
|
145
|
+
beforeRegisterRoutes?: (
|
|
146
|
+
options: VXRNServeOptionsFilled,
|
|
147
|
+
app: Hono
|
|
148
|
+
) => void | Promise<void>
|
|
149
|
+
afterRegisterRoutes?: (
|
|
150
|
+
options: VXRNServeOptionsFilled,
|
|
151
|
+
app: Hono
|
|
152
|
+
) => void | Promise<void>
|
|
142
153
|
}
|
|
@@ -132,7 +132,10 @@ export async function startUserInterface(context: Context) {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
function printCommandsTable(context: Context) {
|
|
135
|
-
const longestKeyLength = COMMANDS.reduce(
|
|
135
|
+
const longestKeyLength = COMMANDS.reduce(
|
|
136
|
+
(max, command) => Math.max(max, command.keys.length),
|
|
137
|
+
0
|
|
138
|
+
)
|
|
136
139
|
|
|
137
140
|
const commandsInfo = COMMANDS.map((cmd) =>
|
|
138
141
|
getCommandInfoInTerminal(cmd, { longestKeyLength })
|
|
@@ -214,12 +217,16 @@ function handleKeypress(context: Context, key: string) {
|
|
|
214
217
|
|
|
215
218
|
if (pressedKeys.length >= 3) {
|
|
216
219
|
clearPrintedInfo()
|
|
217
|
-
console.info(
|
|
220
|
+
console.info(
|
|
221
|
+
`> ${pressedKeys}\nNo matching command for "${pressedKeys}"! Press "?" for help.`
|
|
222
|
+
)
|
|
218
223
|
pressedKeys = ''
|
|
219
224
|
return
|
|
220
225
|
}
|
|
221
226
|
|
|
222
|
-
const possibleCommands = COMMANDS.filter((command) =>
|
|
227
|
+
const possibleCommands = COMMANDS.filter((command) =>
|
|
228
|
+
command.keys.startsWith(pressedKeys)
|
|
229
|
+
)
|
|
223
230
|
|
|
224
231
|
const commandsInfo = possibleCommands
|
|
225
232
|
.map((command) => {
|
|
@@ -260,7 +267,11 @@ async function printNativeQrCodeAndInstructions(url: string) {
|
|
|
260
267
|
|
|
261
268
|
function nativeOpen(url: string) {
|
|
262
269
|
const start =
|
|
263
|
-
process.platform === 'darwin'
|
|
270
|
+
process.platform === 'darwin'
|
|
271
|
+
? 'open'
|
|
272
|
+
: process.platform === 'win32'
|
|
273
|
+
? 'start'
|
|
274
|
+
: 'xdg-open'
|
|
264
275
|
|
|
265
276
|
exec(`${start} ${url}`)
|
|
266
277
|
}
|
|
@@ -310,7 +321,9 @@ async function openAndroid(ctx: Context) {
|
|
|
310
321
|
paths: [projectRoot],
|
|
311
322
|
}
|
|
312
323
|
)
|
|
313
|
-
const androidPlatformManagerModule = await import(
|
|
324
|
+
const androidPlatformManagerModule = await import(
|
|
325
|
+
androidPlatformManagerModuleImportPath
|
|
326
|
+
)
|
|
314
327
|
const PlatformManager = androidPlatformManagerModule.default.AndroidPlatformManager
|
|
315
328
|
|
|
316
329
|
// TODO: Support dev client
|
|
@@ -327,7 +340,9 @@ async function openAndroid(ctx: Context) {
|
|
|
327
340
|
await platformManager.openAsync({ runtime: 'expo' })
|
|
328
341
|
} catch (e) {
|
|
329
342
|
const stack = e instanceof Error ? e.stack : null
|
|
330
|
-
console.error(
|
|
343
|
+
console.error(
|
|
344
|
+
`Failed to open app in Android Emulator: ${e}${stack ? `\n${stack}` : ''}`
|
|
345
|
+
)
|
|
331
346
|
}
|
|
332
347
|
}
|
|
333
348
|
|
package/src/utils/expoRun.ts
CHANGED
|
@@ -6,7 +6,11 @@ export async function expoRun({
|
|
|
6
6
|
root,
|
|
7
7
|
platform,
|
|
8
8
|
port,
|
|
9
|
-
}: {
|
|
9
|
+
}: {
|
|
10
|
+
root: string
|
|
11
|
+
platform: 'ios' | 'android'
|
|
12
|
+
port?: number
|
|
13
|
+
}) {
|
|
10
14
|
const options = await fillOptions({ root })
|
|
11
15
|
|
|
12
16
|
applyBuiltInPatches(options).catch((err) => {
|
|
@@ -30,6 +34,8 @@ export async function expoRun({
|
|
|
30
34
|
// `${port || 8081}`,
|
|
31
35
|
])
|
|
32
36
|
} catch (e) {
|
|
33
|
-
console.error(
|
|
37
|
+
console.error(
|
|
38
|
+
`Failed to run native project: ${e}\nIs "expo" listed in your dependencies?`
|
|
39
|
+
)
|
|
34
40
|
}
|
|
35
41
|
}
|
|
@@ -7,7 +7,10 @@ import type { VXRNOptionsFilled } from '../config/getOptionsFilled'
|
|
|
7
7
|
import { getReactNativeBuildConfig } from '../config/getReactNativeBuildConfig'
|
|
8
8
|
import { filterPluginsForNative } from './filterPluginsForNative'
|
|
9
9
|
import { getCacheDir } from './getCacheDir'
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
isBuildingNativeBundle,
|
|
12
|
+
setIsBuildingNativeBundle,
|
|
13
|
+
} from './isBuildingNativeBundle'
|
|
11
14
|
import { prebuildReactNativeModules } from './swapPrebuiltReactModules'
|
|
12
15
|
|
|
13
16
|
// used for normalizing hot reloads
|
|
@@ -58,7 +61,9 @@ export async function getReactNativeBundle(
|
|
|
58
61
|
// build app
|
|
59
62
|
const nativeBuildConfig = await getReactNativeBuildConfig(options, internal, platform)
|
|
60
63
|
|
|
61
|
-
nativeBuildConfig.plugins = filterPluginsForNative(nativeBuildConfig.plugins, {
|
|
64
|
+
nativeBuildConfig.plugins = filterPluginsForNative(nativeBuildConfig.plugins, {
|
|
65
|
+
isNative: true,
|
|
66
|
+
})
|
|
62
67
|
|
|
63
68
|
// instrument plugins:
|
|
64
69
|
const buildStats: Record<string, number> = {}
|
|
@@ -125,10 +130,8 @@ export async function getReactNativeBundle(
|
|
|
125
130
|
const importsMap = {}
|
|
126
131
|
for (const imp of outputModule.imports) {
|
|
127
132
|
const relativePath = relative(dirname(id), imp)
|
|
128
|
-
importsMap[relativePath[0] === '.' ? relativePath : './' + relativePath] =
|
|
129
|
-
/.*node_modules\//,
|
|
130
|
-
''
|
|
131
|
-
)
|
|
133
|
+
importsMap[relativePath[0] === '.' ? relativePath : './' + relativePath] =
|
|
134
|
+
imp.replace(/.*node_modules\//, '')
|
|
132
135
|
}
|
|
133
136
|
|
|
134
137
|
let code = outputModule.code
|
|
@@ -222,7 +225,10 @@ async function getReactNativeTemplate(mode: 'dev' | 'prod') {
|
|
|
222
225
|
template = template.replace(/process\.env\.DEBUG/g, 'undefined')
|
|
223
226
|
|
|
224
227
|
// In production mode, the prebuilt modules have `.production` in their filenames
|
|
225
|
-
template = template.replaceAll(
|
|
228
|
+
template = template.replaceAll(
|
|
229
|
+
'.vxrn/react-jsx-runtime.js',
|
|
230
|
+
'.vxrn/react-jsx-runtime.production.js'
|
|
231
|
+
)
|
|
226
232
|
template = template.replaceAll('.vxrn/react.js', '.vxrn/react.production.js')
|
|
227
233
|
// react-native already has platform in filename, need to add .production before platform
|
|
228
234
|
template = template.replace(
|
package/src/utils/getVitePath.ts
CHANGED
|
@@ -7,7 +7,10 @@ export async function getVitePath(
|
|
|
7
7
|
importer: string,
|
|
8
8
|
moduleName: string,
|
|
9
9
|
resolver: (moduleName: string, importer: string) => Promise<string | undefined>,
|
|
10
|
-
resolverWithPlugins: (
|
|
10
|
+
resolverWithPlugins: (
|
|
11
|
+
moduleName: string,
|
|
12
|
+
importer: string
|
|
13
|
+
) => Promise<string | undefined>,
|
|
11
14
|
absolute = false
|
|
12
15
|
) {
|
|
13
16
|
// our virtual modules
|