@symbiote-native/vue 0.3.3 → 0.3.5

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.
@@ -13,8 +13,18 @@
13
13
  // Ships as a package-level export (`@symbiote-native/vue/metro-vue-transformer`) rather than living
14
14
  // in each consuming app: a consumer's own metro.config.js just points babelTransformerPath at it.
15
15
 
16
- const { parse, compileScript } = require('@vue/compiler-sfc');
16
+ const nodeFs = require('fs');
17
+ const { parse, compileScript, registerTS } = require('@vue/compiler-sfc');
17
18
  const { createCompoundExpression } = require('@vue/compiler-core');
19
+
20
+ // A bare-specifier type import (`import type { X } from '@symbiote-native/navigation/vue'`, as
21
+ // opposed to a relative one) needs real node_modules resolution (package.json exports, pnpm
22
+ // symlinks) to turn the specifier into a file path — compileScript's own `fs` option only reads
23
+ // paths it's already given, it can't do that resolution. @vue/compiler-sfc's sanctioned hook for
24
+ // this is `registerTS`, the same one @vitejs/plugin-vue and vue-tsc call: it hands the compiler a
25
+ // lazy loader for the real `typescript` package, which resolves the specifier via
26
+ // `ts.resolveModuleName` and self-supplies `ts.sys` as the fs fallback.
27
+ registerTS(() => require('typescript'));
18
28
  // @symbiote-native/css-parser is a real dependency of THIS package, so requiring it directly here
19
29
  // (rather than through the ./metro-css-parser public subpath, which exists for CONSUMERS) resolves
20
30
  // straight from this package's own node_modules under pnpm.
@@ -31,6 +41,23 @@ const {
31
41
 
32
42
  const upstreamTransformer = resolveUpstreamTransformer();
33
43
 
44
+ // compileScript needs file system access to resolve a type-only `defineProps<ISomeProps>()`
45
+ // where ISomeProps is imported from another file — without it, Metro's worker process (a real
46
+ // Node process, but one @vue/compiler-sfc doesn't auto-detect as Node unless the consumer calls
47
+ // its `registerTS` hook) throws "No fs option provided ... in non-Node environment". Wiring
48
+ // Node's own `fs` module straight through is simpler than registering the `typescript` package
49
+ // as a loader (registerTS), and this file already runs in Node at Metro build time.
50
+ const compileScriptFs = {
51
+ fileExists: (file) => nodeFs.existsSync(file),
52
+ readFile: (file) => {
53
+ try {
54
+ return nodeFs.readFileSync(file, 'utf-8');
55
+ } catch {
56
+ return undefined;
57
+ }
58
+ },
59
+ };
60
+
34
61
  // Rewrites a Vue template AST so every `class`/`:class` binding on an element resolves
35
62
  // against this file's scoped class names at the compiled call site, via @symbiote-native/engine's
36
63
  // scopeClassName(value, localNames, scopeId). This runs at the AST level rather than as a
@@ -234,6 +261,7 @@ async function compileSfc(src, filename) {
234
261
  id: scopeId,
235
262
  inlineTemplate: true,
236
263
  templateOptions,
264
+ fs: compileScriptFs,
237
265
  });
238
266
  // Point every Vue import (the compiler's injected helpers AND the user's own
239
267
  // `import { ref } from 'vue'`) at the runtime-helpers shim, which re-exports the same
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbiote-native/vue",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "SymbioteNative's Vue adapter — a @vue/runtime-core createRenderer driving real native iOS/Android views through the same engine as the React adapter.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -44,9 +44,10 @@
44
44
  "@vue/compiler-core": "^3.5.13",
45
45
  "@vue/compiler-sfc": "^3.5.13",
46
46
  "@vue/runtime-core": "^3.5.13",
47
- "@symbiote-native/components": "0.2.3",
47
+ "typescript": "~6.0.0",
48
+ "@symbiote-native/components": "0.2.4",
48
49
  "@symbiote-native/css-parser": "0.2.1",
49
- "@symbiote-native/engine": "0.1.4"
50
+ "@symbiote-native/engine": "0.1.5"
50
51
  },
51
52
  "peerDependencies": {
52
53
  "vue": ">=3.5.0",