@oxy.so/app-preset 3.6.1 → 4.0.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 CHANGED
@@ -19,7 +19,7 @@ and JSON.
19
19
  | Android WebP resources | `@oxy.so/app-preset/plugin/withOxyAndroidWebp` | re-encoding generated mipmaps/splash bitmaps to real lossless WebP (opt-in, needs `sharp`) |
20
20
  | Oxy Updates (OTA) | `@oxy.so/app-preset/plugin/withOxyUpdates` | the `expo-updates` manifest URL, release channel, `runtimeVersion` policy and the shared code-signing certificate (opt-in, see below) |
21
21
  | Metro | `@oxy.so/app-preset/metro` | monorepo watch folders, block list, symlink + package-exports resolution, web-font/wasm asset exts, release minifier, NativeWind wrapper |
22
- | Babel | `@oxy.so/app-preset/babel` | `babel-preset-expo` + `module-resolver` + `react-native-worklets/plugin` |
22
+ | Babel | `@oxy.so/app-preset/babel` | `babel-preset-expo` alone in development, so Expo's oxc transformer (Noxcturnal) runs; the build-id inliner in production |
23
23
  | ESLint | `@oxy.so/app-preset/eslint` | `eslint-config-expo/flat` + `dist/*` ignore |
24
24
  | CSS base | `@oxy.so/app-preset/base.css` | Tailwind v4 + NativeWind + Bloom design-token imports + SDK `@source` globs |
25
25
  | tsconfig | `@oxy.so/app-preset/tsconfig/{base,frontend,backend}.json` | the shared strict/composite TypeScript bases |
@@ -238,6 +238,21 @@ defaults without replacing them.
238
238
  module.exports = require('@oxy.so/app-preset/babel');
239
239
  ```
240
240
 
241
+ In development this is exactly `babel-preset-expo`. Expo's oxc transformer,
242
+ Noxcturnal, runs only when the Babel config resolves to the bare Expo preset;
243
+ one extra plugin or preset option sends every file back to Babel. The config
244
+ plugin turns the experiment (`experiments.noxcturnalTransformWorker`) on for
245
+ development; `noxcturnal: false` opts out. Production builds stay on Babel,
246
+ with the build-id inliner, because Noxcturnal keeps the requires of dead
247
+ platform branches and pulls native-only packages into a web bundle.
248
+
249
+ `@/` resolves from the app's `tsconfig.json` paths (`"@/*": ["./*"]`), not from
250
+ Babel. Jest needs the same alias in `moduleNameMapper`
251
+ (`"^@/(.*)$": "<rootDir>/$1"`). `babel-preset-expo` adds
252
+ `react-native-worklets/plugin` and the `import.meta` transform itself. An app
253
+ that adds its own Babel plugins, or a custom `babelTransformerPath` such as
254
+ `react-native-svg-transformer`, keeps every file on Babel.
255
+
241
256
  With Bundle Mode (opt-in, 3.2.0+), a worker runtime runs the app's own modules:
242
257
 
243
258
  ```js
package/babel/index.js CHANGED
@@ -1,10 +1,18 @@
1
1
  /**
2
2
  * @oxy.so/app-preset — Babel config factory.
3
3
  *
4
- * The standard Babel config every Oxy Expo app shares: babel-preset-expo with
5
- * `unstable_transformImportMeta`, the `@ → ./` module-resolver alias, and the
6
- * `react-native-worklets/plugin` LAST (Reanimated 4 re-exports it — it must be
7
- * the final plugin).
4
+ * In development the config is exactly `babel-preset-expo`, nothing else.
5
+ * Expo's oxc transformer (Noxcturnal, `experiments.noxcturnalTransformWorker`,
6
+ * which the preset's config plugin turns on) runs only when the project's Babel
7
+ * config resolves to the bare Expo preset; one extra plugin or preset option
8
+ * sends every file back to Babel. Everything the config used to add is covered
9
+ * without it in SDK 58: `babel-preset-expo` adds `react-native-worklets/plugin`
10
+ * and the `import.meta` transform itself, and Metro resolves `@/` from the
11
+ * app's `tsconfig.json` paths.
12
+ *
13
+ * A production build adds the build-id inliner (`./inline-oxy-build-id`).
14
+ * Production stays on Babel either way: Noxcturnal keeps the requires of dead
15
+ * platform branches, pulling native-only packages into a web bundle.
8
16
  *
9
17
  * Usage — a one-line babel.config.js:
10
18
  *
@@ -22,11 +30,11 @@
22
30
  * workletsBundleMode: true })`). `importForwarding` (worklets'
23
31
  * `moduleNames`/`relativePaths`) names the modules whose imports a worklet
24
32
  * runs ON its runtime; an import not forwarded stays on the RN runtime and a
25
- * synchronous call to it from a worker runtime throws.
33
+ * synchronous call to it from a worker runtime throws. Its plugin options make
34
+ * the config non-default, so a Bundle Mode app stays on Babel.
26
35
  *
27
- * The peer packages (`babel-preset-expo`, `babel-plugin-module-resolver`,
28
- * `react-native-worklets`) resolve from the consuming app's node_modules, where
29
- * Expo already installs them.
36
+ * The peer packages (`babel-preset-expo`, `react-native-worklets`) resolve from
37
+ * the consuming app's node_modules, where Expo already installs them.
30
38
  */
31
39
 
32
40
  const FORWARDING_KEYS = ['moduleNames', 'relativePaths'];
@@ -78,33 +86,17 @@ function bundleModeOptions(value) {
78
86
  function createOxyBabelConfig(options = {}) {
79
87
  const bundleMode = bundleModeOptions(options.workletsBundleMode);
80
88
  return function oxyBabelPreset(api) {
81
- api.cache(true);
89
+ const production = api.cache.using(() => process.env.NODE_ENV === 'production');
90
+ const plugins = [
91
+ // The build id `@oxy.so/services` busts its persisted caches on.
92
+ ...(production ? [require.resolve('./inline-oxy-build-id')] : []),
93
+ // In Bundle Mode the worklets plugin needs its options, so
94
+ // babel-preset-expo must not add a second, option-less copy.
95
+ ...(bundleMode ? [['react-native-worklets/plugin', bundleMode]] : []),
96
+ ];
82
97
  return {
83
- presets: [
84
- [
85
- 'babel-preset-expo',
86
- // In Bundle Mode the worklets plugin needs its options, so
87
- // babel-preset-expo must not add a second, option-less copy.
88
- bundleMode
89
- ? { unstable_transformImportMeta: true, worklets: false }
90
- : { unstable_transformImportMeta: true },
91
- ],
92
- ],
93
- plugins: [
94
- // The module-resolver must come first for correct module resolution.
95
- [
96
- 'module-resolver',
97
- {
98
- root: ['./'],
99
- alias: { '@': './' },
100
- extensions: ['.ts', '.tsx', '.js', '.jsx', '.json', '.svg'],
101
- },
102
- ],
103
- // The build id `@oxy.so/services` busts its persisted caches on.
104
- require.resolve('./inline-oxy-build-id'),
105
- // Must be LAST.
106
- bundleMode ? ['react-native-worklets/plugin', bundleMode] : 'react-native-worklets/plugin',
107
- ],
98
+ presets: [bundleMode ? ['babel-preset-expo', { worklets: false }] : 'babel-preset-expo'],
99
+ plugins,
108
100
  };
109
101
  };
110
102
  }
package/metro/index.js CHANGED
@@ -25,7 +25,8 @@
25
25
  * @param {boolean} [options.dropConsole=false] Strip console calls from the
26
26
  * production web bundle. Hermes native bundles do not use Metro's minifier.
27
27
  * @param {string} [options.svgTransformerPath] Resolved SVG transformer path.
28
- * When set, `svg` moves from asset extensions to source extensions.
28
+ * When set, `svg` moves from asset extensions to source extensions. A custom
29
+ * Babel transformer keeps every file on Babel, so the app loses Noxcturnal.
29
30
  * @param {Record<string,string>} [options.extraNodeModules={}] Extra aliases.
30
31
  * @param {string[]} [options.extraWatchFolders=[]] Additional watch roots.
31
32
  * @param {string} [options.workspaceRoot] The install root Metro watches and
@@ -136,7 +137,8 @@ function createOxyMetroConfig(projectRoot, options = {}) {
136
137
  const monorepoRoot = workspaceRoot ? path.resolve(workspaceRoot) : findWorkspaceRoot(projectRoot);
137
138
  const config = getDefaultConfig(projectRoot);
138
139
 
139
- // The preset's Babel plugin inlines this id into every module, but Metro's
140
+ // In a production build the preset's Babel plugin inlines this id into every
141
+ // module (development uses a constant id and no plugin), but Metro's
140
142
  // transform cache key does not cover it: without the id in `cacheVersion`, a
141
143
  // cached SDK module would keep an old build's id. Published so the Babel
142
144
  // workers Metro forks resolve the same value.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxy.so/app-preset",
3
- "version": "3.6.1",
3
+ "version": "4.0.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": {
@@ -60,14 +60,12 @@
60
60
  "node": ">=18.0.0"
61
61
  },
62
62
  "scripts": {
63
- "prepublishOnly": "node ../../scripts/assert-bun-publish.mjs && bun run test",
64
63
  "test": "node --test __tests__/*.test.js"
65
64
  },
66
65
  "//peerDependencies": "THE TWO @oxy.so PEERS ARE DELIBERATE. This package couples to them by FILE PATH, not by API: `css/base.css` imports `@oxy.so/bloom/design-tokens/theme.css`, and `plugin/withOxyAppPreset.js` requires `@oxy.so/services/plugins/withOxySharedPermissions` (services 11+, where it first exists, so the services floor is the major that ships it). Both peers retain a measured floor and are deliberately OPEN-ENDED above it: Oxy apps always run the latest Bloom and Services, so a new release of either must never need a preset release first. A release that breaks this package's file-path coupling is caught by its own tests and the apps' CI, not by a cap. Never replace either constraint with `*`.",
67
66
  "peerDependencies": {
68
67
  "@oxy.so/bloom": "^2.0.0 || ^3.0.0 || ^4.2.0 || ^5.1.0 || >=6.0.0",
69
68
  "@oxy.so/services": ">=11.0.0",
70
- "babel-plugin-module-resolver": "*",
71
69
  "babel-preset-expo": "*",
72
70
  "eslint": ">=9.0.0",
73
71
  "eslint-config-expo": "*",
@@ -99,9 +97,6 @@
99
97
  "@oxy.so/bloom": {
100
98
  "optional": true
101
99
  },
102
- "babel-plugin-module-resolver": {
103
- "optional": true
104
- },
105
100
  "babel-preset-expo": {
106
101
  "optional": true
107
102
  },
@@ -19,6 +19,7 @@
19
19
  * ios: { deploymentTarget: '17.0' }, // false → skip iOS build properties
20
20
  * android: { targetSdkVersion: 34 }, // false → skip Android build properties
21
21
  * webgpu: true, // opt-in: react-native-webgpu's config plugin
22
+ * noxcturnal: false, // opt out of Expo's oxc transformer in development
22
23
  * }]
23
24
  *
24
25
  * Android never gets `android:sharedUserId`: each Oxy app has its own UID and
@@ -37,6 +38,13 @@
37
38
  * @param {boolean} [options.webgpu=false] Apply `react-native-webgpu`'s
38
39
  * config plugin (an app drawing with WebGPU on native). Needs
39
40
  * `react-native-webgpu` installed in the app.
41
+ * @param {boolean} [options.noxcturnal=true] Bundle development builds with
42
+ * Noxcturnal, Expo's oxc transformer (`experiments.noxcturnalTransformWorker`),
43
+ * about twice as fast as Babel on a cold cache. It only runs when the app's
44
+ * Babel config is the preset's (or none), and never in a production build: it
45
+ * keeps the requires of dead platform branches, pulling native-only packages
46
+ * into a web bundle. The Expo CLI sets NODE_ENV before it reads the config.
47
+ * An app that sets the experiment itself keeps its own value.
40
48
  */
41
49
  const withOxyKeychain = require('./withOxyKeychain');
42
50
  const withOxyBuildProperties = require('./withOxyBuildProperties');
@@ -58,10 +66,26 @@ module.exports = function withOxyAppPreset(config, options = {}) {
58
66
  }
59
67
  }
60
68
 
61
- const { keychainGroup = 'group.so.oxy.shared', ios = {}, android = {}, webgpu = false } = options;
69
+ const {
70
+ keychainGroup = 'group.so.oxy.shared',
71
+ ios = {},
72
+ android = {},
73
+ webgpu = false,
74
+ noxcturnal = true,
75
+ } = options;
62
76
 
63
77
  let next = config;
64
78
 
79
+ if (noxcturnal && next.experiments?.noxcturnalTransformWorker === undefined) {
80
+ next = {
81
+ ...next,
82
+ experiments: {
83
+ ...next.experiments,
84
+ noxcturnalTransformWorker: process.env.NODE_ENV !== 'production',
85
+ },
86
+ };
87
+ }
88
+
65
89
  if (keychainGroup !== false) {
66
90
  next = withOxyKeychain(next, keychainGroup);
67
91
  }