vxrn 0.1.46 → 0.1.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/cjs/cli.js +12 -2
  2. package/dist/cjs/cli.js.map +1 -1
  3. package/dist/cjs/cli.native.js +47 -35
  4. package/dist/cjs/cli.native.js.map +2 -2
  5. package/dist/cjs/constants.js +2 -70
  6. package/dist/cjs/constants.js.map +1 -1
  7. package/dist/cjs/constants.native.js +2 -105
  8. package/dist/cjs/constants.native.js.map +2 -2
  9. package/dist/cjs/exports/build.js +50 -62
  10. package/dist/cjs/exports/build.js.map +1 -1
  11. package/dist/cjs/exports/build.native.js +224 -205
  12. package/dist/cjs/exports/build.native.js.map +2 -2
  13. package/dist/cjs/exports/dev.js +39 -24
  14. package/dist/cjs/exports/dev.js.map +1 -1
  15. package/dist/cjs/exports/dev.native.js +48 -50
  16. package/dist/cjs/exports/dev.native.js.map +2 -2
  17. package/dist/cjs/utils/getHtml.js +9 -6
  18. package/dist/cjs/utils/getHtml.js.map +1 -1
  19. package/dist/cjs/utils/getHtml.native.js +9 -5
  20. package/dist/cjs/utils/getHtml.native.js.map +2 -2
  21. package/dist/cjs/utils/getOptimizeDeps.js +132 -0
  22. package/dist/cjs/utils/getOptimizeDeps.js.map +6 -0
  23. package/dist/cjs/utils/getOptimizeDeps.native.js +171 -0
  24. package/dist/cjs/utils/getOptimizeDeps.native.js.map +6 -0
  25. package/dist/cjs/utils/getVitePath.js +3 -1
  26. package/dist/cjs/utils/getVitePath.js.map +1 -1
  27. package/dist/cjs/utils/getVitePath.native.js +1 -1
  28. package/dist/cjs/utils/getVitePath.native.js.map +1 -1
  29. package/dist/cjs/utils/readVXRNConfig.js +5 -3
  30. package/dist/cjs/utils/readVXRNConfig.js.map +1 -1
  31. package/dist/cjs/utils/readVXRNConfig.native.js +5 -1
  32. package/dist/cjs/utils/readVXRNConfig.native.js.map +2 -2
  33. package/dist/esm/cli.js +12 -2
  34. package/dist/esm/cli.js.map +1 -1
  35. package/dist/esm/cli.mjs +12 -2
  36. package/dist/esm/cli.native.js +47 -35
  37. package/dist/esm/cli.native.js.map +2 -2
  38. package/dist/esm/constants.js +2 -70
  39. package/dist/esm/constants.js.map +1 -1
  40. package/dist/esm/constants.mjs +2 -13
  41. package/dist/esm/constants.native.js +2 -102
  42. package/dist/esm/constants.native.js.map +2 -2
  43. package/dist/esm/exports/build.js +47 -60
  44. package/dist/esm/exports/build.js.map +1 -1
  45. package/dist/esm/exports/build.mjs +64 -63
  46. package/dist/esm/exports/build.native.js +223 -204
  47. package/dist/esm/exports/build.native.js.map +2 -2
  48. package/dist/esm/exports/dev.js +37 -21
  49. package/dist/esm/exports/dev.js.map +1 -1
  50. package/dist/esm/exports/dev.mjs +39 -30
  51. package/dist/esm/exports/dev.native.js +46 -47
  52. package/dist/esm/exports/dev.native.js.map +2 -2
  53. package/dist/esm/utils/getHtml.js +9 -6
  54. package/dist/esm/utils/getHtml.js.map +1 -1
  55. package/dist/esm/utils/getHtml.mjs +11 -4
  56. package/dist/esm/utils/getHtml.native.js +9 -5
  57. package/dist/esm/utils/getHtml.native.js.map +2 -2
  58. package/dist/esm/utils/getOptimizeDeps.js +116 -0
  59. package/dist/esm/utils/getOptimizeDeps.js.map +6 -0
  60. package/dist/esm/utils/getOptimizeDeps.mjs +18 -0
  61. package/dist/esm/utils/getOptimizeDeps.native.js +150 -0
  62. package/dist/esm/utils/getOptimizeDeps.native.js.map +6 -0
  63. package/dist/esm/utils/getVitePath.js +3 -1
  64. package/dist/esm/utils/getVitePath.js.map +1 -1
  65. package/dist/esm/utils/getVitePath.mjs +1 -1
  66. package/dist/esm/utils/getVitePath.native.js +1 -1
  67. package/dist/esm/utils/getVitePath.native.js.map +1 -1
  68. package/dist/esm/utils/readVXRNConfig.js +5 -3
  69. package/dist/esm/utils/readVXRNConfig.js.map +1 -1
  70. package/dist/esm/utils/readVXRNConfig.mjs +5 -1
  71. package/dist/esm/utils/readVXRNConfig.native.js +5 -1
  72. package/dist/esm/utils/readVXRNConfig.native.js.map +2 -2
  73. package/package.json +10 -10
  74. package/src/cli.ts +12 -2
  75. package/src/constants.ts +0 -77
  76. package/src/exports/build.ts +96 -100
  77. package/src/exports/dev.ts +49 -39
  78. package/src/utils/getHtml.ts +21 -6
  79. package/src/utils/getOptimizeDeps.ts +122 -0
  80. package/src/utils/getVitePath.ts +3 -1
  81. package/src/utils/readVXRNConfig.ts +6 -4
  82. package/types/constants.d.ts +0 -10
  83. package/types/exports/build.d.ts +6 -1
  84. package/types/utils/getHtml.d.ts +2 -1
  85. package/types/utils/getOptimizeDeps.d.ts +13 -0
@@ -1,20 +1,35 @@
1
+ // TODO merge with the other one
1
2
  export function getHtml({
2
3
  template,
3
4
  loaderData,
5
+ loaderProps,
4
6
  appHtml,
5
7
  headHtml,
6
8
  css,
7
- }: { css?: string; template: string; loaderData: Object; appHtml: string; headHtml: string }) {
9
+ }: {
10
+ css?: string
11
+ template: string
12
+ loaderData: Object
13
+ loaderProps?: any
14
+ appHtml: string
15
+ headHtml: string
16
+ }) {
8
17
  if (!template.includes(`<!--ssr-outlet-->`)) {
9
18
  throw new Error(`No <!--ssr-outlet--> found in html to inject SSR contents`)
10
19
  }
11
20
  if (!template.includes(`<!--head-outlet-->`)) {
12
21
  throw new Error(`No <!--head-outlet--> found in html to inject SSR contents`)
13
22
  }
14
- const loaderDataString = `\n<script>globalThis['__vxrnLoaderData__']=${JSON.stringify(
15
- loaderData
16
- )}</script>`
23
+
24
+ const loaderDataJS = `globalThis['__vxrnLoaderData__']=${JSON.stringify(loaderData)}`
25
+ const loaderPropsJS = `globalThis['__vxrnLoaderProps__']=${JSON.stringify(loaderProps || null)}`
26
+ const loaderDataString = `\n<script>
27
+ ${loaderDataJS};
28
+ ${loaderPropsJS};
29
+ </script>`
30
+
17
31
  return template
18
- .replace(`<!--ssr-outlet-->`, appHtml + loaderDataString)
19
- .replace(`<!--head-outlet-->`, `${headHtml}\n${css ? `<style>${css}</style>` : ``}`)
32
+ .replace(/\s*<!--ssr-outlet-->\s*/, appHtml)
33
+ .replace(`<!--head-outlet-->`, `${headHtml}\n${css ? `<style>${css}</style>\n` : ``}`)
34
+ .replace('</body>', loaderDataString)
20
35
  }
@@ -0,0 +1,122 @@
1
+ import { optimizeDeps, type UserConfig } from 'vite'
2
+ import { webExtensions } from '../constants'
3
+
4
+ export function getOptimizeDeps(mode: 'build' | 'serve') {
5
+ const needsInterop = [
6
+ 'react',
7
+ 'react/jsx-runtime',
8
+ 'react/jsx-dev-runtime',
9
+ 'react-native-web-internals',
10
+ 'react-dom',
11
+ 'react-native-web',
12
+ 'react-dom/server',
13
+ 'react-dom/client',
14
+ 'url-parse',
15
+ '@vxrn/safe-area',
16
+ 'query-string',
17
+ 'escape-string-regexp',
18
+ 'use-latest-callback',
19
+ 'react-is',
20
+ 'fast-deep-equal',
21
+ 'react-native-svg',
22
+ '@supabase/auth-helpers-react',
23
+ 'parse-numeric-range',
24
+ 'use-sync-external-store',
25
+ 'use-sync-external-store/shim',
26
+ 'expo-constants',
27
+ 'expo-linking',
28
+ 'uuid',
29
+ '@react-navigation/core',
30
+ '@react-navigation/native',
31
+ '@react-navigation/elements',
32
+ '@react-navigation/bottom-tabs',
33
+ '@react-navigation/native-stack',
34
+ 'inline-style-prefixer',
35
+ '@docsearch/react',
36
+ '@algolia/autocomplete-core',
37
+ '@algolia/autocomplete-plugin-algolia-insights',
38
+ '@algolia/autocomplete-shared',
39
+ 'react-native-reanimated',
40
+ 'moti',
41
+ ]
42
+
43
+ const depsToOptimize = [
44
+ ...needsInterop,
45
+ 'requires-port',
46
+ 'querystringify',
47
+ 'compare-versions',
48
+ 'strict-uri-encode',
49
+ 'decode-uri-component',
50
+ 'split-on-first',
51
+ 'filter-obj',
52
+ 'scheduler',
53
+ 'warn-once',
54
+ '@radix-ui/react-compose-refs',
55
+ '@radix-ui/react-slot',
56
+ 'expo-splash-screen',
57
+ 'nanoid',
58
+ 'swr',
59
+ 'refractor/lang/tsx',
60
+ 'invariant',
61
+ 'tamagui/linear-gradient',
62
+ '@tamagui/linear-gradient',
63
+ '@react-native/normalize-color',
64
+ '@vxrn/router',
65
+ 'expo-modules-core',
66
+ 'expo-status-bar',
67
+ 'react-native-web',
68
+ 'react-native-web-lite',
69
+ 'react-native',
70
+ '@tamagui/constants',
71
+ '@tamagui/react-native-use-responder-events',
72
+ '@tamagui/alert-dialog',
73
+ '@react-navigation/routers',
74
+ '@tamagui/simple-hash',
75
+ '@tamagui/use-did-finish-ssr',
76
+ '@tamagui/use-event',
77
+ '@tamagui/portal',
78
+ '@tamagui/compose-refs',
79
+ '@tamagui/avatar',
80
+ '@tamagui/core',
81
+ '@tamagui/dialog',
82
+ '@tamagui/group',
83
+ '@tamagui/helpers-icon',
84
+ '@tamagui/helpers',
85
+ '@tamagui/image',
86
+ '@tamagui/lucide-icons',
87
+ '@tamagui/popover',
88
+ '@tamagui/popper',
89
+ '@tamagui/scroll-view',
90
+ '@tamagui/select',
91
+ '@tamagui/sheet',
92
+ '@tamagui/switch',
93
+ '@tamagui/tabs',
94
+ '@tamagui/toast',
95
+ '@tamagui/toggle-group',
96
+ '@tamagui/tooltip',
97
+ '@tamagui/use-window-dimensions',
98
+ '@tamagui/web',
99
+ 'tamagui',
100
+ 'react-native-web',
101
+ 'react-native-web-lite',
102
+ 'reforest',
103
+ ]
104
+
105
+ if (mode === 'build') {
106
+ // breaks in serve mode
107
+ depsToOptimize.push('@babel/runtime')
108
+ }
109
+
110
+ return {
111
+ needsInterop,
112
+ depsToOptimize,
113
+ optimizeDeps: {
114
+ include: depsToOptimize,
115
+ exclude: ['util', '@swc/wasm', '@swc/core-darwin-arm64'],
116
+ needsInterop,
117
+ esbuildOptions: {
118
+ resolveExtensions: webExtensions,
119
+ },
120
+ } satisfies UserConfig['optimizeDeps'],
121
+ }
122
+ }
@@ -34,7 +34,9 @@ export async function getVitePath(
34
34
  const resolved = resolve(sourceFile)(moduleName)
35
35
  // figure out symlinks
36
36
  if (!resolved) {
37
- throw new Error(`❌ cant find`)
37
+ throw new Error(
38
+ ` ❌ Path not found ${sourceFile} (rootPath ${rootPath}, importer ${importer}, moduleName ${moduleName})`
39
+ )
38
40
  }
39
41
  const real = await FSExtra.realpath(resolved)
40
42
  let id = real
@@ -30,10 +30,12 @@ export async function readVXRNConfig(): Promise<VXRNConfig> {
30
30
 
31
31
  await vite.close()
32
32
  return resolveOptionalAsyncFunction(userConfig?.default ?? {})
33
- } catch (err) {
34
- console.info(
35
- ` [vxrn] Error loading config via ESM, attempting CJS, set VXRN_CJS=1 to run in cjs mode`
36
- )
33
+ } catch (err: any) {
34
+ console.info(` [vxrn] Error loading config via ESM:
35
+
36
+ ${err.stack}
37
+
38
+ To load as CommonJS, set VXRN_CJS=1`)
37
39
  throw err
38
40
  }
39
41
  }
@@ -1,14 +1,4 @@
1
1
  export declare const DEFAULT_PORT = 8081;
2
- export declare const EMPTY_LOADER_STRING = "function loader() {/* \u2737\u2737\u2737 */};";
3
2
  export declare const nativeExtensions: string[];
4
3
  export declare const webExtensions: string[];
5
- export declare const depsToOptimize: string[];
6
- export declare const optimizeDeps: {
7
- include: string[];
8
- needsInterop: string[];
9
- exclude: string[];
10
- esbuildOptions: {
11
- resolveExtensions: string[];
12
- };
13
- };
14
4
  //# sourceMappingURL=constants.d.ts.map
@@ -1,4 +1,9 @@
1
1
  import type { VXRNConfig } from '../types';
2
2
  export declare const resolveFile: (path: string) => string;
3
- export declare const build: (optionsIn: VXRNConfig) => Promise<void>;
3
+ type BuildOptions = {
4
+ step?: string;
5
+ page?: string;
6
+ };
7
+ export declare const build: (optionsIn: VXRNConfig, buildOptions?: BuildOptions) => Promise<void>;
8
+ export {};
4
9
  //# sourceMappingURL=build.d.ts.map
@@ -1,7 +1,8 @@
1
- export declare function getHtml({ template, loaderData, appHtml, headHtml, css, }: {
1
+ export declare function getHtml({ template, loaderData, loaderProps, appHtml, headHtml, css, }: {
2
2
  css?: string;
3
3
  template: string;
4
4
  loaderData: Object;
5
+ loaderProps?: any;
5
6
  appHtml: string;
6
7
  headHtml: string;
7
8
  }): string;
@@ -0,0 +1,13 @@
1
+ export declare function getOptimizeDeps(mode: 'build' | 'serve'): {
2
+ needsInterop: string[];
3
+ depsToOptimize: string[];
4
+ optimizeDeps: {
5
+ include: string[];
6
+ exclude: string[];
7
+ needsInterop: string[];
8
+ esbuildOptions: {
9
+ resolveExtensions: string[];
10
+ };
11
+ };
12
+ };
13
+ //# sourceMappingURL=getOptimizeDeps.d.ts.map