@symbiote-native/angular 2.0.0 → 2.0.1

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 (2) hide show
  1. package/metro-config.cjs +32 -16
  2. package/package.json +1 -1
package/metro-config.cjs CHANGED
@@ -1,20 +1,27 @@
1
1
  // Angular's AOT pipeline needs ONE Metro-side accommodation beyond the plain css-parser
2
2
  // transformer: ngc mirrors this app's whole source tree into its own outDir (see
3
3
  // tsconfig.angular.base.json's `outDir` convention, "build/angular" by default) but only ever
4
- // compiles .ts — a relative style import (`import './App.css'`) survives untouched in the
5
- // compiled .js, still pointing at the ORIGINAL source location, which ngc never copies there.
6
- // Metro resolves that relative specifier against the COMPILED file's own location
7
- // (<outDir>/...), so without this it 404s on a file that was never created there. This redirects
8
- // such an import back to the real source file instead of copying it — a copy would need its own
9
- // re-copy on every CSS edit during `ngc --watch` (which only re-runs on .ts changes), while this
10
- // redirect lets Metro's own watchFolders pick up a source-file CSS edit for free. Applies
11
- // identically to a release `react-native bundle`, which resolves through this same config.
4
+ // compiles .ts — a relative non-script import (`import './App.css'`, a bundled asset require such
5
+ // as `./assets/logo.png`) survives untouched in the compiled .js, still pointing at the ORIGINAL
6
+ // source location, which
7
+ // ngc never copies there. Metro resolves that relative specifier against the COMPILED file's own
8
+ // location (<outDir>/...), so without this it 404s on a file that was never created there — a
9
+ // device-diagnosed 2026-09-18 case: `Unable to resolve module ./assets/react-native-logo.png`
10
+ // from a component that ships a bundled image `require()`, same failure shape as the CSS case
11
+ // this originally shipped for, just a different extension. This redirects the resolution ORIGIN
12
+ // back to the real source directory and lets Metro's own resolver take it from there (its usual
13
+ // sourceFile/assetFile decision, including @2x/@3x density-variant lookup for images) — cheaper
14
+ // and more general than hand-rolling either resolution shape here, and it generalizes to ANY
15
+ // non-script asset ngc doesn't copy, not just the two extensions someone happened to hit first.
16
+ // A real copy would need its own re-copy on every source edit during `ngc --watch` (which only
17
+ // re-runs on .ts changes), while this redirect lets Metro's own watchFolders pick up a source
18
+ // edit for free. Applies identically to a release `react-native bundle`, which resolves through
19
+ // this same config.
12
20
  //
13
21
  // watchFolders/extraNodeModules are intentionally NOT included here — those are monorepo-only
14
22
  // pnpm-workspace concerns (deduping a single react/@angular/core copy across packages), not
15
23
  // relevant to an external app installing @symbiote-native/angular from npm; a consumer keeps
16
24
  // those local to their own metro.config.js if it needs them at all.
17
- const fs = require('node:fs');
18
25
  const path = require('node:path');
19
26
 
20
27
  function withSymbioteAngularMetroConfig(
@@ -38,10 +45,14 @@ function withSymbioteAngularMetroConfig(
38
45
  'styl',
39
46
  ],
40
47
  resolveRequest: (context, moduleName, platform) => {
41
- const isRelativeStyleImport =
48
+ // ngc only ever emits .ts -> .js into buildRoot (and a bare extensionless specifier is
49
+ // always a real compiled module, e.g. `./MenuScreen`) — anything else with a relative
50
+ // specifier and an extension is a non-script file ngc never copied there.
51
+ const isRelativeNonScriptImport =
42
52
  /^\.\.?\//.test(moduleName) &&
43
- /\.(css|scss|sass|less|styl)$/.test(moduleName);
44
- if (isRelativeStyleImport) {
53
+ path.extname(moduleName) !== '' &&
54
+ !/\.(ts|tsx|js|jsx)$/.test(moduleName);
55
+ if (isRelativeNonScriptImport) {
45
56
  const originDir = path.dirname(context.originModulePath);
46
57
  if (
47
58
  originDir === buildRoot ||
@@ -51,10 +62,15 @@ function withSymbioteAngularMetroConfig(
51
62
  projectRoot,
52
63
  path.relative(buildRoot, originDir),
53
64
  );
54
- const sourceFile = path.resolve(sourceDir, moduleName);
55
- if (fs.existsSync(sourceFile)) {
56
- return { type: 'sourceFile', filePath: sourceFile };
57
- }
65
+ const fakeOrigin = path.join(
66
+ sourceDir,
67
+ path.basename(context.originModulePath),
68
+ );
69
+ return context.resolveRequest(
70
+ { ...context, originModulePath: fakeOrigin },
71
+ moduleName,
72
+ platform,
73
+ );
58
74
  }
59
75
  }
60
76
  return context.resolveRequest(context, moduleName, platform);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbiote-native/angular",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "SymbioteNative's Angular adapter — a Renderer2/RendererFactory2 with DOM-less bootstrap driving real native iOS/Android views through the same engine as the other adapters.",
5
5
  "keywords": [
6
6
  "react-native",