vxrn 1.1.134 → 1.1.136
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/.depcheckrc +1 -1
- package/dist/cjs/exports/dev.js +2 -7
- package/dist/cjs/exports/dev.js.map +1 -1
- package/dist/cjs/exports/dev.native.js +2 -22
- package/dist/cjs/exports/dev.native.js.map +2 -2
- package/dist/cjs/plugins/expoManifestRequestHandlerPlugin.js +123 -0
- package/dist/cjs/plugins/expoManifestRequestHandlerPlugin.js.map +6 -0
- package/dist/cjs/plugins/expoManifestRequestHandlerPlugin.native.js +311 -0
- package/dist/cjs/plugins/expoManifestRequestHandlerPlugin.native.js.map +6 -0
- package/dist/cjs/plugins/fixDependenciesPlugin.js +35 -0
- package/dist/cjs/plugins/fixDependenciesPlugin.js.map +6 -0
- package/dist/cjs/plugins/fixDependenciesPlugin.native.js +40 -0
- package/dist/cjs/plugins/fixDependenciesPlugin.native.js.map +6 -0
- package/dist/cjs/utils/getBaseViteConfig.js +2 -1
- package/dist/cjs/utils/getBaseViteConfig.js.map +1 -1
- package/dist/cjs/utils/getBaseViteConfig.native.js +2 -1
- package/dist/cjs/utils/getBaseViteConfig.native.js.map +1 -1
- package/dist/cjs/utils/getReactNativeBundle.js +1 -15
- package/dist/cjs/utils/getReactNativeBundle.js.map +1 -1
- package/dist/cjs/utils/getReactNativeBundle.native.js +1 -31
- package/dist/cjs/utils/getReactNativeBundle.native.js.map +2 -2
- package/dist/cjs/utils/getReactNativeConfig.js.map +1 -1
- package/dist/cjs/utils/getReactNativeConfig.native.js.map +1 -1
- package/dist/cjs/utils/getViteServerConfig.js +8 -6
- package/dist/cjs/utils/getViteServerConfig.js.map +1 -1
- package/dist/cjs/utils/getViteServerConfig.native.js +12 -24
- package/dist/cjs/utils/getViteServerConfig.native.js.map +2 -2
- package/dist/cjs/utils/patches.js +8 -0
- package/dist/cjs/utils/patches.js.map +1 -1
- package/dist/cjs/utils/patches.native.js +4 -0
- package/dist/cjs/utils/patches.native.js.map +1 -1
- package/dist/cjs/utils/prependMiddleware.js +23 -0
- package/dist/cjs/utils/prependMiddleware.js.map +6 -0
- package/dist/cjs/utils/prependMiddleware.native.js +28 -0
- package/dist/cjs/utils/prependMiddleware.native.js.map +6 -0
- package/dist/esm/exports/dev.js +1 -7
- package/dist/esm/exports/dev.js.map +1 -1
- package/dist/esm/exports/dev.mjs +1 -11
- package/dist/esm/exports/dev.native.js +1 -22
- package/dist/esm/exports/dev.native.js.map +2 -2
- package/dist/esm/plugins/expoManifestRequestHandlerPlugin.js +101 -0
- package/dist/esm/plugins/expoManifestRequestHandlerPlugin.js.map +6 -0
- package/dist/esm/plugins/expoManifestRequestHandlerPlugin.mjs +111 -0
- package/dist/esm/plugins/expoManifestRequestHandlerPlugin.native.js +284 -0
- package/dist/esm/plugins/expoManifestRequestHandlerPlugin.native.js.map +6 -0
- package/dist/esm/plugins/fixDependenciesPlugin.js +19 -0
- package/dist/esm/plugins/fixDependenciesPlugin.js.map +6 -0
- package/dist/esm/plugins/fixDependenciesPlugin.mjs +16 -0
- package/dist/esm/plugins/fixDependenciesPlugin.native.js +19 -0
- package/dist/esm/plugins/fixDependenciesPlugin.native.js.map +6 -0
- package/dist/esm/utils/getBaseViteConfig.js +2 -1
- package/dist/esm/utils/getBaseViteConfig.js.map +1 -1
- package/dist/esm/utils/getBaseViteConfig.mjs +1 -1
- package/dist/esm/utils/getBaseViteConfig.native.js +2 -1
- package/dist/esm/utils/getBaseViteConfig.native.js.map +1 -1
- package/dist/esm/utils/getReactNativeBundle.js +0 -15
- package/dist/esm/utils/getReactNativeBundle.js.map +1 -1
- package/dist/esm/utils/getReactNativeBundle.mjs +0 -11
- package/dist/esm/utils/getReactNativeBundle.native.js +0 -31
- package/dist/esm/utils/getReactNativeBundle.native.js.map +2 -2
- package/dist/esm/utils/getViteServerConfig.js +8 -5
- package/dist/esm/utils/getViteServerConfig.js.map +1 -1
- package/dist/esm/utils/getViteServerConfig.mjs +10 -6
- package/dist/esm/utils/getViteServerConfig.native.js +12 -23
- package/dist/esm/utils/getViteServerConfig.native.js.map +2 -2
- package/dist/esm/utils/patches.js +8 -0
- package/dist/esm/utils/patches.js.map +1 -1
- package/dist/esm/utils/patches.mjs +9 -1
- package/dist/esm/utils/patches.native.js +4 -0
- package/dist/esm/utils/patches.native.js.map +1 -1
- package/dist/esm/utils/prependMiddleware.js +7 -0
- package/dist/esm/utils/prependMiddleware.js.map +6 -0
- package/dist/esm/utils/prependMiddleware.mjs +4 -0
- package/dist/esm/utils/prependMiddleware.native.js +7 -0
- package/dist/esm/utils/prependMiddleware.native.js.map +6 -0
- package/package.json +5 -5
- package/patches/h3+1.11.1.patch +19 -0
- package/src/exports/dev.ts +3 -18
- package/src/plugins/expoManifestRequestHandlerPlugin.ts +162 -0
- package/src/plugins/fixDependenciesPlugin.ts +24 -0
- package/src/utils/getBaseViteConfig.ts +3 -1
- package/src/utils/getReactNativeBundle.ts +0 -16
- package/src/utils/getReactNativeConfig.ts +1 -1
- package/src/utils/getViteServerConfig.ts +8 -6
- package/src/utils/patches.ts +9 -0
- package/src/utils/prependMiddleware.ts +14 -0
- package/types/plugins/expoManifestRequestHandlerPlugin.d.ts +12 -0
- package/types/plugins/fixDependenciesPlugin.d.ts +6 -0
- package/types/utils/prependMiddleware.d.ts +10 -0
- package/src/utils/getIndexJsonResponse.ts +0 -52
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vxrn",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.136",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"@babel/core": "^7.21.8",
|
|
36
36
|
"@hono/node-server": "^1.11.1",
|
|
37
37
|
"@vitejs/plugin-react-swc": "^3.6.0",
|
|
38
|
-
"@vxrn/react-native-prebuilt": "1.1.
|
|
39
|
-
"@vxrn/safe-area": "1.1.
|
|
40
|
-
"@vxrn/vite-flow": "1.1.
|
|
41
|
-
"@vxrn/vite-native-swc": "1.1.
|
|
38
|
+
"@vxrn/react-native-prebuilt": "1.1.136",
|
|
39
|
+
"@vxrn/safe-area": "1.1.136",
|
|
40
|
+
"@vxrn/vite-flow": "1.1.136",
|
|
41
|
+
"@vxrn/vite-native-swc": "1.1.136",
|
|
42
42
|
"citty": "^0.1.6",
|
|
43
43
|
"crossws": "^0.2.4",
|
|
44
44
|
"es-module-lexer": "^1.3.0",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
diff --git a/node_modules/h3/dist/index.mjs b/node_modules/h3/dist/index.mjs
|
|
2
|
+
index 16294ff..03b54b9 100644
|
|
3
|
+
--- a/node_modules/h3/dist/index.mjs
|
|
4
|
+
+++ b/node_modules/h3/dist/index.mjs
|
|
5
|
+
@@ -1229,6 +1229,14 @@ function getProxyRequestHeaders(event) {
|
|
6
|
+
headers[name] = reqHeaders[name];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
+
|
|
10
|
+
+ // The expoManifestRequestHandlerPlugin (Vite plugin) needs the original request host so that it can compose URLs that can be accessed by physical devices. This won't be needed once we retire h3 and use the Vite Dev Server directly.
|
|
11
|
+
+ // This may not work if one installed vxrn from NPM since this patch may not apply.
|
|
12
|
+
+ const originalHost = reqHeaders.host;
|
|
13
|
+
+ if (originalHost) {
|
|
14
|
+
+ headers['X-Forwarded-Host'] = originalHost;
|
|
15
|
+
+ }
|
|
16
|
+
+
|
|
17
|
+
return headers;
|
|
18
|
+
}
|
|
19
|
+
function fetchWithEvent(event, req, init, options) {
|
package/src/exports/dev.ts
CHANGED
|
@@ -10,9 +10,7 @@ import {
|
|
|
10
10
|
toNodeListener,
|
|
11
11
|
} from 'h3'
|
|
12
12
|
import { createProxyEventHandler } from 'h3-proxy'
|
|
13
|
-
import { rm } from 'node:fs/promises'
|
|
14
13
|
import { createServer as nodeCreateServer } from 'node:http'
|
|
15
|
-
import { join } from 'node:path'
|
|
16
14
|
import { createServer, resolveConfig } from 'vite'
|
|
17
15
|
import { WebSocket } from 'ws'
|
|
18
16
|
import { clientInjectionsPlugin } from '../plugins/clientInjectPlugin'
|
|
@@ -22,13 +20,13 @@ import {
|
|
|
22
20
|
addConnectedNativeClient,
|
|
23
21
|
removeConnectedNativeClient,
|
|
24
22
|
} from '../utils/connectedNativeClients'
|
|
25
|
-
import { getIndexJsonResponse } from '../utils/getIndexJsonResponse'
|
|
26
23
|
import { getOptionsFilled } from '../utils/getOptionsFilled'
|
|
27
24
|
import { getReactNativeBundle } from '../utils/getReactNativeBundle'
|
|
28
25
|
import { getViteServerConfig } from '../utils/getViteServerConfig'
|
|
29
26
|
import { hotUpdateCache } from '../utils/hotUpdateCache'
|
|
30
27
|
import { checkPatches } from '../utils/patches'
|
|
31
28
|
import { clean } from './clean'
|
|
29
|
+
import { TLSSocket } from 'node:tls'
|
|
32
30
|
|
|
33
31
|
const { ensureDir } = FSExtra
|
|
34
32
|
|
|
@@ -64,10 +62,12 @@ export const dev = async (optionsIn: VXRNOptions & { clean?: boolean }) => {
|
|
|
64
62
|
const viteServer = await createServer(serverConfig)
|
|
65
63
|
|
|
66
64
|
// first resolve config so we can pass into client plugin, then add client plugin:
|
|
65
|
+
// TODO do we need this really? seems like we don't, can check if we can do this without the resolveConfig()
|
|
67
66
|
const resolvedConfig = await resolveConfig(serverConfig, 'serve')
|
|
68
67
|
const viteRNClientPlugin = clientInjectionsPlugin(resolvedConfig)
|
|
69
68
|
|
|
70
69
|
// this fakes vite into thinking its loading files, so it hmrs in native mode despite not us never requesting the url
|
|
70
|
+
// TODO we can check if any native clients are connected to avoid some work here
|
|
71
71
|
viteServer.watcher.addListener('change', async (path) => {
|
|
72
72
|
const id = path.replace(process.cwd(), '')
|
|
73
73
|
if (!id.endsWith('tsx') && !id.endsWith('jsx')) {
|
|
@@ -139,21 +139,6 @@ export const dev = async (optionsIn: VXRNOptions & { clean?: boolean }) => {
|
|
|
139
139
|
|
|
140
140
|
app.use(router)
|
|
141
141
|
|
|
142
|
-
// TODO move these to router.get():
|
|
143
|
-
app.use(
|
|
144
|
-
defineEventHandler(async ({ node: { req } }) => {
|
|
145
|
-
if (!req.headers['expo-platform']) {
|
|
146
|
-
if (!req.headers['user-agent']?.match(/Expo|React/)) {
|
|
147
|
-
return
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (req.url === '/' || req.url?.startsWith('/?platform=')) {
|
|
152
|
-
return getIndexJsonResponse({ port, root })
|
|
153
|
-
}
|
|
154
|
-
})
|
|
155
|
-
)
|
|
156
|
-
|
|
157
142
|
const clients = new Set<Peer>()
|
|
158
143
|
let socket: WebSocket | null = null
|
|
159
144
|
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { join } from 'node:path'
|
|
2
|
+
import module from 'node:module'
|
|
3
|
+
import { TLSSocket } from 'node:tls'
|
|
4
|
+
|
|
5
|
+
import type { Plugin } from 'vite'
|
|
6
|
+
|
|
7
|
+
// Can support more [options](https://github.com/expo/expo/blob/sdk-50/packages/%40expo/cli/src/start/server/middleware/ManifestMiddleware.ts#L113-L121) in the future.
|
|
8
|
+
type ExpoManifestRequestHandlerPluginConfig = {
|
|
9
|
+
/** The root of the Expo project. */
|
|
10
|
+
projectRoot: string
|
|
11
|
+
port: number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Let the Vite dev server support handling [Expo Manifest Request](https://github.com/expo/expo/blob/sdk-50/docs/pages/archive/technical-specs/expo-updates-0.mdx#manifest-request), which is required for Expo Go to work.
|
|
16
|
+
*/
|
|
17
|
+
export function expoManifestRequestHandlerPlugin(
|
|
18
|
+
options: ExpoManifestRequestHandlerPluginConfig
|
|
19
|
+
): Plugin {
|
|
20
|
+
const { projectRoot } = options
|
|
21
|
+
return {
|
|
22
|
+
name: 'vxrn:expo-manifest-request-handler',
|
|
23
|
+
|
|
24
|
+
configureServer(server) {
|
|
25
|
+
// Add a middleware to Vite's internal Connect server to handle the Expo Manifest Request.
|
|
26
|
+
server.middlewares.use(async (req, res, next) => {
|
|
27
|
+
if (!req.headers['expo-platform']) {
|
|
28
|
+
// Not an Expo manifest request, skip this middleware and proceed.
|
|
29
|
+
return next()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const protocol = req.socket instanceof TLSSocket && req.socket.encrypted ? 'https' : 'http'
|
|
33
|
+
const host = `${req.headers['x-forwarded-host']}` || req.headers.host
|
|
34
|
+
|
|
35
|
+
// Try to dynamically import the internal Expo manifest handler from expo packages installed in the user's project.
|
|
36
|
+
let ExpoGoManifestHandlerMiddleware
|
|
37
|
+
let expoGoManifestHandlerMiddlewareImportError
|
|
38
|
+
try {
|
|
39
|
+
// Import Expo from the user's project instead of from where vxrn is installed, since vxrn may be installed globally or at the root workspace.
|
|
40
|
+
const require = module.createRequire(projectRoot)
|
|
41
|
+
const importPath = require.resolve(
|
|
42
|
+
'@expo/cli/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js',
|
|
43
|
+
{ paths: [projectRoot] }
|
|
44
|
+
)
|
|
45
|
+
ExpoGoManifestHandlerMiddleware = (await import(importPath)).default
|
|
46
|
+
.ExpoGoManifestHandlerMiddleware
|
|
47
|
+
} catch (e) {
|
|
48
|
+
expoGoManifestHandlerMiddlewareImportError = e
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// If we failed to import the Expo manifest handler, show a warning and ignore the error.
|
|
52
|
+
if (!ExpoGoManifestHandlerMiddleware) {
|
|
53
|
+
if (
|
|
54
|
+
expoGoManifestHandlerMiddlewareImportError instanceof Error &&
|
|
55
|
+
(expoGoManifestHandlerMiddlewareImportError as any).code === 'MODULE_NOT_FOUND'
|
|
56
|
+
) {
|
|
57
|
+
console.warn(
|
|
58
|
+
`Failed to locate Expo SDK in your project: ${expoGoManifestHandlerMiddlewareImportError}`
|
|
59
|
+
)
|
|
60
|
+
} else {
|
|
61
|
+
console.warn(
|
|
62
|
+
`Failed to import Expo SDK from your project: ${expoGoManifestHandlerMiddlewareImportError}`
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
console.warn(
|
|
67
|
+
'Ignoring the error and proceeding without handling the Expo manifest request.'
|
|
68
|
+
)
|
|
69
|
+
console.warn(
|
|
70
|
+
`Is this a Expo project, or are you using a supported version of Expo SDK? (${projectRoot})`
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
const json = getIndexJsonResponse(options)
|
|
74
|
+
|
|
75
|
+
res.setHeader('content-type', 'application/json')
|
|
76
|
+
res.write(JSON.stringify(json))
|
|
77
|
+
res.end()
|
|
78
|
+
|
|
79
|
+
// fallback to our preset index json for now
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const manifestHandlerMiddleware = new ExpoGoManifestHandlerMiddleware(projectRoot, {
|
|
84
|
+
constructUrl: () => {
|
|
85
|
+
return `${protocol}://${host}`
|
|
86
|
+
},
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
// Override the `_getBundleUrl` method ensure the same host and protocol are used for the bundle URL.
|
|
90
|
+
const origGetBundleUrl =
|
|
91
|
+
manifestHandlerMiddleware._getBundleUrl.bind(manifestHandlerMiddleware)
|
|
92
|
+
manifestHandlerMiddleware._getBundleUrl = (...args) => {
|
|
93
|
+
/** 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`. */
|
|
94
|
+
const origBundleUrl = origGetBundleUrl(...args)
|
|
95
|
+
|
|
96
|
+
let url = new URL(origBundleUrl)
|
|
97
|
+
if (host) url.host = host
|
|
98
|
+
url.protocol = protocol
|
|
99
|
+
|
|
100
|
+
// For now, vxrn will always serve the React Native bundle at `/index.bundle`, while Expo may use something like `/src/App.tsx.bundle`.
|
|
101
|
+
url.pathname = '/index.bundle'
|
|
102
|
+
|
|
103
|
+
return url.toString()
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Handle the Expo manifest request.
|
|
107
|
+
manifestHandlerMiddleware.handleRequestAsync(req, res, next)
|
|
108
|
+
})
|
|
109
|
+
},
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function getIndexJsonResponse({ port, projectRoot }: ExpoManifestRequestHandlerPluginConfig) {
|
|
114
|
+
return {
|
|
115
|
+
name: 'myapp',
|
|
116
|
+
slug: 'myapp',
|
|
117
|
+
scheme: 'myapp',
|
|
118
|
+
version: '1.0.0',
|
|
119
|
+
jsEngine: 'jsc',
|
|
120
|
+
orientation: 'portrait',
|
|
121
|
+
icon: './assets/icon.png',
|
|
122
|
+
userInterfaceStyle: 'light',
|
|
123
|
+
splash: {
|
|
124
|
+
image: './assets/splash.png',
|
|
125
|
+
resizeMode: 'contain',
|
|
126
|
+
backgroundColor: '#ffffff',
|
|
127
|
+
imageUrl: 'http://127.0.0.1:8081/assets/./assets/splash.png',
|
|
128
|
+
},
|
|
129
|
+
updates: { fallbackToCacheTimeout: 0 },
|
|
130
|
+
assetBundlePatterns: ['**/*'],
|
|
131
|
+
ios: { supportsTablet: true, bundleIdentifier: 'com.natew.myapp' },
|
|
132
|
+
android: {
|
|
133
|
+
package: 'com.tamagui.myapp',
|
|
134
|
+
adaptiveIcon: {
|
|
135
|
+
foregroundImage: './assets/adaptive-icon.png',
|
|
136
|
+
backgroundColor: '#FFFFFF',
|
|
137
|
+
foregroundImageUrl: 'http://127.0.0.1:8081/assets/./assets/adaptive-icon.png',
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
web: { favicon: './assets/favicon.png' },
|
|
141
|
+
extra: { eas: { projectId: '061b4470-78c7-4d6a-b850-8167fb0a3434' } },
|
|
142
|
+
_internal: {
|
|
143
|
+
isDebug: false,
|
|
144
|
+
projectRoot: projectRoot,
|
|
145
|
+
dynamicConfigPath: null,
|
|
146
|
+
staticConfigPath: join(projectRoot, 'app.json'),
|
|
147
|
+
packageJsonPath: join(projectRoot, 'package.json'),
|
|
148
|
+
},
|
|
149
|
+
sdkVersion: '50.0.0',
|
|
150
|
+
platforms: ['ios', 'android', 'web'],
|
|
151
|
+
iconUrl: `http://127.0.0.1:${port}/assets/./assets/icon.png`,
|
|
152
|
+
debuggerHost: `127.0.0.1:${port}`,
|
|
153
|
+
logUrl: `http://127.0.0.1:${port}/logs`,
|
|
154
|
+
developer: { tool: 'expo-cli', projectRoot: projectRoot },
|
|
155
|
+
packagerOpts: { dev: true },
|
|
156
|
+
mainModuleName: 'index',
|
|
157
|
+
__flipperHack: 'React Native packager is running',
|
|
158
|
+
hostUri: `127.0.0.1:${port}`,
|
|
159
|
+
bundleUrl: `http://127.0.0.1:${port}/index.bundle?platform=ios&dev=true&hot=false&lazy=true`,
|
|
160
|
+
id: '@anonymous/myapp-473c4543-3c36-4786-9db1-c66a62ac9b78',
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Plugin } from 'vite'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Some fixes for known bad dependencies with Vite
|
|
5
|
+
*/
|
|
6
|
+
export function fixDependenciesPlugin(): Plugin {
|
|
7
|
+
// uh this isn't runnning at all?
|
|
8
|
+
return {
|
|
9
|
+
name: 'vxrn:fix-dependencies-plugin',
|
|
10
|
+
enforce: 'pre',
|
|
11
|
+
|
|
12
|
+
resolveId(source, importer, options) {
|
|
13
|
+
console.log('resolve', source, importer)
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
load(id) {
|
|
17
|
+
console.log('load', id)
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
transform(code, id) {
|
|
21
|
+
console.log('go?', id)
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import reactSwcPlugin from '@vitejs/plugin-react-swc'
|
|
2
|
-
import type { InlineConfig
|
|
2
|
+
import type { InlineConfig } from 'vite'
|
|
3
|
+
import { fixDependenciesPlugin } from '../plugins/fixDependenciesPlugin'
|
|
3
4
|
|
|
4
5
|
// essentially base web config not base everything
|
|
5
6
|
|
|
@@ -12,6 +13,7 @@ export const dedupe = [
|
|
|
12
13
|
'react-native-web',
|
|
13
14
|
'@tamagui/core',
|
|
14
15
|
'@tamagui/web',
|
|
16
|
+
'react-native-reanimated',
|
|
15
17
|
]
|
|
16
18
|
|
|
17
19
|
export function getBaseViteConfig({ mode }: { mode: 'development' | 'production' }): InlineConfig {
|
|
@@ -38,22 +38,6 @@ export async function getReactNativeBundle(options: VXRNOptionsFilled, viteRNCli
|
|
|
38
38
|
})
|
|
39
39
|
)
|
|
40
40
|
|
|
41
|
-
async function babelReanimated(input: string, filename: string) {
|
|
42
|
-
return await new Promise<string>((res, rej) => {
|
|
43
|
-
babel.transform(
|
|
44
|
-
input,
|
|
45
|
-
{
|
|
46
|
-
plugins: ['react-native-reanimated/plugin'],
|
|
47
|
-
filename,
|
|
48
|
-
},
|
|
49
|
-
(err: any, result) => {
|
|
50
|
-
if (!result || err) rej(err || 'no res')
|
|
51
|
-
res(result!.code!)
|
|
52
|
-
}
|
|
53
|
-
)
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
|
|
57
41
|
// build app
|
|
58
42
|
const nativeBuildConfig = await getReactNativeConfig(options, viteRNClientPlugin)
|
|
59
43
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { loadConfigFromFile, mergeConfig, type InlineConfig, type UserConfig } from 'vite'
|
|
2
2
|
import { reactNativeHMRPlugin } from '../plugins/reactNativeHMRPlugin'
|
|
3
|
+
import { expoManifestRequestHandlerPlugin } from '../plugins/expoManifestRequestHandlerPlugin'
|
|
3
4
|
import { coerceToArray } from './coerceToArray'
|
|
4
5
|
import { getBaseViteConfig } from './getBaseViteConfig'
|
|
5
6
|
import { getOptimizeDeps } from './getOptimizeDeps'
|
|
@@ -8,7 +9,7 @@ import { uniq } from './uniq'
|
|
|
8
9
|
import mkcert from 'vite-plugin-mkcert'
|
|
9
10
|
|
|
10
11
|
export async function getViteServerConfig(config: VXRNOptionsFilled) {
|
|
11
|
-
const { root, host, https } = config
|
|
12
|
+
const { root, host, https, port } = config
|
|
12
13
|
const { optimizeDeps } = getOptimizeDeps('serve')
|
|
13
14
|
const { config: userViteConfig } =
|
|
14
15
|
(await loadConfigFromFile({
|
|
@@ -30,6 +31,12 @@ export async function getViteServerConfig(config: VXRNOptionsFilled) {
|
|
|
30
31
|
|
|
31
32
|
reactNativeHMRPlugin(config),
|
|
32
33
|
|
|
34
|
+
expoManifestRequestHandlerPlugin({
|
|
35
|
+
projectRoot: root,
|
|
36
|
+
port,
|
|
37
|
+
}),
|
|
38
|
+
|
|
39
|
+
// TODO very hacky/arbitrary
|
|
33
40
|
{
|
|
34
41
|
name: 'process-env-ssr',
|
|
35
42
|
transform(code, id, options) {
|
|
@@ -112,10 +119,5 @@ export async function getViteServerConfig(config: VXRNOptionsFilled) {
|
|
|
112
119
|
console.debug('merged config is', JSON.stringify(serverConfig, null, 2))
|
|
113
120
|
}
|
|
114
121
|
|
|
115
|
-
serverConfig = {
|
|
116
|
-
...serverConfig,
|
|
117
|
-
plugins: [...serverConfig.plugins!],
|
|
118
|
-
}
|
|
119
|
-
|
|
120
122
|
return serverConfig
|
|
121
123
|
}
|
package/src/utils/patches.ts
CHANGED
|
@@ -8,7 +8,16 @@ const patches = [
|
|
|
8
8
|
module: 'react-native-screens',
|
|
9
9
|
patchFile: 'react-native-screens+3.22.1.patch',
|
|
10
10
|
},
|
|
11
|
+
{
|
|
12
|
+
module: 'h3',
|
|
13
|
+
patchFile: 'h3+1.11.1.patch',
|
|
14
|
+
},
|
|
15
|
+
// {
|
|
16
|
+
// module: 'react-native-reanimated',
|
|
17
|
+
// patchFile: 'react-native-reanimated+3.14.0.patch',
|
|
18
|
+
// },
|
|
11
19
|
]
|
|
20
|
+
|
|
12
21
|
type Patch = (typeof patches)[0]
|
|
13
22
|
|
|
14
23
|
export async function checkPatches(options: VXRNOptionsFilled) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Connect } from 'vite'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Prepends a middleware to a Connect server's middleware stack.
|
|
5
|
+
*/
|
|
6
|
+
export function prependMiddleware(
|
|
7
|
+
/** The Connect app server instance to prepend the middleware to. */
|
|
8
|
+
connectServer: Connect.Server,
|
|
9
|
+
/** The middleware to prepend. */
|
|
10
|
+
middleware: Connect.NextHandleFunction
|
|
11
|
+
) {
|
|
12
|
+
connectServer.use(middleware);
|
|
13
|
+
connectServer.stack.unshift(connectServer.stack.pop()!);
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
type ExpoManifestRequestHandlerPluginConfig = {
|
|
3
|
+
/** The root of the Expo project. */
|
|
4
|
+
projectRoot: string;
|
|
5
|
+
port: number;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Let the Vite dev server support handling [Expo Manifest Request](https://github.com/expo/expo/blob/sdk-50/docs/pages/archive/technical-specs/expo-updates-0.mdx#manifest-request), which is required for Expo Go to work.
|
|
9
|
+
*/
|
|
10
|
+
export declare function expoManifestRequestHandlerPlugin(options: ExpoManifestRequestHandlerPluginConfig): Plugin;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=expoManifestRequestHandlerPlugin.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Connect } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Prepends a middleware to a Connect server's middleware stack.
|
|
4
|
+
*/
|
|
5
|
+
export declare function prependMiddleware(
|
|
6
|
+
/** The Connect app server instance to prepend the middleware to. */
|
|
7
|
+
connectServer: Connect.Server,
|
|
8
|
+
/** The middleware to prepend. */
|
|
9
|
+
middleware: Connect.NextHandleFunction): void;
|
|
10
|
+
//# sourceMappingURL=prependMiddleware.d.ts.map
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path'
|
|
2
|
-
|
|
3
|
-
export function getIndexJsonResponse({ port, root }: { port: number | string; root }) {
|
|
4
|
-
return {
|
|
5
|
-
name: 'myapp',
|
|
6
|
-
slug: 'myapp',
|
|
7
|
-
scheme: 'myapp',
|
|
8
|
-
version: '1.0.0',
|
|
9
|
-
jsEngine: 'jsc',
|
|
10
|
-
orientation: 'portrait',
|
|
11
|
-
icon: './assets/icon.png',
|
|
12
|
-
userInterfaceStyle: 'light',
|
|
13
|
-
splash: {
|
|
14
|
-
image: './assets/splash.png',
|
|
15
|
-
resizeMode: 'contain',
|
|
16
|
-
backgroundColor: '#ffffff',
|
|
17
|
-
imageUrl: 'http://127.0.0.1:8081/assets/./assets/splash.png',
|
|
18
|
-
},
|
|
19
|
-
updates: { fallbackToCacheTimeout: 0 },
|
|
20
|
-
assetBundlePatterns: ['**/*'],
|
|
21
|
-
ios: { supportsTablet: true, bundleIdentifier: 'com.natew.myapp' },
|
|
22
|
-
android: {
|
|
23
|
-
package: 'com.tamagui.myapp',
|
|
24
|
-
adaptiveIcon: {
|
|
25
|
-
foregroundImage: './assets/adaptive-icon.png',
|
|
26
|
-
backgroundColor: '#FFFFFF',
|
|
27
|
-
foregroundImageUrl: 'http://127.0.0.1:8081/assets/./assets/adaptive-icon.png',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
web: { favicon: './assets/favicon.png' },
|
|
31
|
-
extra: { eas: { projectId: '061b4470-78c7-4d6a-b850-8167fb0a3434' } },
|
|
32
|
-
_internal: {
|
|
33
|
-
isDebug: false,
|
|
34
|
-
projectRoot: root,
|
|
35
|
-
dynamicConfigPath: null,
|
|
36
|
-
staticConfigPath: join(root, 'app.json'),
|
|
37
|
-
packageJsonPath: join(root, 'package.json'),
|
|
38
|
-
},
|
|
39
|
-
sdkVersion: '50.0.0',
|
|
40
|
-
platforms: ['ios', 'android', 'web'],
|
|
41
|
-
iconUrl: `http://127.0.0.1:${port}/assets/./assets/icon.png`,
|
|
42
|
-
debuggerHost: `127.0.0.1:${port}`,
|
|
43
|
-
logUrl: `http://127.0.0.1:${port}/logs`,
|
|
44
|
-
developer: { tool: 'expo-cli', projectRoot: root },
|
|
45
|
-
packagerOpts: { dev: true },
|
|
46
|
-
mainModuleName: 'index',
|
|
47
|
-
__flipperHack: 'React Native packager is running',
|
|
48
|
-
hostUri: `127.0.0.1:${port}`,
|
|
49
|
-
bundleUrl: `http://127.0.0.1:${port}/index.bundle?platform=ios&dev=true&hot=false&lazy=true`,
|
|
50
|
-
id: '@anonymous/myapp-473c4543-3c36-4786-9db1-c66a62ac9b78',
|
|
51
|
-
}
|
|
52
|
-
}
|