@oxy.so/app-preset 3.3.0 → 3.5.0
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/README.md +10 -3
- package/metro/index.js +83 -15
- package/package.json +1 -1
- package/plugin/withOxyBuildProperties.js +6 -3
package/README.md
CHANGED
|
@@ -37,8 +37,8 @@ plugins: [
|
|
|
37
37
|
|
|
38
38
|
This adds the iOS `keychain-access-groups` entitlement
|
|
39
39
|
(`$(AppIdentifierPrefix)group.so.oxy.shared`), the Oxy `expo-build-properties`
|
|
40
|
-
defaults (iOS `deploymentTarget 16.4`; Android
|
|
41
|
-
|
|
40
|
+
defaults (iOS `deploymentTarget 16.4`; Android ProGuard + resource shrinking — the
|
|
41
|
+
Android compile/target SDK and build tools are the Expo SDK's own, never pinned here), and `@oxy.so/services/plugins/withOxySharedPermissions`:
|
|
42
42
|
the app declares and requests the signature-level `so.oxy.permission.IDENTITY` and
|
|
43
43
|
`so.oxy.permission.DEVICE_SESSION`, with `<queries>` for the Commons and Accounts
|
|
44
44
|
providers. That is how silent "Sign in with Oxy" works on Android: each Oxy app
|
|
@@ -166,10 +166,17 @@ module.exports = createOxyMetroConfig(__dirname, {
|
|
|
166
166
|
cssInput: './global.css', // optional, this is the default
|
|
167
167
|
dropConsole: true, // optional, production web only
|
|
168
168
|
// svgTransformerPath: require.resolve('react-native-svg-transformer/expo'),
|
|
169
|
-
//
|
|
169
|
+
// workspaceRoot: path.join(__dirname, '../..'), // optional, see below
|
|
170
170
|
});
|
|
171
171
|
```
|
|
172
172
|
|
|
173
|
+
Metro watches the app's install root and resolves hoisted dependencies from its
|
|
174
|
+
`node_modules`. The root is found by walking up from the project, never past its
|
|
175
|
+
git checkout: the nearest `package.json` that declares `workspaces`, else the
|
|
176
|
+
nearest lockfile, else the checkout's top level. A monorepo app watches the
|
|
177
|
+
monorepo; a single-package app watches only itself. `workspaceRoot` overrides it.
|
|
178
|
+
Worktrees under `<root>/.worktrees` and `<root>/.claude/worktrees` are blocked.
|
|
179
|
+
|
|
173
180
|
`workletsBundleMode: true` (opt-in, 3.2.0+) turns on react-native-worklets'
|
|
174
181
|
[Bundle Mode](https://docs.swmansion.com/react-native-worklets/docs/bundleMode).
|
|
175
182
|
It wraps the finished config with worklets' `getBundleModeMetroConfig`. Use it
|
package/metro/index.js
CHANGED
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
* When set, `svg` moves from asset extensions to source extensions.
|
|
29
29
|
* @param {Record<string,string>} [options.extraNodeModules={}] Extra aliases.
|
|
30
30
|
* @param {string[]} [options.extraWatchFolders=[]] Additional watch roots.
|
|
31
|
+
* @param {string} [options.workspaceRoot] The install root Metro watches and
|
|
32
|
+
* resolves hoisted deps from. Defaults to {@link findWorkspaceRoot}.
|
|
31
33
|
* @param {string[]} [options.extraAssetExts=[]] Additional asset extensions.
|
|
32
34
|
* @param {string[]} [options.extraSourceExts=[]] Additional source extensions.
|
|
33
35
|
* @param {boolean} [options.workletsBundleMode=false] react-native-worklets'
|
|
@@ -39,19 +41,81 @@
|
|
|
39
41
|
*/
|
|
40
42
|
const { getDefaultConfig } = require('expo/metro-config');
|
|
41
43
|
const { withNativeWind } = require('nativewind/metro');
|
|
42
|
-
const
|
|
44
|
+
const fs = require('node:fs');
|
|
45
|
+
const path = require('node:path');
|
|
43
46
|
const { resolveOxyBuildId } = require('../build-id');
|
|
44
47
|
const { requireFromProject } = require('../plugin/requireFromProject');
|
|
45
48
|
|
|
49
|
+
function escapeRegExp(value) {
|
|
50
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
51
|
+
}
|
|
52
|
+
|
|
46
53
|
function blockPath(dir) {
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
return new RegExp(`${escapeRegExp(path.resolve(dir))}/.*`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Every directory called `name` BELOW one of `roots` — never one in a root's
|
|
59
|
+
* own path. An unanchored `.cache/` pattern also matched the CHECKOUT when it
|
|
60
|
+
* lived under `~/.cache` (a worktree there), blocking every file of the app and
|
|
61
|
+
* failing the bundle with "Unable to resolve module ./node_modules/expo-router/
|
|
62
|
+
* entry"; the same held for `.expo`, `.expo-shared`, `.metro` and `__tests__`.
|
|
63
|
+
*/
|
|
64
|
+
function dirsUnder(roots, name) {
|
|
65
|
+
const anyRoot = unique(roots.map((root) => escapeRegExp(path.resolve(root)))).join('|');
|
|
66
|
+
return new RegExp(`^(?:${anyRoot})/(?:.*/)?${escapeRegExp(name)}/.*`);
|
|
49
67
|
}
|
|
50
68
|
|
|
51
69
|
function unique(values) {
|
|
52
70
|
return [...new Set(values)];
|
|
53
71
|
}
|
|
54
72
|
|
|
73
|
+
const LOCKFILES = [
|
|
74
|
+
'bun.lock',
|
|
75
|
+
'bun.lockb',
|
|
76
|
+
'package-lock.json',
|
|
77
|
+
'yarn.lock',
|
|
78
|
+
'pnpm-lock.yaml',
|
|
79
|
+
'pnpm-workspace.yaml',
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
function declaresWorkspaces(dir) {
|
|
83
|
+
try {
|
|
84
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'));
|
|
85
|
+
return Boolean(manifest?.workspaces);
|
|
86
|
+
} catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The directory the app was installed from — what Metro watches and resolves
|
|
93
|
+
* hoisted deps from. Walking up from the project, never past the git checkout
|
|
94
|
+
* that contains it: the nearest ancestor whose package.json declares
|
|
95
|
+
* `workspaces`, else the nearest one holding a lockfile, else the checkout's
|
|
96
|
+
* top level, else the project itself.
|
|
97
|
+
*
|
|
98
|
+
* Never a blind `../..`: for a single-package app at `~/Oxy/<repo>` that is the
|
|
99
|
+
* home directory, and Metro crawled all of it (every sibling repo and worktree
|
|
100
|
+
* with its node_modules) until it ran out of memory.
|
|
101
|
+
*
|
|
102
|
+
* @param {string} projectRoot
|
|
103
|
+
* @returns {string}
|
|
104
|
+
*/
|
|
105
|
+
function findWorkspaceRoot(projectRoot) {
|
|
106
|
+
const start = path.resolve(projectRoot);
|
|
107
|
+
let lockfileRoot;
|
|
108
|
+
for (let dir = start; ; dir = path.dirname(dir)) {
|
|
109
|
+
if (declaresWorkspaces(dir)) return dir;
|
|
110
|
+
if (!lockfileRoot && LOCKFILES.some((name) => fs.existsSync(path.join(dir, name)))) {
|
|
111
|
+
lockfileRoot = dir;
|
|
112
|
+
}
|
|
113
|
+
// `.git` is a directory in a checkout and a file in a worktree.
|
|
114
|
+
if (fs.existsSync(path.join(dir, '.git'))) return lockfileRoot || dir;
|
|
115
|
+
if (path.dirname(dir) === dir) return lockfileRoot || start;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
55
119
|
function createOxyMetroConfig(projectRoot, options = {}) {
|
|
56
120
|
const {
|
|
57
121
|
sharedTypesPackage,
|
|
@@ -63,9 +127,10 @@ function createOxyMetroConfig(projectRoot, options = {}) {
|
|
|
63
127
|
extraWatchFolders = [],
|
|
64
128
|
extraAssetExts = [],
|
|
65
129
|
extraSourceExts = [],
|
|
130
|
+
workspaceRoot,
|
|
66
131
|
} = options;
|
|
67
132
|
|
|
68
|
-
const monorepoRoot = path.resolve(projectRoot
|
|
133
|
+
const monorepoRoot = workspaceRoot ? path.resolve(workspaceRoot) : findWorkspaceRoot(projectRoot);
|
|
69
134
|
const config = getDefaultConfig(projectRoot);
|
|
70
135
|
|
|
71
136
|
// The preset's Babel plugin inlines this id into every module, but Metro's
|
|
@@ -78,7 +143,7 @@ function createOxyMetroConfig(projectRoot, options = {}) {
|
|
|
78
143
|
|
|
79
144
|
config.projectRoot = projectRoot;
|
|
80
145
|
|
|
81
|
-
//
|
|
146
|
+
// Watch the install root so Metro resolves hoisted deps in its node_modules/.
|
|
82
147
|
config.watchFolders = unique([
|
|
83
148
|
monorepoRoot,
|
|
84
149
|
...extraWatchFolders.map((folder) => path.resolve(folder)),
|
|
@@ -91,14 +156,13 @@ function createOxyMetroConfig(projectRoot, options = {}) {
|
|
|
91
156
|
// full node_modules; leaving them watchable makes Metro's file crawler walk
|
|
92
157
|
// hundreds of thousands of extra directories and time out starting watch mode.
|
|
93
158
|
blockPath(path.join(monorepoRoot, '.worktrees')),
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
159
|
+
blockPath(path.join(monorepoRoot, '.claude/worktrees')),
|
|
160
|
+
// Caches and tests anywhere inside what Metro crawls (`node_modules/.cache`
|
|
161
|
+
// and `.expo/types` included), and nowhere above it.
|
|
162
|
+
...['.expo', '.expo-shared', '.metro', '.cache', '__tests__'].map((name) =>
|
|
163
|
+
dirsUnder([projectRoot, ...config.watchFolders], name),
|
|
164
|
+
),
|
|
99
165
|
/\.tsbuildinfo$/,
|
|
100
|
-
/.*\.expo\/types\/.*/,
|
|
101
|
-
/__tests__\/.*/,
|
|
102
166
|
/\.test\.(js|ts|tsx|jsx)$/,
|
|
103
167
|
/\.spec\.(js|ts|tsx|jsx)$/,
|
|
104
168
|
/\.md$/,
|
|
@@ -124,10 +188,10 @@ function createOxyMetroConfig(projectRoot, options = {}) {
|
|
|
124
188
|
...configuredExtraNodeModules,
|
|
125
189
|
},
|
|
126
190
|
// Resolve from the app's node_modules first, then the monorepo root (hoisted deps).
|
|
127
|
-
nodeModulesPaths: [
|
|
191
|
+
nodeModulesPaths: unique([
|
|
128
192
|
path.join(projectRoot, 'node_modules'),
|
|
129
193
|
path.join(monorepoRoot, 'node_modules'),
|
|
130
|
-
],
|
|
194
|
+
]),
|
|
131
195
|
// Enable symlinks for workspace resolution.
|
|
132
196
|
unstable_enableSymlinks: true,
|
|
133
197
|
// Enable package.json "exports" resolution (required by @oxy.so/bloom subpath exports).
|
|
@@ -254,4 +318,8 @@ function createOxyMetroConfigWithBloom(projectRoot, options = {}) {
|
|
|
254
318
|
return workletsBundleMode ? withWorkletsBundleMode(config, projectRoot) : config;
|
|
255
319
|
}
|
|
256
320
|
|
|
257
|
-
module.exports = {
|
|
321
|
+
module.exports = {
|
|
322
|
+
createOxyMetroConfig: createOxyMetroConfigWithBloom,
|
|
323
|
+
findWorkspaceRoot,
|
|
324
|
+
withBloomSingleInstance,
|
|
325
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/app-preset",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "The Oxy distro of Expo — centralized Expo config plugin, Metro/Babel/ESLint factories, Tailwind base CSS and TypeScript bases shared by every Oxy app (Mention, Homiio, Allo, accounts, …). A zero-build package: apps replace copy-pasted config with a single dependency bump.",
|
|
5
5
|
"main": "./app.plugin.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -22,10 +22,13 @@ const DEFAULTS = {
|
|
|
22
22
|
ios: {
|
|
23
23
|
deploymentTarget: '16.4',
|
|
24
24
|
},
|
|
25
|
+
// No compileSdkVersion / targetSdkVersion / buildToolsVersion: the Expo SDK's
|
|
26
|
+
// own template sets them (SDK 58: compileSdk 37, targetSdk 36, build tools
|
|
27
|
+
// 37.0.0), so they move with every SDK upgrade. Pinning them here broke every
|
|
28
|
+
// SDK 58 release build: SDK 58's Expo modules require compileSdk 37 and AGP's
|
|
29
|
+
// checkReleaseAarMetadata refuses compileSdk 36. An app that must hold a level
|
|
30
|
+
// back still passes it as an override.
|
|
25
31
|
android: {
|
|
26
|
-
compileSdkVersion: 36,
|
|
27
|
-
targetSdkVersion: 35,
|
|
28
|
-
buildToolsVersion: '36.0.0',
|
|
29
32
|
enableProguardInReleaseBuilds: true,
|
|
30
33
|
enableShrinkResourcesInReleaseBuilds: true,
|
|
31
34
|
useLegacyPackaging: false,
|