vxrn 0.1.19 → 0.1.21
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/cjs/build.js +57 -8
- package/dist/cjs/build.js.map +2 -2
- package/dist/cjs/build.native.js +180 -8
- package/dist/cjs/build.native.js.map +2 -2
- package/dist/cjs/cli.js +77 -3
- package/dist/cjs/cli.js.map +2 -2
- package/dist/cjs/cli.native.js +268 -2
- package/dist/cjs/cli.native.js.map +2 -2
- package/dist/cjs/constants.js +21 -0
- package/dist/cjs/constants.js.map +6 -0
- package/dist/cjs/constants.native.js +26 -0
- package/dist/cjs/constants.native.js.map +6 -0
- package/dist/cjs/createDevServer.js +9 -10
- package/dist/cjs/createDevServer.js.map +1 -1
- package/dist/cjs/createDevServer.native.js +9 -11
- package/dist/cjs/createDevServer.native.js.map +2 -2
- package/dist/cjs/createExpoServer.js +34 -0
- package/dist/cjs/createExpoServer.js.map +6 -0
- package/dist/cjs/createExpoServer.native.js +42 -0
- package/dist/cjs/createExpoServer.native.js.map +6 -0
- package/dist/cjs/{getBaseViteConfig.js → dispose.js} +12 -24
- package/dist/cjs/dispose.js.map +6 -0
- package/dist/cjs/{getBaseViteConfig.native.js → dispose.native.js} +16 -26
- package/dist/cjs/dispose.native.js.map +6 -0
- package/dist/cjs/exports/build.js +145 -0
- package/dist/cjs/exports/build.js.map +6 -0
- package/dist/cjs/exports/build.native.js +409 -0
- package/dist/cjs/exports/build.native.js.map +6 -0
- package/dist/cjs/exports/checkPatches.js +62 -0
- package/dist/cjs/exports/checkPatches.js.map +6 -0
- package/dist/cjs/{getOptionsFIlled.native.js → exports/checkPatches.native.js} +106 -124
- package/dist/cjs/exports/checkPatches.native.js.map +6 -0
- package/dist/cjs/{create.js → exports/dev.js} +90 -168
- package/dist/cjs/exports/dev.js.map +6 -0
- package/dist/cjs/{create.native.js → exports/dev.native.js} +148 -357
- package/dist/cjs/exports/dev.native.js.map +6 -0
- package/dist/cjs/{dev/bindKeypressInput.js → exports/serve.js} +31 -40
- package/dist/cjs/exports/serve.js.map +6 -0
- package/dist/cjs/{getVitePath.native.js → exports/serve.native.js} +99 -60
- package/dist/cjs/exports/serve.native.js.map +6 -0
- package/dist/cjs/index.js +2 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +3 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/plugins/clientBundleTreeShakePlugin.js +69 -0
- package/dist/cjs/plugins/clientBundleTreeShakePlugin.js.map +6 -0
- package/dist/cjs/plugins/clientBundleTreeShakePlugin.native.js +97 -0
- package/dist/cjs/plugins/clientBundleTreeShakePlugin.native.js.map +6 -0
- package/dist/cjs/plugins/clientInjectPlugin.js +66 -0
- package/dist/cjs/plugins/clientInjectPlugin.js.map +6 -0
- package/dist/cjs/plugins/clientInjectPlugin.native.js +190 -0
- package/dist/cjs/plugins/clientInjectPlugin.native.js.map +6 -0
- package/dist/cjs/plugins/reactNativeCommonJsPlugin.js +89 -0
- package/dist/cjs/plugins/reactNativeCommonJsPlugin.js.map +6 -0
- package/dist/cjs/plugins/reactNativeCommonJsPlugin.native.js +346 -0
- package/dist/cjs/plugins/reactNativeCommonJsPlugin.native.js.map +6 -0
- package/dist/cjs/utils/checkPatches.js +62 -0
- package/dist/cjs/utils/checkPatches.js.map +6 -0
- package/dist/cjs/{VXRNConfigFilled.native.js → utils/checkPatches.native.js} +106 -124
- package/dist/cjs/utils/checkPatches.native.js.map +6 -0
- package/dist/cjs/utils/dispose.js +28 -0
- package/dist/cjs/utils/dispose.js.map +6 -0
- package/dist/cjs/utils/dispose.native.js +36 -0
- package/dist/cjs/utils/dispose.native.js.map +6 -0
- package/dist/cjs/utils/getBaseViteConfig.js +2 -2
- package/dist/cjs/utils/getBaseViteConfig.js.map +1 -1
- package/dist/cjs/utils/getBaseViteConfig.native.js +2 -2
- package/dist/cjs/utils/getBaseViteConfig.native.js.map +1 -1
- package/dist/cjs/utils/getOptionsFilled.js +3 -3
- package/dist/cjs/utils/getOptionsFilled.js.map +2 -2
- package/dist/cjs/utils/getOptionsFilled.native.js +4 -3
- package/dist/cjs/utils/getOptionsFilled.native.js.map +2 -2
- package/dist/cjs/utils/patches.js +62 -0
- package/dist/cjs/utils/patches.js.map +6 -0
- package/dist/cjs/utils/patches.native.js +289 -0
- package/dist/cjs/utils/patches.native.js.map +6 -0
- package/dist/cjs/utils/prerender.js +1 -0
- package/dist/cjs/utils/prerender.js.map +6 -0
- package/dist/cjs/utils/prerender.native.js +2 -0
- package/dist/cjs/utils/prerender.native.js.map +6 -0
- package/dist/cjs/vendor/createExpoServer.js +34 -0
- package/dist/cjs/vendor/createExpoServer.js.map +6 -0
- package/dist/cjs/vendor/createExpoServer.native.js +42 -0
- package/dist/cjs/vendor/createExpoServer.native.js.map +6 -0
- package/dist/esm/build.js +51 -6
- package/dist/esm/build.js.map +2 -2
- package/dist/esm/build.mjs +68 -5
- package/dist/esm/build.native.js +174 -6
- package/dist/esm/build.native.js.map +2 -2
- package/dist/esm/cli.js +58 -3
- package/dist/esm/cli.js.map +2 -2
- package/dist/esm/cli.mjs +81 -9
- package/dist/esm/cli.native.js +249 -3
- package/dist/esm/cli.native.js.map +2 -2
- package/dist/esm/constants.js +5 -0
- package/dist/esm/constants.js.map +6 -0
- package/dist/esm/constants.mjs +2 -0
- package/dist/esm/constants.native.js +5 -0
- package/dist/esm/constants.native.js.map +6 -0
- package/dist/esm/createDevServer.js +10 -9
- package/dist/esm/createDevServer.js.map +1 -1
- package/dist/esm/createDevServer.mjs +8 -12
- package/dist/esm/createDevServer.native.js +10 -10
- package/dist/esm/createDevServer.native.js.map +2 -2
- package/dist/esm/createExpoServer.js +20 -0
- package/dist/esm/createExpoServer.js.map +6 -0
- package/dist/esm/createExpoServer.mjs +17 -0
- package/dist/esm/createExpoServer.native.js +22 -0
- package/dist/esm/createExpoServer.native.js.map +6 -0
- package/dist/esm/dispose.js +12 -0
- package/dist/esm/dispose.js.map +6 -0
- package/dist/esm/dispose.mjs +8 -0
- package/dist/esm/dispose.native.js +14 -0
- package/dist/esm/dispose.native.js.map +6 -0
- package/dist/esm/exports/build.js +128 -0
- package/dist/esm/exports/build.js.map +6 -0
- package/dist/esm/exports/build.mjs +119 -0
- package/dist/esm/exports/build.native.js +385 -0
- package/dist/esm/exports/build.native.js.map +6 -0
- package/dist/esm/exports/checkPatches.js +40 -0
- package/dist/esm/exports/checkPatches.js.map +6 -0
- package/dist/esm/exports/checkPatches.mjs +31 -0
- package/dist/esm/exports/checkPatches.native.js +262 -0
- package/dist/esm/exports/checkPatches.native.js.map +6 -0
- package/dist/esm/{create.js → exports/dev.js} +94 -171
- package/dist/esm/exports/dev.js.map +6 -0
- package/dist/esm/exports/dev.mjs +543 -0
- package/dist/esm/{create.native.js → exports/dev.native.js} +150 -359
- package/dist/esm/exports/dev.native.js.map +6 -0
- package/dist/esm/exports/serve.js +33 -0
- package/dist/esm/exports/serve.js.map +6 -0
- package/dist/esm/exports/serve.mjs +38 -0
- package/dist/esm/exports/serve.native.js +209 -0
- package/dist/esm/exports/serve.native.js.map +6 -0
- package/dist/esm/index.js +3 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +3 -4
- package/dist/esm/index.native.js +3 -5
- package/dist/esm/index.native.js.map +2 -2
- package/dist/esm/plugins/clientBundleTreeShakePlugin.js +46 -0
- package/dist/esm/plugins/clientBundleTreeShakePlugin.js.map +6 -0
- package/dist/esm/plugins/clientBundleTreeShakePlugin.mjs +41 -0
- package/dist/esm/plugins/clientBundleTreeShakePlugin.native.js +70 -0
- package/dist/esm/plugins/clientBundleTreeShakePlugin.native.js.map +6 -0
- package/dist/esm/plugins/clientInjectPlugin.js +42 -0
- package/dist/esm/plugins/clientInjectPlugin.js.map +6 -0
- package/dist/esm/plugins/clientInjectPlugin.mjs +56 -0
- package/dist/esm/plugins/clientInjectPlugin.native.js +161 -0
- package/dist/esm/plugins/clientInjectPlugin.native.js.map +6 -0
- package/dist/esm/plugins/reactNativeCommonJsPlugin.js +75 -0
- package/dist/esm/plugins/reactNativeCommonJsPlugin.js.map +6 -0
- package/dist/esm/plugins/reactNativeCommonJsPlugin.mjs +55 -0
- package/dist/esm/plugins/reactNativeCommonJsPlugin.native.js +327 -0
- package/dist/esm/plugins/reactNativeCommonJsPlugin.native.js.map +6 -0
- package/dist/esm/utils/checkPatches.js +40 -0
- package/dist/esm/utils/checkPatches.js.map +6 -0
- package/dist/esm/utils/checkPatches.mjs +31 -0
- package/dist/esm/utils/checkPatches.native.js +262 -0
- package/dist/esm/utils/checkPatches.native.js.map +6 -0
- package/dist/esm/utils/dispose.js +12 -0
- package/dist/esm/utils/dispose.js.map +6 -0
- package/dist/esm/utils/dispose.mjs +8 -0
- package/dist/esm/utils/dispose.native.js +14 -0
- package/dist/esm/utils/dispose.native.js.map +6 -0
- package/dist/esm/utils/getBaseViteConfig.js +1 -1
- package/dist/esm/utils/getBaseViteConfig.mjs +1 -1
- package/dist/esm/utils/getBaseViteConfig.native.js +1 -1
- package/dist/esm/utils/getOptionsFilled.js +3 -1
- package/dist/esm/utils/getOptionsFilled.js.map +2 -2
- package/dist/esm/utils/getOptionsFilled.mjs +3 -1
- package/dist/esm/utils/getOptionsFilled.native.js +4 -2
- package/dist/esm/utils/getOptionsFilled.native.js.map +2 -2
- package/dist/esm/utils/patches.js +40 -0
- package/dist/esm/utils/patches.js.map +6 -0
- package/dist/esm/utils/patches.mjs +31 -0
- package/dist/esm/utils/patches.native.js +262 -0
- package/dist/esm/utils/patches.native.js.map +6 -0
- package/dist/esm/utils/prerender.js +1 -0
- package/dist/esm/utils/prerender.js.map +6 -0
- package/dist/esm/utils/prerender.mjs +0 -0
- package/dist/esm/utils/prerender.native.js +1 -0
- package/dist/esm/utils/prerender.native.js.map +6 -0
- package/dist/esm/vendor/createExpoServer.js +20 -0
- package/dist/esm/vendor/createExpoServer.js.map +6 -0
- package/dist/esm/vendor/createExpoServer.mjs +17 -0
- package/dist/esm/vendor/createExpoServer.native.js +22 -0
- package/dist/esm/vendor/createExpoServer.native.js.map +6 -0
- package/package.json +9 -6
- package/react-native-template.js +11 -0
- package/src/cli.ts +78 -2
- package/src/exports/build.ts +197 -0
- package/src/{createDevServer.ts → exports/dev.ts} +25 -72
- package/src/exports/serve.ts +51 -0
- package/src/index.ts +3 -3
- package/src/plugins/clientBundleTreeShakePlugin.tsx +105 -0
- package/src/{dev → plugins}/clientInjectPlugin.ts +1 -12
- package/src/{nativePlugin.ts → plugins/reactNativeCommonJsPlugin.ts} +3 -26
- package/src/utils/getBaseViteConfig.ts +1 -1
- package/src/utils/getOptionsFilled.ts +6 -1
- package/src/utils/patches.ts +54 -0
- package/src/vendor/createExpoServer.ts +27 -0
- package/types/build.d.ts +4 -4
- package/types/constants.d.ts +2 -0
- package/types/createExpoServer.d.ts +4 -0
- package/types/dispose.d.ts +3 -0
- package/types/exports/build.d.ts +4 -0
- package/types/exports/dev.d.ts +13 -0
- package/types/exports/serve.d.ts +3 -0
- package/types/index.d.ts +2 -3
- package/types/plugins/clientBundleTreeShakePlugin.d.ts +13 -0
- package/types/plugins/clientBundleTreeShakePlugni.d.ts +13 -0
- package/types/plugins/clientInjectPlugin.d.ts +7 -0
- package/types/plugins/reactNativeCommonJsPlugin.d.ts +7 -0
- package/types/plugins/server-tree-shake.d.ts +13 -0
- package/types/utils/checkPatches.d.ts +3 -0
- package/types/utils/dispose.d.ts +3 -0
- package/types/utils/patches.d.ts +3 -0
- package/types/utils/prerender.d.ts +1 -0
- package/types/vendor/createExpoServer.d.ts +4 -0
- package/dist/cjs/VXRNConfigFilled.js +0 -53
- package/dist/cjs/VXRNConfigFilled.js.map +0 -6
- package/dist/cjs/VXRNConfigFilled.native.js.map +0 -6
- package/dist/cjs/create.js.map +0 -6
- package/dist/cjs/create.native.js.map +0 -6
- package/dist/cjs/dev/bindKeypressInput.js.map +0 -6
- package/dist/cjs/dev/bindKeypressInput.native.js +0 -73
- package/dist/cjs/dev/bindKeypressInput.native.js.map +0 -6
- package/dist/cjs/getBaseViteConfig.js.map +0 -6
- package/dist/cjs/getBaseViteConfig.native.js.map +0 -6
- package/dist/cjs/getOptionsFIlled.js +0 -53
- package/dist/cjs/getOptionsFIlled.js.map +0 -6
- package/dist/cjs/getOptionsFIlled.native.js.map +0 -6
- package/dist/cjs/getVitePath.js +0 -50
- package/dist/cjs/getVitePath.js.map +0 -6
- package/dist/cjs/getVitePath.native.js.map +0 -6
- package/dist/esm/VXRNConfigFilled.js +0 -30
- package/dist/esm/VXRNConfigFilled.js.map +0 -6
- package/dist/esm/VXRNConfigFilled.mjs +0 -34
- package/dist/esm/VXRNConfigFilled.native.js +0 -279
- package/dist/esm/VXRNConfigFilled.native.js.map +0 -6
- package/dist/esm/create.js.map +0 -6
- package/dist/esm/create.mjs +0 -624
- package/dist/esm/create.native.js.map +0 -6
- package/dist/esm/dev/bindKeypressInput.js +0 -40
- package/dist/esm/dev/bindKeypressInput.js.map +0 -6
- package/dist/esm/dev/bindKeypressInput.mjs +0 -41
- package/dist/esm/dev/bindKeypressInput.native.js +0 -44
- package/dist/esm/dev/bindKeypressInput.native.js.map +0 -6
- package/dist/esm/getBaseViteConfig.js +0 -24
- package/dist/esm/getBaseViteConfig.js.map +0 -6
- package/dist/esm/getBaseViteConfig.mjs +0 -23
- package/dist/esm/getBaseViteConfig.native.js +0 -25
- package/dist/esm/getBaseViteConfig.native.js.map +0 -6
- package/dist/esm/getOptionsFIlled.js +0 -30
- package/dist/esm/getOptionsFIlled.js.map +0 -6
- package/dist/esm/getOptionsFIlled.mjs +0 -34
- package/dist/esm/getOptionsFIlled.native.js +0 -279
- package/dist/esm/getOptionsFIlled.native.js.map +0 -6
- package/dist/esm/getVitePath.js +0 -28
- package/dist/esm/getVitePath.js.map +0 -6
- package/dist/esm/getVitePath.mjs +0 -21
- package/dist/esm/getVitePath.native.js +0 -170
- package/dist/esm/getVitePath.native.js.map +0 -6
- package/src/build.ts +0 -96
- package/src/commands/cli-build.ts +0 -25
- package/src/commands/cli-dev.ts +0 -47
- package/src/commands/index.ts +0 -10
- package/src/dev/createDevServer.ts +0 -234
- /package/src/{utils/constants.ts → constants.ts} +0 -0
- /package/src/{utils.ts → utils/dispose.ts} +0 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { resolve as importMetaResolve } from 'import-meta-resolve'
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import { mergeConfig, build as viteBuild, type UserConfig } from 'vite'
|
|
5
|
+
|
|
6
|
+
import FSExtra from 'fs-extra'
|
|
7
|
+
import type { OutputAsset, OutputChunk, RollupOutput } from 'rollup'
|
|
8
|
+
import { clientBundleTreeShakePlugin } from '../plugins/clientBundleTreeShakePlugin'
|
|
9
|
+
import type { VXRNConfig } from '../types'
|
|
10
|
+
import { getBaseViteConfig } from '../utils/getBaseViteConfig'
|
|
11
|
+
import { getOptionsFilled, type VXRNConfigFilled } from '../utils/getOptionsFilled'
|
|
12
|
+
|
|
13
|
+
export const resolveFile = (path: string) => {
|
|
14
|
+
try {
|
|
15
|
+
return importMetaResolve(path, import.meta.url).replace('file://', '')
|
|
16
|
+
} catch {
|
|
17
|
+
return require.resolve(path)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const { ensureDir, existsSync, readFile } = FSExtra
|
|
22
|
+
|
|
23
|
+
const extensions = [
|
|
24
|
+
'.web.tsx',
|
|
25
|
+
'.tsx',
|
|
26
|
+
'.web.ts',
|
|
27
|
+
'.ts',
|
|
28
|
+
'.web.jsx',
|
|
29
|
+
'.jsx',
|
|
30
|
+
'.web.js',
|
|
31
|
+
'.js',
|
|
32
|
+
'.css',
|
|
33
|
+
'.json',
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
export const build = async (optionsIn: VXRNConfig) => {
|
|
37
|
+
const options = await getOptionsFilled(optionsIn)
|
|
38
|
+
const depsToOptimize = [
|
|
39
|
+
'react',
|
|
40
|
+
'react-dom',
|
|
41
|
+
'@react-native/normalize-color',
|
|
42
|
+
'@react-navigation/native',
|
|
43
|
+
'expo-constants',
|
|
44
|
+
'expo-modules-core',
|
|
45
|
+
'expo-status-bar',
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
let buildConfig = mergeConfig(
|
|
49
|
+
getBaseViteConfig({
|
|
50
|
+
mode: 'production',
|
|
51
|
+
}),
|
|
52
|
+
{
|
|
53
|
+
root: options.root,
|
|
54
|
+
clearScreen: false,
|
|
55
|
+
optimizeDeps: {
|
|
56
|
+
include: depsToOptimize,
|
|
57
|
+
esbuildOptions: {
|
|
58
|
+
resolveExtensions: extensions,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
) satisfies UserConfig
|
|
63
|
+
|
|
64
|
+
if (options.webConfig) {
|
|
65
|
+
buildConfig = mergeConfig(buildConfig, options.webConfig) as any
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
console.info(`build client`)
|
|
69
|
+
await viteBuild(
|
|
70
|
+
mergeConfig(buildConfig, {
|
|
71
|
+
plugins: [clientBundleTreeShakePlugin({})],
|
|
72
|
+
build: {
|
|
73
|
+
ssrManifest: true,
|
|
74
|
+
outDir: 'dist/client',
|
|
75
|
+
},
|
|
76
|
+
} satisfies UserConfig)
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
console.info(`build server`)
|
|
80
|
+
const { output } = (await viteBuild(
|
|
81
|
+
mergeConfig(buildConfig, {
|
|
82
|
+
resolve: {
|
|
83
|
+
alias: {
|
|
84
|
+
'react-native': 'react-native-web-lite',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
optimizeDeps: {
|
|
88
|
+
esbuildOptions: {
|
|
89
|
+
format: 'cjs',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
ssr: {
|
|
93
|
+
noExternal: true,
|
|
94
|
+
},
|
|
95
|
+
build: {
|
|
96
|
+
// we want one big file of css
|
|
97
|
+
cssCodeSplit: false,
|
|
98
|
+
ssr: 'src/entry-server.tsx',
|
|
99
|
+
outDir: 'dist/server',
|
|
100
|
+
rollupOptions: {
|
|
101
|
+
external: [],
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
} satisfies UserConfig)
|
|
105
|
+
)) as RollupOutput
|
|
106
|
+
|
|
107
|
+
console.info(`generating static pages`)
|
|
108
|
+
await generateStaticPages(options, output)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function generateStaticPages(
|
|
112
|
+
options: VXRNConfigFilled,
|
|
113
|
+
serverOutput: (OutputChunk | OutputAsset)[]
|
|
114
|
+
) {
|
|
115
|
+
const toAbsolute = (p) => path.resolve(options.root, p)
|
|
116
|
+
|
|
117
|
+
const staticDir = toAbsolute(`dist/static`)
|
|
118
|
+
await ensureDir(staticDir)
|
|
119
|
+
const template = fs.readFileSync(toAbsolute('index.html'), 'utf-8')
|
|
120
|
+
|
|
121
|
+
const render = (await import(`${options.root}/dist/server/entry-server.js`)).render
|
|
122
|
+
|
|
123
|
+
// load routes
|
|
124
|
+
const entry = serverOutput.find(
|
|
125
|
+
(x) => x.type === 'chunk' && x.facadeModuleId?.includes('entry-server')
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
const assets: OutputAsset[] = []
|
|
129
|
+
|
|
130
|
+
const allRoutes = (
|
|
131
|
+
await Promise.all(
|
|
132
|
+
serverOutput.flatMap(async (output) => {
|
|
133
|
+
if (output.type === 'asset') {
|
|
134
|
+
assets.push(output)
|
|
135
|
+
return []
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const id = output.facadeModuleId || ''
|
|
139
|
+
const file = path.basename(id)
|
|
140
|
+
const name = file.replace(/\.[^/.]+$/, '')
|
|
141
|
+
|
|
142
|
+
if (!id || file[0] === '_' || file.includes('entry-server')) {
|
|
143
|
+
return []
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const endpointPath = path.join(options.root, 'dist/server', output.fileName)
|
|
147
|
+
const exported = await import(endpointPath)
|
|
148
|
+
const staticParams = await exported.generateStaticParams?.()
|
|
149
|
+
const result = (staticParams || [{}]).map((params) => {
|
|
150
|
+
return getUrl(params)
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
function getUrl(params = {}) {
|
|
154
|
+
return name === 'index'
|
|
155
|
+
? '/'
|
|
156
|
+
: `/${name
|
|
157
|
+
.split('/')
|
|
158
|
+
.map((part) => {
|
|
159
|
+
if (part[0] === '[') {
|
|
160
|
+
const found = params[part.slice(1, part.length - 1)]
|
|
161
|
+
if (!found) {
|
|
162
|
+
console.warn('not found', { params, part })
|
|
163
|
+
}
|
|
164
|
+
return found
|
|
165
|
+
}
|
|
166
|
+
return part
|
|
167
|
+
})
|
|
168
|
+
.join('/')}`
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return result
|
|
172
|
+
})
|
|
173
|
+
)
|
|
174
|
+
).flat()
|
|
175
|
+
|
|
176
|
+
// for now just inline
|
|
177
|
+
const cssString = assets
|
|
178
|
+
.filter((x) => x.name?.endsWith('.css'))
|
|
179
|
+
.map((x) => x.source)
|
|
180
|
+
.join('\n\n')
|
|
181
|
+
|
|
182
|
+
// pre-render each route...
|
|
183
|
+
for (const path of allRoutes) {
|
|
184
|
+
const { appHtml, headHtml } = await render({ path })
|
|
185
|
+
const slashFileName = `${path === '/' ? '/index' : path}.html`
|
|
186
|
+
const clientHtmlPath = toAbsolute(`dist/client${slashFileName}`)
|
|
187
|
+
const clientHtml = existsSync(clientHtmlPath) ? await readFile(clientHtmlPath, 'utf-8') : null
|
|
188
|
+
const html = (clientHtml || template)
|
|
189
|
+
.replace(`<!--ssr-outlet-->`, appHtml)
|
|
190
|
+
.replace(
|
|
191
|
+
`<!--head-outlet-->`,
|
|
192
|
+
`${headHtml}\n${cssString ? `<style>${cssString}</style>` : ``}`
|
|
193
|
+
)
|
|
194
|
+
const filePath = toAbsolute(`dist/static${slashFileName}`)
|
|
195
|
+
fs.writeFileSync(toAbsolute(filePath), html)
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import wsAdapter from 'crossws/adapters/node'
|
|
2
|
-
import findNodeModules from 'find-node-modules'
|
|
3
2
|
import {
|
|
4
3
|
createApp,
|
|
5
4
|
createRouter,
|
|
@@ -14,7 +13,6 @@ import { readFile } from 'node:fs/promises'
|
|
|
14
13
|
import { createServer as nodeCreateServer } from 'node:http'
|
|
15
14
|
import { dirname, join, relative, resolve } from 'node:path'
|
|
16
15
|
import readline from 'node:readline'
|
|
17
|
-
import viteInspectPlugin from 'vite-plugin-inspect'
|
|
18
16
|
import { WebSocket } from 'ws'
|
|
19
17
|
|
|
20
18
|
import * as babel from '@babel/core'
|
|
@@ -36,12 +34,15 @@ import {
|
|
|
36
34
|
import createViteFlow from '@vxrn/vite-flow'
|
|
37
35
|
import type { Peer } from 'crossws'
|
|
38
36
|
import { resolve as importMetaResolve } from 'import-meta-resolve'
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
37
|
+
import { clientBundleTreeShakePlugin } from '../plugins/clientBundleTreeShakePlugin'
|
|
38
|
+
import { clientInjectionsPlugin } from '../plugins/clientInjectPlugin'
|
|
39
|
+
import { reactNativeCommonJsPlugin } from '../plugins/reactNativeCommonJsPlugin'
|
|
40
|
+
import type { VXRNConfig } from '../types'
|
|
41
|
+
import { getBaseViteConfig } from '../utils/getBaseViteConfig'
|
|
42
|
+
import { getOptionsFilled } from '../utils/getOptionsFilled'
|
|
43
|
+
import { getVitePath } from '../utils/getVitePath'
|
|
44
|
+
import { checkPatches } from '../utils/patches'
|
|
45
|
+
import { createExpoServer } from '../vendor/createExpoServer'
|
|
45
46
|
|
|
46
47
|
export const resolveFile = (path: string) => {
|
|
47
48
|
try {
|
|
@@ -77,58 +78,7 @@ const extensions = [
|
|
|
77
78
|
|
|
78
79
|
const { ensureDir, pathExists, pathExistsSync } = FSExtra
|
|
79
80
|
|
|
80
|
-
const
|
|
81
|
-
{
|
|
82
|
-
module: 'react-native-screens',
|
|
83
|
-
patchFile: 'react-native-screens+3.22.1.patch',
|
|
84
|
-
},
|
|
85
|
-
]
|
|
86
|
-
|
|
87
|
-
type Patch = (typeof patches)[0]
|
|
88
|
-
|
|
89
|
-
async function checkPatches(options: VXRNConfigFilled) {
|
|
90
|
-
if (options.state.applyPatches === false) {
|
|
91
|
-
return
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const nodeModulesDirs = findNodeModules({
|
|
95
|
-
cwd: options.root,
|
|
96
|
-
}).map((relativePath) => join(options.root, relativePath))
|
|
97
|
-
|
|
98
|
-
const patchesToCopy = new Set<Patch>()
|
|
99
|
-
|
|
100
|
-
await Promise.all(
|
|
101
|
-
patches.flatMap((patch) => {
|
|
102
|
-
return nodeModulesDirs.flatMap(async (dir) => {
|
|
103
|
-
if (await FSExtra.pathExists(join(dir, patch.module))) {
|
|
104
|
-
patchesToCopy.add(patch)
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
})
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
let didCopy = false
|
|
111
|
-
|
|
112
|
-
for (const patch of [...patchesToCopy]) {
|
|
113
|
-
const dest = join(options.userPatchesDir, patch.patchFile)
|
|
114
|
-
if (!(await pathExists(dest))) {
|
|
115
|
-
didCopy = true
|
|
116
|
-
console.info(`Copying patch ${patch.module}`)
|
|
117
|
-
const src = join(options.internalPatchesDir, patch.patchFile)
|
|
118
|
-
await FSExtra.copy(src, dest)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (didCopy) {
|
|
123
|
-
console.info(
|
|
124
|
-
`\nPlease restart after applying the patch by running "npx patch-package".
|
|
125
|
-
Ideally add it to your devDependencies and as a postinstall script.\n`
|
|
126
|
-
)
|
|
127
|
-
process.exit(0)
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export const createDevServer = async (optionsIn: VXRNConfig) => {
|
|
81
|
+
export const dev = async (optionsIn: VXRNConfig) => {
|
|
132
82
|
const options = await getOptionsFilled(optionsIn)
|
|
133
83
|
const { host, port, root, cacheDir } = options
|
|
134
84
|
|
|
@@ -363,7 +313,11 @@ export const createDevServer = async (optionsIn: VXRNConfig) => {
|
|
|
363
313
|
{
|
|
364
314
|
root,
|
|
365
315
|
clearScreen: false,
|
|
366
|
-
plugins: [
|
|
316
|
+
plugins: [
|
|
317
|
+
reactNativeHMRPlugin,
|
|
318
|
+
|
|
319
|
+
clientBundleTreeShakePlugin({}),
|
|
320
|
+
],
|
|
367
321
|
optimizeDeps: {
|
|
368
322
|
include: depsToOptimize,
|
|
369
323
|
exclude: Object.values(virtualModules).map((v) => v.alias),
|
|
@@ -379,7 +333,7 @@ export const createDevServer = async (optionsIn: VXRNConfig) => {
|
|
|
379
333
|
cors: true,
|
|
380
334
|
host,
|
|
381
335
|
},
|
|
382
|
-
}
|
|
336
|
+
} satisfies UserConfig
|
|
383
337
|
) satisfies InlineConfig
|
|
384
338
|
|
|
385
339
|
if (options.webConfig) {
|
|
@@ -430,6 +384,8 @@ export const createDevServer = async (optionsIn: VXRNConfig) => {
|
|
|
430
384
|
},
|
|
431
385
|
})
|
|
432
386
|
|
|
387
|
+
createExpoServer(root, app)
|
|
388
|
+
|
|
433
389
|
router.get(
|
|
434
390
|
'/file',
|
|
435
391
|
defineEventHandler((e) => {
|
|
@@ -557,6 +513,7 @@ export const createDevServer = async (optionsIn: VXRNConfig) => {
|
|
|
557
513
|
data: string[]
|
|
558
514
|
}
|
|
559
515
|
|
|
516
|
+
// react native log bridge
|
|
560
517
|
app.use(
|
|
561
518
|
'/__client',
|
|
562
519
|
defineWebSocketHandler({
|
|
@@ -601,7 +558,7 @@ export const createDevServer = async (optionsIn: VXRNConfig) => {
|
|
|
601
558
|
server.on('upgrade', handleUpgrade)
|
|
602
559
|
|
|
603
560
|
return {
|
|
604
|
-
|
|
561
|
+
server,
|
|
605
562
|
viteServer,
|
|
606
563
|
|
|
607
564
|
async start() {
|
|
@@ -655,8 +612,6 @@ export const createDevServer = async (optionsIn: VXRNConfig) => {
|
|
|
655
612
|
})
|
|
656
613
|
}
|
|
657
614
|
|
|
658
|
-
const buildInput = options.entryNative || 'index.jsx'
|
|
659
|
-
|
|
660
615
|
// build app
|
|
661
616
|
let buildConfig = {
|
|
662
617
|
plugins: [
|
|
@@ -674,9 +629,10 @@ export const createDevServer = async (optionsIn: VXRNConfig) => {
|
|
|
674
629
|
},
|
|
675
630
|
},
|
|
676
631
|
|
|
632
|
+
clientBundleTreeShakePlugin({}),
|
|
677
633
|
viteRNClientPlugin,
|
|
678
634
|
|
|
679
|
-
|
|
635
|
+
reactNativeCommonJsPlugin({
|
|
680
636
|
root,
|
|
681
637
|
port,
|
|
682
638
|
mode: 'build',
|
|
@@ -687,11 +643,6 @@ export const createDevServer = async (optionsIn: VXRNConfig) => {
|
|
|
687
643
|
mode: 'build',
|
|
688
644
|
}),
|
|
689
645
|
|
|
690
|
-
// viteInspectPlugin({
|
|
691
|
-
// build: true,
|
|
692
|
-
// outputDir: '.vite-inspect',
|
|
693
|
-
// }),
|
|
694
|
-
|
|
695
646
|
{
|
|
696
647
|
name: 'treat-js-files-as-jsx',
|
|
697
648
|
async transform(code, id) {
|
|
@@ -807,6 +758,8 @@ __require("${outputModule.fileName}")
|
|
|
807
758
|
.replaceAll('undefined.accept(function() {});', '')
|
|
808
759
|
.replaceAll('(void 0).accept(() => {})', '')
|
|
809
760
|
.replaceAll('(void 0).accept(function() {});', '')
|
|
761
|
+
// TEMP FIX for expo-router tamagui thing since expo router 3 upgrade
|
|
762
|
+
.replaceAll('dist/esm/index.mjs"', 'dist/esm/index.js"')
|
|
810
763
|
|
|
811
764
|
// TODO this is not stable based on cwd
|
|
812
765
|
const appRootParent = join(root, '..', '..')
|
|
@@ -861,7 +814,7 @@ function getIndexJsonResponse({ port, root }: { port: number | string; root }) {
|
|
|
861
814
|
staticConfigPath: join(root, 'app.json'),
|
|
862
815
|
packageJsonPath: join(root, 'package.json'),
|
|
863
816
|
},
|
|
864
|
-
sdkVersion: '
|
|
817
|
+
sdkVersion: '50.0.0',
|
|
865
818
|
platforms: ['ios', 'android', 'web'],
|
|
866
819
|
iconUrl: `http://127.0.0.1:${port}/assets/./assets/icon.png`,
|
|
867
820
|
debuggerHost: `127.0.0.1:${port}`,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import sirv from 'sirv'
|
|
2
|
+
import type { VXRNConfig } from '../types'
|
|
3
|
+
import { getOptionsFilled } from '../utils/getOptionsFilled'
|
|
4
|
+
import { createApp, defineEventHandler } from 'h3'
|
|
5
|
+
|
|
6
|
+
export const serve = async (optionsIn: VXRNConfig) => {
|
|
7
|
+
const options = await getOptionsFilled(optionsIn)
|
|
8
|
+
|
|
9
|
+
const app = createApp()
|
|
10
|
+
|
|
11
|
+
const sirvStaticMiddleware = sirv('dist/static', {
|
|
12
|
+
gzip: true,
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
app.use(
|
|
16
|
+
defineEventHandler(async ({ node: { req, res } }) => {
|
|
17
|
+
await new Promise<void>((response) => {
|
|
18
|
+
sirvStaticMiddleware(req, res, () => {
|
|
19
|
+
response()
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const sirvMiddleware = sirv('dist/client', {
|
|
26
|
+
gzip: true,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
app.use(
|
|
30
|
+
defineEventHandler(async ({ node: { req, res } }) => {
|
|
31
|
+
await new Promise<void>((response) => {
|
|
32
|
+
sirvMiddleware(req, res, () => {
|
|
33
|
+
response()
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// app.use(
|
|
41
|
+
// defineEventHandler(async ({ node: { req, res } }) => {
|
|
42
|
+
// const url = req.originalUrl
|
|
43
|
+
// const template = fs.readFileSync(path.resolve('dist/client/index.html'), 'utf-8')
|
|
44
|
+
// // @ts-ignore
|
|
45
|
+
// const render = (await import('./dist/server/entry-server.js')).render
|
|
46
|
+
// const appHtml = await render({ path: url })
|
|
47
|
+
// const html = template.replace(`<!--ssr-outlet-->`, appHtml)
|
|
48
|
+
// res.setHeader('Content-Type', 'text/html')
|
|
49
|
+
// return html
|
|
50
|
+
// })
|
|
51
|
+
// )
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
|
|
1
|
+
export { build } from './exports/build'
|
|
2
|
+
export { dev } from './exports/dev'
|
|
3
|
+
|
|
4
4
|
export * from './types'
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Node, Program } from 'estree'
|
|
2
|
+
import { walk } from 'estree-walker'
|
|
3
|
+
import MagicString from 'magic-string'
|
|
4
|
+
import type { Plugin } from 'vite'
|
|
5
|
+
|
|
6
|
+
interface TreeShakeTemplatePluginOptions {
|
|
7
|
+
sourcemap?: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type AcornNode<N extends Node> = N & { start: number; end: number }
|
|
11
|
+
|
|
12
|
+
export const clientBundleTreeShakePlugin = (options: TreeShakeTemplatePluginOptions) => {
|
|
13
|
+
return {
|
|
14
|
+
name: 'vxrn:client-tree-shake',
|
|
15
|
+
enforce: 'post',
|
|
16
|
+
transform(code, id) {
|
|
17
|
+
if (id.includes('node_modules')) {
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
if (!code.includes(`generateStaticParams`)) {
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const s = new MagicString(code)
|
|
25
|
+
const codeAst = this.parse(code) as AcornNode<Program>
|
|
26
|
+
|
|
27
|
+
walk(codeAst, {
|
|
28
|
+
enter: (node) => {
|
|
29
|
+
if (node.type === 'ExportNamedDeclaration' || node.type === 'VariableDeclaration') {
|
|
30
|
+
let declarators = (
|
|
31
|
+
'declarations' in node
|
|
32
|
+
? node.declarations
|
|
33
|
+
: 'declaration' in node
|
|
34
|
+
? [node.declaration]
|
|
35
|
+
: []
|
|
36
|
+
) as any[]
|
|
37
|
+
|
|
38
|
+
let shouldRemove = false
|
|
39
|
+
|
|
40
|
+
declarators.forEach((declarator) => {
|
|
41
|
+
if (
|
|
42
|
+
declarator.id.type === 'Identifier' &&
|
|
43
|
+
declarator.id.name === 'generateStaticParams'
|
|
44
|
+
) {
|
|
45
|
+
shouldRemove = true
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const replaceStr = `function generateStaticParams() {};`
|
|
50
|
+
const length = node['end'] - node['start']
|
|
51
|
+
|
|
52
|
+
if (shouldRemove) {
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
// s.remove(node.start, node.end + 1)
|
|
55
|
+
s.update(node.start, node.end + 1, replaceStr.padEnd(length - replaceStr.length))
|
|
56
|
+
// make sure it doesnt error with forceExports
|
|
57
|
+
// s.append(`function generateStaticParams {}`)
|
|
58
|
+
|
|
59
|
+
if (node.type === 'ExportNamedDeclaration') {
|
|
60
|
+
// remove import declaration if it exists
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
removeImportDeclaration(codeAst, node, s)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
if (s.hasChanged()) {
|
|
70
|
+
return {
|
|
71
|
+
code: s.toString(),
|
|
72
|
+
map: options.sourcemap ? s.generateMap({ hires: true }) : undefined,
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
} satisfies Plugin
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function removeImportDeclaration(
|
|
80
|
+
ast: Program,
|
|
81
|
+
importName: string,
|
|
82
|
+
magicString: MagicString
|
|
83
|
+
): boolean {
|
|
84
|
+
for (const node of ast.body) {
|
|
85
|
+
if (node.type === 'ImportDeclaration') {
|
|
86
|
+
const specifier = node.specifiers.find((s) => s.local.name === importName)
|
|
87
|
+
if (specifier) {
|
|
88
|
+
if (node.specifiers.length > 1) {
|
|
89
|
+
const specifierIndex = node.specifiers.findIndex((s) => s.local.name === importName)
|
|
90
|
+
if (specifierIndex > -1) {
|
|
91
|
+
magicString.remove(
|
|
92
|
+
(node.specifiers[specifierIndex] as AcornNode<Node>).start,
|
|
93
|
+
(node.specifiers[specifierIndex] as AcornNode<Node>).end + 1
|
|
94
|
+
)
|
|
95
|
+
node.specifiers.splice(specifierIndex, 1)
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
magicString.remove((node as AcornNode<Node>).start, (node as AcornNode<Node>).end)
|
|
99
|
+
}
|
|
100
|
+
return true
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return false
|
|
105
|
+
}
|
|
@@ -81,15 +81,6 @@ export function clientInjectionsPlugin(config: ResolvedConfig): Plugin {
|
|
|
81
81
|
transform(code, id, options) {
|
|
82
82
|
if (id.includes('vite-native-client/dist/esm/client.')) {
|
|
83
83
|
return injectConfigValues(code)
|
|
84
|
-
} else if (!options?.ssr && code.includes('process.env.NODE_ENV')) {
|
|
85
|
-
// replace process.env.NODE_ENV instead of defining a global
|
|
86
|
-
// for it to avoid shimming a `process` object during dev,
|
|
87
|
-
// avoiding inconsistencies between dev and build
|
|
88
|
-
// return code.replace(
|
|
89
|
-
// process_env_NODE_ENV_RE,
|
|
90
|
-
// config.define?.['process.env.NODE_ENV'] ||
|
|
91
|
-
// JSON.stringify(process.env.NODE_ENV || config.mode)
|
|
92
|
-
// )
|
|
93
84
|
}
|
|
94
85
|
},
|
|
95
86
|
}
|
|
@@ -104,9 +95,7 @@ function serializeDefine(define: Record<string, any>): string {
|
|
|
104
95
|
let res = `{`
|
|
105
96
|
for (const key in define) {
|
|
106
97
|
const val = define[key]
|
|
107
|
-
res += `${JSON.stringify(key)}: ${
|
|
108
|
-
typeof val === 'string' ? `(${val})` : JSON.stringify(val)
|
|
109
|
-
}, `
|
|
98
|
+
res += `${JSON.stringify(key)}: ${typeof val === 'string' ? `(${val})` : JSON.stringify(val)}, `
|
|
110
99
|
}
|
|
111
100
|
return res + `}`
|
|
112
101
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { dirname } from 'path'
|
|
1
|
+
import { dirname } from 'node:path'
|
|
2
2
|
|
|
3
3
|
import { parse } from 'es-module-lexer'
|
|
4
4
|
import type { OutputOptions } from 'rollup'
|
|
5
5
|
import type { Plugin } from 'vite'
|
|
6
6
|
|
|
7
|
-
import { getVitePath } from '
|
|
7
|
+
import { getVitePath } from '../utils/getVitePath'
|
|
8
8
|
|
|
9
9
|
const extensions = [
|
|
10
10
|
'.ios.js',
|
|
@@ -19,7 +19,7 @@ const extensions = [
|
|
|
19
19
|
'.mjs',
|
|
20
20
|
]
|
|
21
21
|
|
|
22
|
-
export function
|
|
22
|
+
export function reactNativeCommonJsPlugin(options: {
|
|
23
23
|
root: string
|
|
24
24
|
port: number
|
|
25
25
|
mode: 'build' | 'serve'
|
|
@@ -93,13 +93,6 @@ export function nativePlugin(options: {
|
|
|
93
93
|
|
|
94
94
|
config.build.rollupOptions.plugins ??= []
|
|
95
95
|
|
|
96
|
-
// config.build.rollupOptions.external = [
|
|
97
|
-
// 'react-native',
|
|
98
|
-
// 'react',
|
|
99
|
-
// 'react/jsx-runtime',
|
|
100
|
-
// 'react/jsx-dev-runtime',
|
|
101
|
-
// ]
|
|
102
|
-
|
|
103
96
|
if (!Array.isArray(config.build.rollupOptions.plugins)) {
|
|
104
97
|
throw `x`
|
|
105
98
|
}
|
|
@@ -107,22 +100,6 @@ export function nativePlugin(options: {
|
|
|
107
100
|
if (options.mode === 'build') {
|
|
108
101
|
config.plugins ||= []
|
|
109
102
|
|
|
110
|
-
// https://vitejs.dev/config/dep-optimization-options.html
|
|
111
|
-
// config.build.commonjsOptions ||= {}
|
|
112
|
-
// config.build.commonjsOptions.include = []
|
|
113
|
-
|
|
114
|
-
// CANT DO THIS BECAUSE TAMAGUI PLUGIN DOES THIS! they clobber each other!
|
|
115
|
-
// config.plugins.push(
|
|
116
|
-
// viteCommonjs({
|
|
117
|
-
// include: ['escape-string-regexp'],
|
|
118
|
-
// })
|
|
119
|
-
// )
|
|
120
|
-
|
|
121
|
-
// config.resolve.alias = {
|
|
122
|
-
// ...config.resolve.alias,
|
|
123
|
-
// 'react-native': virtualModuleId,
|
|
124
|
-
// }
|
|
125
|
-
|
|
126
103
|
config.build.rollupOptions.plugins.push({
|
|
127
104
|
name: `force-export-all`,
|
|
128
105
|
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { join } from 'node:path'
|
|
2
2
|
import { readPackageJSON } from 'pkg-types'
|
|
3
|
+
import { createRequire } from 'module'
|
|
3
4
|
import FSExtra from 'fs-extra'
|
|
4
5
|
import type { VXRNConfig } from '../types'
|
|
5
6
|
|
|
7
|
+
const require = createRequire(import.meta.url)
|
|
8
|
+
|
|
6
9
|
export type VXRNConfigFilled = Awaited<ReturnType<typeof getOptionsFilled>>
|
|
7
10
|
|
|
8
11
|
export async function getOptionsFilled(options: VXRNConfig) {
|
|
9
12
|
const { host = '127.0.0.1', root = process.cwd(), port = 8081 } = options
|
|
10
|
-
|
|
13
|
+
|
|
14
|
+
const packageRootDir = join(require.resolve('vxrn'), '../../..')
|
|
15
|
+
|
|
11
16
|
const cacheDir = join(root, 'node_modules', '.cache', 'vxrn')
|
|
12
17
|
const internalPatchesDir = join(packageRootDir, 'patches')
|
|
13
18
|
const userPatchesDir = join(root, 'patches')
|