vxrn 0.1.30 → 0.1.32
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/cli.js +20 -1
- package/dist/cjs/cli.js.map +2 -2
- package/dist/cjs/cli.native.js +43 -1
- package/dist/cjs/cli.native.js.map +2 -2
- package/dist/cjs/constants.js +65 -2
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/constants.native.js +103 -3
- package/dist/cjs/constants.native.js.map +2 -2
- package/dist/cjs/exports/build.js +66 -50
- package/dist/cjs/exports/build.js.map +2 -2
- package/dist/cjs/exports/build.native.js +182 -83
- package/dist/cjs/exports/build.native.js.map +2 -2
- package/dist/cjs/exports/dev.js +292 -293
- package/dist/cjs/exports/dev.js.map +2 -2
- package/dist/cjs/exports/dev.native.js +575 -561
- package/dist/cjs/exports/dev.native.js.map +2 -2
- package/dist/cjs/exports/serve.js +7 -1
- package/dist/cjs/exports/serve.js.map +1 -1
- package/dist/cjs/exports/serve.native.js +76 -81
- package/dist/cjs/exports/serve.native.js.map +2 -2
- package/dist/cjs/plugins/clientBundleTreeShakePlugin.js +25 -11
- package/dist/cjs/plugins/clientBundleTreeShakePlugin.js.map +1 -1
- package/dist/cjs/plugins/clientBundleTreeShakePlugin.native.js +38 -22
- package/dist/cjs/plugins/clientBundleTreeShakePlugin.native.js.map +2 -2
- package/dist/cjs/utils/getBaseViteConfig.js +14 -4
- package/dist/cjs/utils/getBaseViteConfig.js.map +2 -2
- package/dist/cjs/utils/getBaseViteConfig.native.js +16 -4
- package/dist/cjs/utils/getBaseViteConfig.native.js.map +2 -2
- package/dist/cjs/{utils.js → utils/getHtml.js} +16 -12
- package/dist/cjs/utils/getHtml.js.map +6 -0
- package/dist/cjs/{utils.native.js → utils/getHtml.native.js} +11 -16
- package/dist/cjs/utils/getHtml.native.js.map +6 -0
- package/dist/cjs/utils/getVitePath.js.map +1 -1
- package/dist/cjs/utils/getVitePath.native.js.map +1 -1
- package/dist/cjs/utils/readVXRNConfig.js +2 -2
- package/dist/cjs/utils/readVXRNConfig.js.map +1 -1
- package/dist/cjs/utils/readVXRNConfig.native.js +1 -1
- package/dist/cjs/utils/readVXRNConfig.native.js.map +2 -2
- package/dist/esm/cli.js +20 -1
- package/dist/esm/cli.js.map +2 -2
- package/dist/esm/cli.mjs +25 -1
- package/dist/esm/cli.native.js +43 -1
- package/dist/esm/cli.native.js.map +2 -2
- package/dist/esm/constants.js +65 -2
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/constants.mjs +30 -2
- package/dist/esm/constants.native.js +96 -2
- package/dist/esm/constants.native.js.map +2 -2
- package/dist/esm/exports/build.js +70 -51
- package/dist/esm/exports/build.js.map +1 -1
- package/dist/esm/exports/build.mjs +79 -29
- package/dist/esm/exports/build.native.js +186 -84
- package/dist/esm/exports/build.native.js.map +2 -2
- package/dist/esm/exports/dev.js +291 -295
- package/dist/esm/exports/dev.js.map +1 -1
- package/dist/esm/exports/dev.mjs +298 -283
- package/dist/esm/exports/dev.native.js +575 -561
- package/dist/esm/exports/dev.native.js.map +2 -2
- package/dist/esm/exports/serve.js +8 -1
- package/dist/esm/exports/serve.js.map +1 -1
- package/dist/esm/exports/serve.mjs +8 -1
- package/dist/esm/exports/serve.native.js +77 -81
- package/dist/esm/exports/serve.native.js.map +2 -2
- package/dist/esm/plugins/clientBundleTreeShakePlugin.js +25 -11
- package/dist/esm/plugins/clientBundleTreeShakePlugin.js.map +1 -1
- package/dist/esm/plugins/clientBundleTreeShakePlugin.mjs +29 -13
- package/dist/esm/plugins/clientBundleTreeShakePlugin.native.js +38 -22
- package/dist/esm/plugins/clientBundleTreeShakePlugin.native.js.map +2 -2
- package/dist/esm/utils/getBaseViteConfig.js +4 -2
- package/dist/esm/utils/getBaseViteConfig.js.map +1 -1
- package/dist/esm/utils/getBaseViteConfig.mjs +4 -2
- package/dist/esm/utils/getBaseViteConfig.native.js +6 -2
- package/dist/esm/utils/getBaseViteConfig.native.js.map +2 -2
- package/dist/esm/utils/getHtml.js +16 -0
- package/dist/esm/utils/getHtml.js.map +6 -0
- package/dist/esm/utils/getHtml.mjs +13 -0
- package/dist/esm/utils/getHtml.native.js +10 -0
- package/dist/esm/utils/getHtml.native.js.map +6 -0
- package/dist/esm/utils/getVitePath.js.map +1 -1
- package/dist/esm/utils/getVitePath.native.js.map +1 -1
- package/dist/esm/utils/readVXRNConfig.js +2 -2
- package/dist/esm/utils/readVXRNConfig.js.map +1 -1
- package/dist/esm/utils/readVXRNConfig.mjs +2 -2
- package/dist/esm/utils/readVXRNConfig.native.js +1 -1
- package/dist/esm/utils/readVXRNConfig.native.js.map +2 -2
- package/package.json +10 -8
- package/src/cli.ts +27 -0
- package/src/constants.ts +71 -0
- package/src/exports/build.ts +93 -59
- package/src/exports/dev.ts +408 -398
- package/src/exports/serve.ts +12 -14
- package/src/types.ts +1 -1
- package/src/utils/getBaseViteConfig.ts +8 -2
- package/src/utils/getHtml.ts +12 -0
- package/src/utils/getVitePath.ts +1 -0
- package/src/utils/readVXRNConfig.ts +5 -0
- package/types/constants.d.ts +13 -0
- package/types/exports/dev.d.ts +0 -6
- package/types/types.d.ts +1 -1
- package/types/utils/getHtml.d.ts +8 -0
- package/types/utils/getOptionsFilled.d.ts +1 -1
- package/types/vendor/createExpoServer.d.ts +3 -1
- package/dist/cjs/build.js +0 -145
- package/dist/cjs/build.js.map +0 -6
- package/dist/cjs/build.native.js +0 -409
- package/dist/cjs/build.native.js.map +0 -6
- package/dist/cjs/commands/cli-build.js +0 -36
- package/dist/cjs/commands/cli-build.js.map +0 -6
- package/dist/cjs/commands/cli-build.native.js +0 -171
- package/dist/cjs/commands/cli-build.native.js.map +0 -6
- package/dist/cjs/commands/cli-dev.js +0 -52
- package/dist/cjs/commands/cli-dev.js.map +0 -6
- package/dist/cjs/commands/cli-dev.native.js +0 -217
- package/dist/cjs/commands/cli-dev.native.js.map +0 -6
- package/dist/cjs/commands/index.js +0 -34
- package/dist/cjs/commands/index.js.map +0 -6
- package/dist/cjs/commands/index.native.js +0 -45
- package/dist/cjs/commands/index.native.js.map +0 -6
- package/dist/cjs/create.js +0 -643
- package/dist/cjs/create.js.map +0 -6
- package/dist/cjs/create.native.js +0 -1318
- package/dist/cjs/create.native.js.map +0 -6
- package/dist/cjs/createDevServer.js +0 -601
- package/dist/cjs/createDevServer.js.map +0 -6
- package/dist/cjs/createDevServer.native.js +0 -1220
- package/dist/cjs/createDevServer.native.js.map +0 -6
- package/dist/cjs/createExpoServer.js +0 -34
- package/dist/cjs/createExpoServer.js.map +0 -6
- package/dist/cjs/createExpoServer.native.js +0 -42
- package/dist/cjs/createExpoServer.native.js.map +0 -6
- package/dist/cjs/dev/clientInjectPlugin.js +0 -67
- package/dist/cjs/dev/clientInjectPlugin.js.map +0 -6
- package/dist/cjs/dev/clientInjectPlugin.native.js +0 -191
- package/dist/cjs/dev/clientInjectPlugin.native.js.map +0 -6
- package/dist/cjs/dev/createDevServer.js +0 -1
- package/dist/cjs/dev/createDevServer.js.map +0 -6
- package/dist/cjs/dev/createDevServer.native.js +0 -2
- package/dist/cjs/dev/createDevServer.native.js.map +0 -6
- package/dist/cjs/dispose.js +0 -28
- package/dist/cjs/dispose.js.map +0 -6
- package/dist/cjs/dispose.native.js +0 -36
- package/dist/cjs/dispose.native.js.map +0 -6
- package/dist/cjs/exports/checkPatches.js +0 -62
- package/dist/cjs/exports/checkPatches.js.map +0 -6
- package/dist/cjs/exports/checkPatches.native.js +0 -289
- package/dist/cjs/exports/checkPatches.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 +0 -197
- package/dist/cjs/getVitePath.native.js.map +0 -6
- package/dist/cjs/nativePlugin.js +0 -89
- package/dist/cjs/nativePlugin.js.map +0 -6
- package/dist/cjs/nativePlugin.native.js +0 -346
- package/dist/cjs/nativePlugin.native.js.map +0 -6
- package/dist/cjs/utils/checkPatches.js +0 -62
- package/dist/cjs/utils/checkPatches.js.map +0 -6
- package/dist/cjs/utils/checkPatches.native.js +0 -289
- package/dist/cjs/utils/checkPatches.native.js.map +0 -6
- package/dist/cjs/utils/constants.js +0 -21
- package/dist/cjs/utils/constants.js.map +0 -6
- package/dist/cjs/utils/constants.native.js +0 -26
- package/dist/cjs/utils/constants.native.js.map +0 -6
- package/dist/cjs/utils/prerender.js +0 -1
- package/dist/cjs/utils/prerender.js.map +0 -6
- package/dist/cjs/utils/prerender.native.js +0 -2
- package/dist/cjs/utils/prerender.native.js.map +0 -6
- package/dist/cjs/utils.js.map +0 -6
- package/dist/cjs/utils.native.js.map +0 -6
- package/dist/esm/build.js +0 -128
- package/dist/esm/build.js.map +0 -6
- package/dist/esm/build.mjs +0 -119
- package/dist/esm/build.native.js +0 -385
- package/dist/esm/build.native.js.map +0 -6
- package/dist/esm/commands/cli-build.js +0 -23
- package/dist/esm/commands/cli-build.js.map +0 -6
- package/dist/esm/commands/cli-build.mjs +0 -22
- package/dist/esm/commands/cli-build.native.js +0 -156
- package/dist/esm/commands/cli-build.native.js.map +0 -6
- package/dist/esm/commands/cli-dev.js +0 -39
- package/dist/esm/commands/cli-dev.js.map +0 -6
- package/dist/esm/commands/cli-dev.mjs +0 -45
- package/dist/esm/commands/cli-dev.native.js +0 -202
- package/dist/esm/commands/cli-dev.native.js.map +0 -6
- package/dist/esm/commands/index.js +0 -10
- package/dist/esm/commands/index.js.map +0 -6
- package/dist/esm/commands/index.mjs +0 -8
- package/dist/esm/commands/index.native.js +0 -16
- package/dist/esm/commands/index.native.js.map +0 -6
- package/dist/esm/create.js +0 -655
- package/dist/esm/create.js.map +0 -6
- package/dist/esm/create.mjs +0 -622
- package/dist/esm/create.native.js +0 -1309
- package/dist/esm/create.native.js.map +0 -6
- package/dist/esm/createDevServer.js +0 -614
- package/dist/esm/createDevServer.js.map +0 -6
- package/dist/esm/createDevServer.mjs +0 -570
- package/dist/esm/createDevServer.native.js +0 -1211
- package/dist/esm/createDevServer.native.js.map +0 -6
- package/dist/esm/createExpoServer.js +0 -20
- package/dist/esm/createExpoServer.js.map +0 -6
- package/dist/esm/createExpoServer.mjs +0 -17
- package/dist/esm/createExpoServer.native.js +0 -22
- package/dist/esm/createExpoServer.native.js.map +0 -6
- package/dist/esm/dev/clientInjectPlugin.js +0 -43
- package/dist/esm/dev/clientInjectPlugin.js.map +0 -6
- package/dist/esm/dev/clientInjectPlugin.mjs +0 -57
- package/dist/esm/dev/clientInjectPlugin.native.js +0 -162
- package/dist/esm/dev/clientInjectPlugin.native.js.map +0 -6
- package/dist/esm/dev/createDevServer.js +0 -1
- package/dist/esm/dev/createDevServer.js.map +0 -6
- package/dist/esm/dev/createDevServer.mjs +0 -0
- package/dist/esm/dev/createDevServer.native.js +0 -1
- package/dist/esm/dev/createDevServer.native.js.map +0 -6
- package/dist/esm/dispose.js +0 -12
- package/dist/esm/dispose.js.map +0 -6
- package/dist/esm/dispose.mjs +0 -8
- package/dist/esm/dispose.native.js +0 -14
- package/dist/esm/dispose.native.js.map +0 -6
- package/dist/esm/exports/checkPatches.js +0 -40
- package/dist/esm/exports/checkPatches.js.map +0 -6
- package/dist/esm/exports/checkPatches.mjs +0 -31
- package/dist/esm/exports/checkPatches.native.js +0 -262
- package/dist/esm/exports/checkPatches.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/dist/esm/nativePlugin.js +0 -75
- package/dist/esm/nativePlugin.js.map +0 -6
- package/dist/esm/nativePlugin.mjs +0 -55
- package/dist/esm/nativePlugin.native.js +0 -327
- package/dist/esm/nativePlugin.native.js.map +0 -6
- package/dist/esm/utils/checkPatches.js +0 -40
- package/dist/esm/utils/checkPatches.js.map +0 -6
- package/dist/esm/utils/checkPatches.mjs +0 -31
- package/dist/esm/utils/checkPatches.native.js +0 -262
- package/dist/esm/utils/checkPatches.native.js.map +0 -6
- package/dist/esm/utils/constants.js +0 -5
- package/dist/esm/utils/constants.js.map +0 -6
- package/dist/esm/utils/constants.mjs +0 -2
- package/dist/esm/utils/constants.native.js +0 -5
- package/dist/esm/utils/constants.native.js.map +0 -6
- package/dist/esm/utils/prerender.js +0 -1
- package/dist/esm/utils/prerender.js.map +0 -6
- package/dist/esm/utils/prerender.mjs +0 -0
- package/dist/esm/utils/prerender.native.js +0 -1
- package/dist/esm/utils/prerender.native.js.map +0 -6
- package/dist/esm/utils.js +0 -12
- package/dist/esm/utils.js.map +0 -6
- package/dist/esm/utils.mjs +0 -8
- package/dist/esm/utils.native.js +0 -14
- package/dist/esm/utils.native.js.map +0 -6
- package/src/plugins/clientBundleTreeShakePlugin.tsx +0 -105
- package/src/vendor/createExpoServer.ts +0 -43
- package/src/vendor/repack/dev-server/src/createServer.ts +0 -128
- package/src/vendor/repack/dev-server/src/img/favicon.ico +0 -0
- package/src/vendor/repack/dev-server/src/index.ts +0 -2
- package/src/vendor/repack/dev-server/src/plugins/api/apiPlugin.ts +0 -50
- package/src/vendor/repack/dev-server/src/plugins/api/index.ts +0 -1
- package/src/vendor/repack/dev-server/src/plugins/compiler/compilerPlugin.ts +0 -84
- package/src/vendor/repack/dev-server/src/plugins/compiler/index.ts +0 -2
- package/src/vendor/repack/dev-server/src/plugins/compiler/types.ts +0 -37
- package/src/vendor/repack/dev-server/src/plugins/devtools/devtoolsPlugin.ts +0 -107
- package/src/vendor/repack/dev-server/src/plugins/devtools/index.ts +0 -1
- package/src/vendor/repack/dev-server/src/plugins/favicon/faviconPlugin.ts +0 -14
- package/src/vendor/repack/dev-server/src/plugins/favicon/index.ts +0 -1
- package/src/vendor/repack/dev-server/src/plugins/multipart/index.ts +0 -2
- package/src/vendor/repack/dev-server/src/plugins/multipart/multipartPlugin.ts +0 -77
- package/src/vendor/repack/dev-server/src/plugins/multipart/types.ts +0 -13
- package/src/vendor/repack/dev-server/src/plugins/symbolicate/Symbolicator.ts +0 -233
- package/src/vendor/repack/dev-server/src/plugins/symbolicate/index.ts +0 -3
- package/src/vendor/repack/dev-server/src/plugins/symbolicate/sybmolicatePlugin.ts +0 -48
- package/src/vendor/repack/dev-server/src/plugins/symbolicate/types.ts +0 -71
- package/src/vendor/repack/dev-server/src/plugins/wss/WebSocketRouter.ts +0 -74
- package/src/vendor/repack/dev-server/src/plugins/wss/WebSocketServer.ts +0 -60
- package/src/vendor/repack/dev-server/src/plugins/wss/index.ts +0 -3
- package/src/vendor/repack/dev-server/src/plugins/wss/servers/HermesInspectorProxy.ts +0 -158
- package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketApiServer.ts +0 -69
- package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketDebuggerServer.ts +0 -134
- package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketDevClientServer.ts +0 -74
- package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketEventsServer.ts +0 -205
- package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketHMRServer.ts +0 -97
- package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketMessageServer.ts +0 -401
- package/src/vendor/repack/dev-server/src/plugins/wss/types.ts +0 -17
- package/src/vendor/repack/dev-server/src/plugins/wss/wssPlugin.ts +0 -73
- package/src/vendor/repack/dev-server/src/types.ts +0 -197
- package/types/VXRNConfigFilled.d.ts +0 -21
- package/types/build.d.ts +0 -4
- package/types/commands/cli-build.d.ts +0 -3
- package/types/commands/cli-dev.d.ts +0 -3
- package/types/commands/index.d.ts +0 -6
- package/types/create.d.ts +0 -13
- package/types/createDevServer.d.ts +0 -13
- package/types/createExpoServer.d.ts +0 -4
- package/types/dev/bindKeypressInput.d.ts +0 -3
- package/types/dev/clientInjectPlugin.d.ts +0 -7
- package/types/dev/createDevServer.d.ts +0 -1
- package/types/dispose.d.ts +0 -3
- package/types/getBaseViteConfig.d.ts +0 -5
- package/types/getOptionsFIlled.d.ts +0 -21
- package/types/getVitePath.d.ts +0 -2
- package/types/nativePlugin.d.ts +0 -7
- package/types/plugins/clientBundleTreeShakePlugni.d.ts +0 -13
- package/types/plugins/server-tree-shake.d.ts +0 -13
- package/types/utils/checkPatches.d.ts +0 -3
- package/types/utils/constants.d.ts +0 -2
- package/types/utils/prerender.d.ts +0 -1
- package/types/utils.d.ts +0 -3
- package/types/vendor/repack/dev-server/src/createServer.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/index.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/api/apiPlugin.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/api/index.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/compiler/compilerPlugin.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/compiler/index.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/compiler/types.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/devtools/devtoolsPlugin.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/devtools/index.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/favicon/faviconPlugin.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/favicon/index.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/multipart/index.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/multipart/multipartPlugin.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/multipart/types.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/symbolicate/Symbolicator.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/symbolicate/index.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/symbolicate/sybmolicatePlugin.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/symbolicate/types.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/wss/WebSocketRouter.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/wss/WebSocketServer.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/wss/index.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/wss/servers/HermesInspectorProxy.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketApiServer.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketDebuggerServer.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketDevClientServer.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketEventsServer.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketHMRServer.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketMessageServer.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/wss/types.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/plugins/wss/wssPlugin.d.ts +0 -1
- package/types/vendor/repack/dev-server/src/types.d.ts +0 -1
package/dist/esm/exports/dev.js
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
createApp,
|
|
4
4
|
createRouter,
|
|
5
5
|
defineEventHandler,
|
|
6
|
-
defineWebSocketHandler,
|
|
7
6
|
eventHandler,
|
|
8
7
|
getQuery,
|
|
9
8
|
toNodeListener
|
|
@@ -28,122 +27,27 @@ import {
|
|
|
28
27
|
} from "vite";
|
|
29
28
|
import createViteFlow from "@vxrn/vite-flow";
|
|
30
29
|
import { resolve as importMetaResolve } from "import-meta-resolve";
|
|
31
|
-
import {
|
|
30
|
+
import { depsToOptimize, nativeExtensions, ssrOptimizeDeps, webExtensions } from "../constants";
|
|
32
31
|
import { clientInjectionsPlugin } from "../plugins/clientInjectPlugin";
|
|
33
32
|
import { reactNativeCommonJsPlugin } from "../plugins/reactNativeCommonJsPlugin";
|
|
34
33
|
import { getBaseViteConfig } from "../utils/getBaseViteConfig";
|
|
35
34
|
import { getOptionsFilled } from "../utils/getOptionsFilled";
|
|
36
35
|
import { getVitePath } from "../utils/getVitePath";
|
|
37
36
|
import { checkPatches } from "../utils/patches";
|
|
38
|
-
|
|
39
|
-
const
|
|
37
|
+
let isBuildingNativeBundle = null;
|
|
38
|
+
const hotUpdateCache = /* @__PURE__ */ new Map(), resolveFile = (path) => {
|
|
40
39
|
try {
|
|
41
40
|
return importMetaResolve(path, import.meta.url).replace("file://", "");
|
|
42
41
|
} catch {
|
|
43
42
|
return require.resolve(path);
|
|
44
43
|
}
|
|
45
|
-
},
|
|
46
|
-
".native.tsx",
|
|
47
|
-
".native.jsx",
|
|
48
|
-
".native.js",
|
|
49
|
-
".tsx",
|
|
50
|
-
".ts",
|
|
51
|
-
".js",
|
|
52
|
-
".css",
|
|
53
|
-
".json"
|
|
54
|
-
], extensions = [
|
|
55
|
-
".web.tsx",
|
|
56
|
-
".tsx",
|
|
57
|
-
".web.ts",
|
|
58
|
-
".ts",
|
|
59
|
-
".web.jsx",
|
|
60
|
-
".jsx",
|
|
61
|
-
".web.js",
|
|
62
|
-
".js",
|
|
63
|
-
".css",
|
|
64
|
-
".json"
|
|
65
|
-
], { ensureDir, pathExists, pathExistsSync } = FSExtra, dev = async (optionsIn) => {
|
|
44
|
+
}, { ensureDir, pathExists, pathExistsSync } = FSExtra, dev = async (optionsIn) => {
|
|
66
45
|
const options = await getOptionsFilled(optionsIn), { host, port, root, cacheDir } = options;
|
|
67
46
|
bindKeypressInput(), checkPatches(options).catch((err) => {
|
|
68
47
|
console.error(`
|
|
69
48
|
\u{1F97A} couldn't patch`, err);
|
|
70
49
|
}), await ensureDir(cacheDir);
|
|
71
|
-
const
|
|
72
|
-
reactJSX: join(cacheDir, "react-jsx-runtime.js"),
|
|
73
|
-
react: join(cacheDir, "react.js"),
|
|
74
|
-
reactNative: join(cacheDir, "react-native.js")
|
|
75
|
-
};
|
|
76
|
-
await pathExists(prebuilds.reactNative) || (console.info("Pre-building react, react-native react/jsx-runtime (one time cost)..."), await Promise.all([
|
|
77
|
-
buildReactNative({
|
|
78
|
-
entryPoints: [resolveFile("react-native")],
|
|
79
|
-
outfile: prebuilds.reactNative
|
|
80
|
-
}),
|
|
81
|
-
buildReact({
|
|
82
|
-
entryPoints: [resolveFile("react")],
|
|
83
|
-
outfile: prebuilds.react
|
|
84
|
-
}),
|
|
85
|
-
buildReactJSX({
|
|
86
|
-
entryPoints: [resolveFile("react/jsx-dev-runtime")],
|
|
87
|
-
outfile: prebuilds.reactJSX
|
|
88
|
-
})
|
|
89
|
-
]));
|
|
90
|
-
const viteFlow = options.flow ? createViteFlow(options.flow) : null, templateFile = resolveFile("vxrn/react-native-template.js"), jsxRuntime = {
|
|
91
|
-
// alias: 'virtual:react-jsx',
|
|
92
|
-
alias: prebuilds.reactJSX,
|
|
93
|
-
contents: await readFile(prebuilds.reactJSX, "utf-8")
|
|
94
|
-
}, virtualModules = {
|
|
95
|
-
"react-native": {
|
|
96
|
-
// alias: 'virtual:react-native',
|
|
97
|
-
alias: prebuilds.reactNative,
|
|
98
|
-
contents: await readFile(prebuilds.reactNative, "utf-8")
|
|
99
|
-
},
|
|
100
|
-
react: {
|
|
101
|
-
// alias: 'virtual:react',
|
|
102
|
-
alias: prebuilds.react,
|
|
103
|
-
contents: await readFile(prebuilds.react, "utf-8")
|
|
104
|
-
},
|
|
105
|
-
"react/jsx-runtime": jsxRuntime,
|
|
106
|
-
"react/jsx-dev-runtime": jsxRuntime
|
|
107
|
-
}, swapRnPlugin = {
|
|
108
|
-
name: "swap-react-native",
|
|
109
|
-
enforce: "pre",
|
|
110
|
-
resolveId(id, importer = "") {
|
|
111
|
-
if (id.startsWith("react-native/Libraries"))
|
|
112
|
-
return `virtual:rn-internals:${id}`;
|
|
113
|
-
if (id === "react-native-web")
|
|
114
|
-
return prebuilds.reactNative;
|
|
115
|
-
for (const targetId in virtualModules)
|
|
116
|
-
if (id === targetId || id.includes(`node_modules/${targetId}/`))
|
|
117
|
-
return virtualModules[targetId].alias;
|
|
118
|
-
if (id[0] === ".") {
|
|
119
|
-
const absolutePath = resolve(dirname(importer), id), nativePath = absolutePath.replace(/(.m?js)/, ".native.js");
|
|
120
|
-
if (nativePath === id)
|
|
121
|
-
return;
|
|
122
|
-
try {
|
|
123
|
-
const directoryPath = absolutePath + "/index.native.js", directoryNonNativePath = absolutePath + "/index.js";
|
|
124
|
-
if (pathExistsSync(directoryPath))
|
|
125
|
-
return directoryPath;
|
|
126
|
-
if (pathExistsSync(directoryNonNativePath))
|
|
127
|
-
return directoryNonNativePath;
|
|
128
|
-
if (pathExistsSync(nativePath))
|
|
129
|
-
return nativePath;
|
|
130
|
-
} catch (err) {
|
|
131
|
-
console.warn("error probably fine", err);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
load(id) {
|
|
136
|
-
if (id.startsWith("virtual:rn-internals"))
|
|
137
|
-
return `const ___val = __cachedModules["${id.replace("virtual:rn-internals:", "")}"]
|
|
138
|
-
const ___defaultVal = ___val ? ___val.default || ___val : ___val
|
|
139
|
-
export default ___defaultVal`;
|
|
140
|
-
for (const targetId in virtualModules) {
|
|
141
|
-
const info = virtualModules[targetId];
|
|
142
|
-
if (id === info.alias)
|
|
143
|
-
return info.contents;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}, { serverConfig, hotUpdateCache } = await getViteServerConfig(options), viteServer = await createServer(serverConfig), resolvedConfig = await resolveConfig(serverConfig, "serve"), viteRNClientPlugin = clientInjectionsPlugin(resolvedConfig);
|
|
50
|
+
const serverConfig = await getViteServerConfig(options), viteServer = await createServer(serverConfig), resolvedConfig = await resolveConfig(serverConfig, "serve"), viteRNClientPlugin = clientInjectionsPlugin(resolvedConfig);
|
|
147
51
|
viteServer.watcher.addListener("change", async (path) => {
|
|
148
52
|
const id = path.replace(process.cwd(), "");
|
|
149
53
|
if (!(!id.endsWith("tsx") && !id.endsWith("jsx")))
|
|
@@ -152,20 +56,16 @@ const depsToOptimize = ["react", "react-dom", "@react-native/normalize-color"],
|
|
|
152
56
|
} catch (err) {
|
|
153
57
|
console.info("err", err);
|
|
154
58
|
}
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
await viteServer.listen();
|
|
158
|
-
const vitePort = viteServer.config.server.port;
|
|
159
|
-
console.info("vite running on", vitePort);
|
|
160
|
-
const router = createRouter(), app = createApp({
|
|
59
|
+
}), await viteServer.listen();
|
|
60
|
+
const vitePort = viteServer.config.server.port, router = createRouter(), app = createApp({
|
|
161
61
|
onError: (error) => {
|
|
162
62
|
console.error(error);
|
|
163
63
|
},
|
|
164
64
|
onRequest: (event) => {
|
|
165
|
-
console.info(" \u2192", event.path);
|
|
65
|
+
process.env.DEBUG && console.info(" \u2192", event.path);
|
|
166
66
|
}
|
|
167
67
|
});
|
|
168
|
-
|
|
68
|
+
router.get(
|
|
169
69
|
"/file",
|
|
170
70
|
defineEventHandler((e) => {
|
|
171
71
|
const query = getQuery(e);
|
|
@@ -180,7 +80,7 @@ const depsToOptimize = ["react", "react-dom", "@react-native/normalize-color"],
|
|
|
180
80
|
})
|
|
181
81
|
), router.get(
|
|
182
82
|
"/index.bundle",
|
|
183
|
-
defineEventHandler(async (e) => new Response(await
|
|
83
|
+
defineEventHandler(async (e) => new Response(await getReactNativeBundle(options, viteRNClientPlugin), {
|
|
184
84
|
headers: {
|
|
185
85
|
"content-type": "text/javascript"
|
|
186
86
|
}
|
|
@@ -199,67 +99,81 @@ const depsToOptimize = ["react", "react-dom", "@react-native/normalize-color"],
|
|
|
199
99
|
const clients = /* @__PURE__ */ new Set(), socket = new WebSocket(`ws://localhost:${vitePort}/__vxrnhmr`, "vite-hmr");
|
|
200
100
|
socket.on("message", (msg) => {
|
|
201
101
|
const message = msg.toString();
|
|
202
|
-
console.info(clients.size, "message", message);
|
|
203
102
|
for (const listener of [...clients])
|
|
204
103
|
listener.send(message);
|
|
205
104
|
}), socket.on("error", (err) => {
|
|
206
105
|
console.info("error bridging socket to vite", err);
|
|
207
106
|
}), app.use(
|
|
208
107
|
"/__vxrnhmr",
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
console.debug("[hmr:web] open", peer), clients.add(peer);
|
|
212
|
-
},
|
|
213
|
-
message(peer, message) {
|
|
214
|
-
socket.send(message.rawData);
|
|
215
|
-
},
|
|
216
|
-
close(peer, event) {
|
|
217
|
-
console.info("[hmr:web] close", peer, event), clients.delete(peer);
|
|
108
|
+
defineEventHandler({
|
|
109
|
+
handler() {
|
|
218
110
|
},
|
|
219
|
-
|
|
220
|
-
|
|
111
|
+
websocket: {
|
|
112
|
+
open(peer) {
|
|
113
|
+
process.env.DEBUG && console.debug("[hmr:web] open", peer), clients.add(peer);
|
|
114
|
+
},
|
|
115
|
+
message(peer, message) {
|
|
116
|
+
socket.send(message.rawData);
|
|
117
|
+
},
|
|
118
|
+
close(peer, event) {
|
|
119
|
+
process.env.DEBUG && console.info("[hmr:web] close", peer, event), clients.delete(peer);
|
|
120
|
+
},
|
|
121
|
+
error(peer, error) {
|
|
122
|
+
console.error("[hmr:web] error", peer, error);
|
|
123
|
+
}
|
|
221
124
|
}
|
|
222
125
|
})
|
|
223
126
|
);
|
|
224
127
|
}
|
|
225
128
|
app.use(
|
|
226
129
|
"/__hmr",
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
console.debug("[hmr] open", peer);
|
|
230
|
-
},
|
|
231
|
-
message(peer, message) {
|
|
232
|
-
console.info("[hmr] message", peer, message), message.text().includes("ping") && peer.send("pong");
|
|
130
|
+
defineEventHandler({
|
|
131
|
+
handler() {
|
|
233
132
|
},
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
133
|
+
websocket: {
|
|
134
|
+
open(peer) {
|
|
135
|
+
console.debug("[hmr] open", peer);
|
|
136
|
+
},
|
|
137
|
+
message(peer, message) {
|
|
138
|
+
console.info("[hmr] message", peer, message), message.text().includes("ping") && peer.send("pong");
|
|
139
|
+
},
|
|
140
|
+
close(peer, event) {
|
|
141
|
+
console.info("[hmr] close", peer, event);
|
|
142
|
+
},
|
|
143
|
+
error(peer, error) {
|
|
144
|
+
console.error("[hmr] error", peer, error);
|
|
145
|
+
}
|
|
239
146
|
}
|
|
240
147
|
})
|
|
148
|
+
), app.use(
|
|
149
|
+
"/symbolicate",
|
|
150
|
+
defineEventHandler(() => "TODO")
|
|
241
151
|
), app.use(
|
|
242
152
|
"/__client",
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
console.info("[client] open", peer);
|
|
153
|
+
defineEventHandler({
|
|
154
|
+
handler() {
|
|
246
155
|
},
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
156
|
+
websocket: {
|
|
157
|
+
open(peer) {
|
|
158
|
+
console.info("[client] open", peer);
|
|
159
|
+
},
|
|
160
|
+
message(peer, messageRaw) {
|
|
161
|
+
const message = JSON.parse(messageRaw.text());
|
|
162
|
+
switch (message.type) {
|
|
163
|
+
case "client-log": {
|
|
164
|
+
console.info(`\u{1FAB5} [${message.level}]`, ...message.data);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
default:
|
|
168
|
+
console.warn("[client] Unknown message type", message);
|
|
253
169
|
}
|
|
254
|
-
|
|
255
|
-
|
|
170
|
+
},
|
|
171
|
+
close(peer, event) {
|
|
172
|
+
console.info("[client] close", peer, event);
|
|
173
|
+
},
|
|
174
|
+
error(peer, error) {
|
|
175
|
+
console.error("[client] error", peer, error);
|
|
256
176
|
}
|
|
257
|
-
},
|
|
258
|
-
close(peer, event) {
|
|
259
|
-
console.info("[client] close", peer, event);
|
|
260
|
-
},
|
|
261
|
-
error(peer, error) {
|
|
262
|
-
console.error("[client] error", peer, error);
|
|
263
177
|
}
|
|
264
178
|
})
|
|
265
179
|
);
|
|
@@ -281,114 +195,115 @@ const depsToOptimize = ["react", "react-dom", "@react-native/normalize-color"],
|
|
|
281
195
|
await Promise.all([server.close(), viteServer.close()]);
|
|
282
196
|
}
|
|
283
197
|
};
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
filename
|
|
303
|
-
},
|
|
304
|
-
(err, result) => {
|
|
305
|
-
(!result || err) && rej(err || "no res"), res(result.code);
|
|
306
|
-
}
|
|
307
|
-
);
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
let buildConfig = {
|
|
311
|
-
plugins: [
|
|
312
|
-
viteFlow,
|
|
313
|
-
swapRnPlugin,
|
|
198
|
+
};
|
|
199
|
+
async function getReactNativeBundle(options, viteRNClientPlugin) {
|
|
200
|
+
const { root, port, cacheDir } = options;
|
|
201
|
+
if (process.env.LOAD_TMP_BUNDLE) {
|
|
202
|
+
const tmpBundle = join(process.cwd(), "bundle.tmp.js");
|
|
203
|
+
if (await pathExists(tmpBundle))
|
|
204
|
+
return console.info("\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F returning temp bundle \u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F", tmpBundle), await readFile(tmpBundle, "utf-8");
|
|
205
|
+
}
|
|
206
|
+
if (isBuildingNativeBundle)
|
|
207
|
+
return await isBuildingNativeBundle;
|
|
208
|
+
let done;
|
|
209
|
+
isBuildingNativeBundle = new Promise((res) => {
|
|
210
|
+
done = res;
|
|
211
|
+
});
|
|
212
|
+
async function babelReanimated(input, filename) {
|
|
213
|
+
return await new Promise((res, rej) => {
|
|
214
|
+
babel.transform(
|
|
215
|
+
input,
|
|
314
216
|
{
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (code.includes("worklet"))
|
|
318
|
-
return await babelReanimated(code, id);
|
|
319
|
-
}
|
|
217
|
+
plugins: ["react-native-reanimated/plugin"],
|
|
218
|
+
filename
|
|
320
219
|
},
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
reactNativeCommonJsPlugin({
|
|
324
|
-
root,
|
|
325
|
-
port,
|
|
326
|
-
mode: "build"
|
|
327
|
-
}),
|
|
328
|
-
viteReactPlugin({
|
|
329
|
-
tsDecorators: !0,
|
|
330
|
-
mode: "build"
|
|
331
|
-
}),
|
|
332
|
-
{
|
|
333
|
-
name: "treat-js-files-as-jsx",
|
|
334
|
-
async transform(code, id) {
|
|
335
|
-
return id.match(/expo-status-bar/) ? transformWithEsbuild(code, id, {
|
|
336
|
-
loader: "jsx",
|
|
337
|
-
jsx: "automatic"
|
|
338
|
-
}) : null;
|
|
339
|
-
}
|
|
220
|
+
(err, result) => {
|
|
221
|
+
(!result || err) && rej(err || "no res"), res(result.code);
|
|
340
222
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
let nativeBuildConfig = {
|
|
227
|
+
plugins: [
|
|
228
|
+
options.flow ? createViteFlow(options.flow) : null,
|
|
229
|
+
swapPrebuiltReactModules(cacheDir),
|
|
230
|
+
{
|
|
231
|
+
name: "reanimated",
|
|
232
|
+
async transform(code, id) {
|
|
233
|
+
if (code.includes("worklet"))
|
|
234
|
+
return await babelReanimated(code, id);
|
|
349
235
|
}
|
|
350
236
|
},
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
preserveModules: !0,
|
|
369
|
-
format: "cjs"
|
|
370
|
-
}
|
|
237
|
+
viteRNClientPlugin,
|
|
238
|
+
reactNativeCommonJsPlugin({
|
|
239
|
+
root,
|
|
240
|
+
port,
|
|
241
|
+
mode: "build"
|
|
242
|
+
}),
|
|
243
|
+
viteReactPlugin({
|
|
244
|
+
tsDecorators: !0,
|
|
245
|
+
mode: "build"
|
|
246
|
+
}),
|
|
247
|
+
{
|
|
248
|
+
name: "treat-js-files-as-jsx",
|
|
249
|
+
async transform(code, id) {
|
|
250
|
+
return id.match(/expo-status-bar/) ? transformWithEsbuild(code, id, {
|
|
251
|
+
loader: "jsx",
|
|
252
|
+
jsx: "automatic"
|
|
253
|
+
}) : null;
|
|
371
254
|
}
|
|
372
255
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
256
|
+
].filter(Boolean),
|
|
257
|
+
appType: "custom",
|
|
258
|
+
root,
|
|
259
|
+
clearScreen: !1,
|
|
260
|
+
optimizeDeps: {
|
|
261
|
+
include: depsToOptimize,
|
|
262
|
+
esbuildOptions: {
|
|
263
|
+
jsx: "automatic"
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
resolve: {
|
|
267
|
+
extensions: nativeExtensions
|
|
268
|
+
},
|
|
269
|
+
mode: "development",
|
|
270
|
+
define: {
|
|
271
|
+
"process.env.NODE_ENV": '"development"'
|
|
272
|
+
},
|
|
273
|
+
build: {
|
|
274
|
+
ssr: !1,
|
|
275
|
+
minify: !1,
|
|
276
|
+
commonjsOptions: {
|
|
277
|
+
transformMixedEsModules: !0
|
|
278
|
+
},
|
|
279
|
+
rollupOptions: {
|
|
280
|
+
treeshake: !1,
|
|
281
|
+
preserveEntrySignatures: "strict",
|
|
282
|
+
output: {
|
|
283
|
+
preserveModules: !0,
|
|
284
|
+
format: "cjs"
|
|
386
285
|
}
|
|
387
|
-
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
options.nativeConfig && (nativeBuildConfig = mergeConfig(nativeBuildConfig, options.nativeConfig)), await resolveConfig(nativeBuildConfig, "build");
|
|
290
|
+
const buildOutput = await build(nativeBuildConfig);
|
|
291
|
+
if (!("output" in buildOutput))
|
|
292
|
+
throw "\u274C";
|
|
293
|
+
let appCode = buildOutput.output.sort((a, b) => a.isEntry ? 1 : -1).map((outputModule) => {
|
|
294
|
+
if (outputModule.type == "chunk") {
|
|
295
|
+
const importsMap = {
|
|
296
|
+
currentPath: outputModule.fileName
|
|
297
|
+
};
|
|
298
|
+
for (const imp of outputModule.imports) {
|
|
299
|
+
const relativePath = relative(dirname(outputModule.fileName), imp);
|
|
300
|
+
importsMap[relativePath[0] === "." ? relativePath : "./" + relativePath] = imp;
|
|
301
|
+
}
|
|
302
|
+
return outputModule.isEntry && (entryRoot = dirname(outputModule.fileName)), `
|
|
388
303
|
___modules___["${outputModule.fileName}"] = ((exports, module) => {
|
|
389
|
-
|
|
304
|
+
const require = createRequire(${JSON.stringify(importsMap, null, 2)})
|
|
390
305
|
|
|
391
|
-
|
|
306
|
+
${outputModule.code}
|
|
392
307
|
})
|
|
393
308
|
|
|
394
309
|
${outputModule.isEntry ? `
|
|
@@ -398,16 +313,98 @@ __require("react-native")
|
|
|
398
313
|
__require("${outputModule.fileName}")
|
|
399
314
|
` : ""}
|
|
400
315
|
`;
|
|
401
|
-
|
|
402
|
-
|
|
316
|
+
}
|
|
317
|
+
}).join(`
|
|
403
318
|
`);
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
319
|
+
if (!appCode)
|
|
320
|
+
throw "\u274C";
|
|
321
|
+
appCode = appCode.replaceAll("undefined.accept(() => {})", "").replaceAll("undefined.accept(function() {});", "").replaceAll("(void 0).accept(() => {})", "").replaceAll("(void 0).accept(function() {});", "").replaceAll('dist/esm/index.mjs"', 'dist/esm/index.js"');
|
|
322
|
+
const appRootParent = join(root, "..", ".."), prebuilds = {
|
|
323
|
+
reactJSX: join(cacheDir, "react-jsx-runtime.js"),
|
|
324
|
+
react: join(cacheDir, "react.js"),
|
|
325
|
+
reactNative: join(cacheDir, "react-native.js")
|
|
326
|
+
}, templateFile = resolveFile("vxrn/react-native-template.js"), out = (await readFile(templateFile, "utf-8")).replace("_virtual/virtual_react-native.js", relative(appRootParent, prebuilds.reactNative)).replace("_virtual/virtual_react.js", relative(appRootParent, prebuilds.react)).replaceAll("_virtual/virtual_react-jsx.js", relative(appRootParent, prebuilds.reactJSX)) + appCode;
|
|
327
|
+
return done(out), isBuildingNativeBundle = null, out;
|
|
328
|
+
}
|
|
329
|
+
async function swapPrebuiltReactModules(cacheDir) {
|
|
330
|
+
const prebuilds = {
|
|
331
|
+
reactJSX: join(cacheDir, "react-jsx-runtime.js"),
|
|
332
|
+
react: join(cacheDir, "react.js"),
|
|
333
|
+
reactNative: join(cacheDir, "react-native.js")
|
|
334
|
+
};
|
|
335
|
+
await pathExists(prebuilds.reactNative) || (console.info("Pre-building react, react-native react/jsx-runtime (one time cost)..."), await Promise.all([
|
|
336
|
+
buildReactNative({
|
|
337
|
+
entryPoints: [resolveFile("react-native")],
|
|
338
|
+
outfile: prebuilds.reactNative
|
|
339
|
+
}),
|
|
340
|
+
buildReact({
|
|
341
|
+
entryPoints: [resolveFile("react")],
|
|
342
|
+
outfile: prebuilds.react
|
|
343
|
+
}),
|
|
344
|
+
buildReactJSX({
|
|
345
|
+
entryPoints: [resolveFile("react/jsx-dev-runtime")],
|
|
346
|
+
outfile: prebuilds.reactJSX
|
|
347
|
+
})
|
|
348
|
+
]));
|
|
349
|
+
const jsxRuntime = {
|
|
350
|
+
// alias: 'virtual:react-jsx',
|
|
351
|
+
alias: prebuilds.reactJSX,
|
|
352
|
+
contents: await readFile(prebuilds.reactJSX, "utf-8")
|
|
353
|
+
}, virtualModules = {
|
|
354
|
+
"react-native": {
|
|
355
|
+
// alias: 'virtual:react-native',
|
|
356
|
+
alias: prebuilds.reactNative,
|
|
357
|
+
contents: await readFile(prebuilds.reactNative, "utf-8")
|
|
358
|
+
},
|
|
359
|
+
react: {
|
|
360
|
+
// alias: 'virtual:react',
|
|
361
|
+
alias: prebuilds.react,
|
|
362
|
+
contents: await readFile(prebuilds.react, "utf-8")
|
|
363
|
+
},
|
|
364
|
+
"react/jsx-runtime": jsxRuntime,
|
|
365
|
+
"react/jsx-dev-runtime": jsxRuntime
|
|
366
|
+
};
|
|
367
|
+
return {
|
|
368
|
+
name: "swap-react-native",
|
|
369
|
+
enforce: "pre",
|
|
370
|
+
resolveId(id, importer = "") {
|
|
371
|
+
if (id.startsWith("react-native/Libraries"))
|
|
372
|
+
return `virtual:rn-internals:${id}`;
|
|
373
|
+
if (id === "react-native-web")
|
|
374
|
+
return prebuilds.reactNative;
|
|
375
|
+
for (const targetId in virtualModules)
|
|
376
|
+
if (id === targetId || id.includes(`node_modules/${targetId}/`))
|
|
377
|
+
return virtualModules[targetId].alias;
|
|
378
|
+
if (isBuildingNativeBundle && id[0] === ".") {
|
|
379
|
+
const absolutePath = resolve(dirname(importer), id), nativePath = absolutePath.replace(/(.m?js)/, ".native.js");
|
|
380
|
+
if (nativePath === id)
|
|
381
|
+
return;
|
|
382
|
+
try {
|
|
383
|
+
const directoryPath = absolutePath + "/index.native.js", directoryNonNativePath = absolutePath + "/index.js";
|
|
384
|
+
if (pathExistsSync(directoryPath))
|
|
385
|
+
return directoryPath;
|
|
386
|
+
if (pathExistsSync(directoryNonNativePath))
|
|
387
|
+
return directoryNonNativePath;
|
|
388
|
+
if (pathExistsSync(nativePath))
|
|
389
|
+
return nativePath;
|
|
390
|
+
} catch (err) {
|
|
391
|
+
console.warn("error probably fine", err);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
load(id) {
|
|
396
|
+
if (id.startsWith("virtual:rn-internals"))
|
|
397
|
+
return `const ___val = __cachedModules["${id.replace("virtual:rn-internals:", "")}"]
|
|
398
|
+
const ___defaultVal = ___val ? ___val.default || ___val : ___val
|
|
399
|
+
export default ___defaultVal`;
|
|
400
|
+
for (const targetId in virtualModules) {
|
|
401
|
+
const info = virtualModules[targetId];
|
|
402
|
+
if (id === info.alias)
|
|
403
|
+
return info.contents;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}
|
|
411
408
|
function getIndexJsonResponse({ port, root }) {
|
|
412
409
|
return {
|
|
413
410
|
name: "myapp",
|
|
@@ -492,8 +489,43 @@ function isWithin(outer, inner) {
|
|
|
492
489
|
return !rel.startsWith("../") && rel !== "..";
|
|
493
490
|
}
|
|
494
491
|
let entryRoot = "";
|
|
495
|
-
async function getViteServerConfig(
|
|
496
|
-
const
|
|
492
|
+
async function getViteServerConfig(config) {
|
|
493
|
+
const { root, host, webConfig, cacheDir } = config;
|
|
494
|
+
let serverConfig = mergeConfig(
|
|
495
|
+
getBaseViteConfig({
|
|
496
|
+
mode: "development"
|
|
497
|
+
}),
|
|
498
|
+
{
|
|
499
|
+
root,
|
|
500
|
+
clearScreen: !1,
|
|
501
|
+
plugins: [reactNativeHMRPlugin(config)],
|
|
502
|
+
optimizeDeps: {
|
|
503
|
+
include: depsToOptimize,
|
|
504
|
+
exclude: [`${cacheDir}/*`],
|
|
505
|
+
esbuildOptions: {
|
|
506
|
+
resolveExtensions: webExtensions
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
ssr: {
|
|
510
|
+
noExternal: !0,
|
|
511
|
+
optimizeDeps: ssrOptimizeDeps
|
|
512
|
+
},
|
|
513
|
+
server: {
|
|
514
|
+
hmr: {
|
|
515
|
+
path: "/__vxrnhmr"
|
|
516
|
+
},
|
|
517
|
+
cors: !0,
|
|
518
|
+
host
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
);
|
|
522
|
+
return webConfig && (serverConfig = mergeConfig(serverConfig, webConfig)), serverConfig = {
|
|
523
|
+
...serverConfig,
|
|
524
|
+
plugins: [...serverConfig.plugins]
|
|
525
|
+
}, serverConfig;
|
|
526
|
+
}
|
|
527
|
+
function reactNativeHMRPlugin({ root }) {
|
|
528
|
+
return {
|
|
497
529
|
name: "client-transform",
|
|
498
530
|
async handleHotUpdate({ read, modules, file }) {
|
|
499
531
|
try {
|
|
@@ -537,46 +569,10 @@ async function getViteServerConfig({ root, host, webConfig, cacheDir }) {
|
|
|
537
569
|
}
|
|
538
570
|
}
|
|
539
571
|
};
|
|
540
|
-
let serverConfig = mergeConfig(
|
|
541
|
-
getBaseViteConfig({
|
|
542
|
-
mode: "development"
|
|
543
|
-
}),
|
|
544
|
-
{
|
|
545
|
-
root,
|
|
546
|
-
clearScreen: !1,
|
|
547
|
-
plugins: [
|
|
548
|
-
reactNativeHMRPlugin,
|
|
549
|
-
clientBundleTreeShakePlugin({})
|
|
550
|
-
],
|
|
551
|
-
optimizeDeps: {
|
|
552
|
-
include: depsToOptimize,
|
|
553
|
-
exclude: [`${cacheDir}/*`],
|
|
554
|
-
force: !0,
|
|
555
|
-
esbuildOptions: {
|
|
556
|
-
resolveExtensions: extensions
|
|
557
|
-
}
|
|
558
|
-
},
|
|
559
|
-
server: {
|
|
560
|
-
hmr: {
|
|
561
|
-
path: "/__vxrnhmr"
|
|
562
|
-
},
|
|
563
|
-
cors: !0,
|
|
564
|
-
host
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
);
|
|
568
|
-
return webConfig && (serverConfig = mergeConfig(serverConfig, webConfig)), serverConfig = {
|
|
569
|
-
...serverConfig,
|
|
570
|
-
plugins: [...serverConfig.plugins]
|
|
571
|
-
}, {
|
|
572
|
-
serverConfig,
|
|
573
|
-
hotUpdateCache
|
|
574
|
-
};
|
|
575
572
|
}
|
|
576
573
|
export {
|
|
577
574
|
bindKeypressInput,
|
|
578
575
|
dev,
|
|
579
|
-
getViteServerConfig,
|
|
580
576
|
resolveFile
|
|
581
577
|
};
|
|
582
578
|
//# sourceMappingURL=dev.js.map
|