expo 58.0.16 → 58.0.19

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.
@@ -17,6 +17,8 @@
17
17
 
18
18
  const fs = require('fs');
19
19
 
20
+ const { spmUpdateCommand } = require('./commands');
21
+
20
22
  /**
21
23
  * Pod-name families already covered by the SwiftPM graph: Expo's own modules
22
24
  * (contributed by this plugin) and React Native's products (contributed by RN).
@@ -49,6 +51,16 @@ const COVERED_POD_PREFIXES = [
49
51
  */
50
52
  const UNMAPPED_POD_ALLOWLIST = new Set(['sqlite3']);
51
53
 
54
+ // Expo apps do not depend on @react-native-community/cli, which provides the
55
+ // `react-native spm` command; React Native's own script is always installed.
56
+ function rerunSpmUpdate() {
57
+ return `Then run \`${spmUpdateCommand()}\` from your app directory again.`;
58
+ }
59
+
60
+ /** Where an app sets its `buildFromSource` autolinking option. */
61
+ const BUILD_FROM_SOURCE_OPTION =
62
+ '`"expo": { "autolinking": { "buildFromSource": [...] } }` (or its `"ios"` section) in your package.json';
63
+
52
64
  /**
53
65
  * An error the plugin fails the sync with, namespaced so the failure is
54
66
  * attributable to it: what failed, then why and what to do next when known.
@@ -84,7 +96,15 @@ function classifyUnsupported({ pending, coreAvailable }) {
84
96
  if (!coreAvailable) {
85
97
  return [{ reason: 'core-unavailable', pods: pending.map((p) => p.podName) }];
86
98
  }
87
- return pending.map(({ refusals, ...subject }) => ({ ...subject, ...mostSpecific(refusals) }));
99
+ return pending.map(({ refusals, buildFromSourceEntry, precompiledIncomplete, ...subject }) => {
100
+ if (buildFromSourceEntry == null) return { ...subject, ...mostSpecific(refusals) };
101
+ // The artifact exists; buildFromSource is why it was not linked.
102
+ const cause = mostSpecific(refusals.filter((r) => r.reason !== 'prebuild-available'));
103
+ const reason = precompiledIncomplete
104
+ ? 'build-from-source-fallback-incomplete'
105
+ : 'build-from-source-unsupported';
106
+ return { ...subject, reason, buildFromSourceEntry, cause };
107
+ });
88
108
  }
89
109
 
90
110
  function mostSpecific(refusals) {
@@ -237,9 +257,68 @@ function renderPrebuildAvailable({ podName, packageName, moduleRoot, productName
237
257
  `error: Expo module "${packageName}" (pod ${podName}) has no prebuilt XCFramework, so it is not in the Swift Package Manager graph.`,
238
258
  [
239
259
  `It declares "${productName}" in its spm.config.json, so it does not need a Package.swift — the Expo prebuild pipeline builds it. The artifact is just missing.`,
240
- `Build it — omit --flavor so both Debug and Release are built, since the plugin declares an immutable pair and rejects a half-built one:`,
241
- ` et prebuild ${packageName}`,
242
- `Then re-run \`npx react-native spm update\`. A published ${packageName} that ships prebuilds/output/<flavor>/xcframeworks is picked up with no local build.`,
260
+ `In the Expo repository, from its root, build it — omit --flavor so both Debug and Release are built, since the plugin declares an immutable pair and rejects a half-built one:`,
261
+ ` node tools/bin/expotools.js prebuild ${packageName}`,
262
+ `Then re-run \`${spmUpdateCommand()}\`. A published ${packageName} that ships prebuilds/output/<flavor>/xcframeworks is picked up with no local build.`,
263
+ ],
264
+ moduleRoot
265
+ );
266
+ }
267
+
268
+ const quotedList = (names) => names.map((name) => `"${name}"`).join(', ');
269
+
270
+ /** Why a pod cannot be built from source, by the reason it was refused. */
271
+ const SOURCE_BUILD_BLOCKERS = {
272
+ 'mixed-no-manifest': () =>
273
+ 'It mixes Swift and Objective-C/C++ sources and ships no Package.swift, and Swift Package Manager can build such a module only from a manifest that splits the two languages into separate targets.',
274
+ 'no-apple-sources': () =>
275
+ 'It has no `ios` or `apple` source directory for Swift Package Manager to compile.',
276
+ 'needs-manifest-for-linkage': ({ file, line }) =>
277
+ `Its podspec declares native linkage at ${file}:${line}, and it ships no Package.swift stating that linkage, so a package built from its sources would link less than CocoaPods does.`,
278
+ 'unsupported-target-dependency': ({ dependencies }) =>
279
+ `Its Package.swift has targets depending on ${quotedList(dependencies.map((d) => d.dependsOn))}, which the package generated from it cannot declare.`,
280
+ 'unsupported-package-dependency': () =>
281
+ 'Its Package.swift declares Swift packages the package generated from it cannot declare.',
282
+ 'unresolvable-target-path': ({ targetNames }) =>
283
+ `Its Package.swift names targets with no sources on disk: ${quotedList(targetNames)}.`,
284
+ 'not-exported-by-manifest': ({ productName }) =>
285
+ `Its Package.swift exports no "${productName}" library product.`,
286
+ 'partially-precompiled': ({ precompiledSiblings }) =>
287
+ `Other pods of the module are linked precompiled (${precompiledSiblings.join(', ')}), and building the module from source would link them a second time.`,
288
+ };
289
+
290
+ function renderBuildFromSourceUnsupported({
291
+ podName,
292
+ packageName,
293
+ moduleRoot,
294
+ buildFromSourceEntry,
295
+ cause,
296
+ }) {
297
+ return renderBlock(
298
+ `error: Expo module "${packageName}" (pod ${podName}) is listed in buildFromSource, but Swift Package Manager cannot build it from source.`,
299
+ [
300
+ SOURCE_BUILD_BLOCKERS[cause.reason]?.(cause) ??
301
+ `The plugin found no way to build it from source with Swift Package Manager (reason: ${cause.reason}).`,
302
+ `Remove "${buildFromSourceEntry}" from ${BUILD_FROM_SOURCE_OPTION}, or narrow it so it no longer matches ${podName} or ${packageName}. The module's precompiled XCFramework is then used. ${rerunSpmUpdate()}`,
303
+ ],
304
+ moduleRoot
305
+ );
306
+ }
307
+
308
+ function renderBuildFromSourceFallbackIncomplete({
309
+ podName,
310
+ packageName,
311
+ moduleRoot,
312
+ buildFromSourceEntry,
313
+ cause,
314
+ }) {
315
+ return renderBlock(
316
+ `error: The buildFromSource entry "${buildFromSourceEntry}" matches Expo module "${packageName}" (pod ${podName}), which Swift Package Manager cannot build from source, and its precompiled XCFramework is incomplete, so it cannot be linked precompiled either.`,
317
+ [
318
+ SOURCE_BUILD_BLOCKERS[cause.reason]?.(cause) ??
319
+ `The plugin found no way to build it from source with Swift Package Manager (reason: ${cause.reason}).`,
320
+ 'A buildFromSource pattern links a module precompiled when Swift Package Manager cannot build it from source, and the plugin links a precompiled XCFramework only when both its Debug and Release flavors are present.',
321
+ `Reinstall ${packageName} so it ships both flavors, or, in the Expo repository, from its root, build both with \`node tools/bin/expotools.js prebuild ${packageName}\`. ${rerunSpmUpdate()}`,
243
322
  ],
244
323
  moduleRoot
245
324
  );
@@ -508,14 +587,14 @@ function renderPartiallyPrecompiled({
508
587
  ? `add a product for ${podName} to ${packageName}'s spm.config.json, then build it`
509
588
  : `build ${podName} too — ${packageName}'s spm.config.json already declares "${prebuildProduct.name}"`;
510
589
  const precompile = [
511
- `To precompile all of them, ${productStep}. Omit --flavor so both Debug and Release are built, since the plugin declares an immutable pair and rejects a half-built one:`,
512
- ` et prebuild ${packageName}`,
513
- ` Then re-run \`npx react-native spm update\`.`,
590
+ `To precompile all of them, ${productStep}. In the Expo repository, from its root, run this — omit --flavor so both Debug and Release are built, since the plugin declares an immutable pair and rejects a half-built one:`,
591
+ ` node tools/bin/expotools.js prebuild ${packageName}`,
592
+ ` Then re-run \`${spmUpdateCommand()}\`.`,
514
593
  ];
515
594
  const remedies = [
516
595
  ...(sourceOnly ? [] : [precompile]),
517
596
  [
518
- `To build it from source instead, delete the prebuilt ${siblings} artifacts — ${artifacts}, under debug/xcframeworks and release/xcframeworks — from each directory below, then re-run \`npx react-native spm update\`. The plugin searches them in this order and uses the first one that has an artifact, so one left behind anywhere is picked up again:`,
597
+ `To build it from source instead, delete the prebuilt ${siblings} artifacts — ${artifacts}, under debug/xcframeworks and release/xcframeworks — from each directory below, then re-run \`${spmUpdateCommand()}\`. The plugin searches them in this order and uses the first one that has an artifact, so one left behind anywhere is picked up again:`,
519
598
  ...artifactDirs.map((dir) => ` ${dir}`),
520
599
  ],
521
600
  [remedy.exclude(packageName)],
@@ -599,9 +678,9 @@ function renderCoreUnavailable({ pods }) {
599
678
  return [
600
679
  `error: ExpoModulesCore has no prebuilt Debug and Release xcframework, so all ${pods.length} source-built Expo ${pods.length === 1 ? 'module' : 'modules'} were skipped.`,
601
680
  ` Every Expo source module compiles against the ExpoModulesCore framework interface tree; without both flavors the plugin cannot emit any of them.`,
602
- ` Build the precompiled core, once per flavor (the flavor name is case-sensitive):`,
603
- ` et prebuild -f Debug expo-modules-core expo-modules-jsi`,
604
- ` et prebuild -f Release expo-modules-core expo-modules-jsi`,
681
+ ` In the Expo repository, from its root, build the precompiled core once per flavor (the flavor name is case-sensitive):`,
682
+ ` node tools/bin/expotools.js prebuild -f Debug expo-modules-core expo-modules-jsi`,
683
+ ` node tools/bin/expotools.js prebuild -f Release expo-modules-core expo-modules-jsi`,
605
684
  ` Skipped: ${pods.join(', ')}`,
606
685
  ].join('\n');
607
686
  }
@@ -624,6 +703,8 @@ function renderDuplicatePodName({ podName, copies }) {
624
703
  const REFUSALS = new Map(
625
704
  [
626
705
  ['duplicate-pod-name', { render: renderDuplicatePodName }],
706
+ ['build-from-source-unsupported', { render: renderBuildFromSourceUnsupported }],
707
+ ['build-from-source-fallback-incomplete', { render: renderBuildFromSourceFallbackIncomplete }],
627
708
  ['partially-precompiled', { render: renderPartiallyPrecompiled }],
628
709
  ['prebuild-available', { render: renderPrebuildAvailable }],
629
710
  ['needs-manifest-for-linkage', { render: renderNeedsManifestForLinkage }],
@@ -711,7 +792,7 @@ function renderRootConflictWarning(entries) {
711
792
  ` built by this plugin: ${moduleRoot}`,
712
793
  ` imported by your app: ${autolinkedRoot}`,
713
794
  ` Both are real directories, not one directory reached through a symlink, so the copies can be different versions. The plugin builds the first one; your app's JavaScript imports the second. When the two disagree it usually surfaces at runtime, as a missing method or "Cannot find native module" — and two copies of different versions can fail the build instead.`,
714
- ` Run \`npm ls ${packageName}\` (or \`yarn why\` / \`pnpm why\`) to find what pulls in the second copy, deduplicate it with \`npm dedupe\` (or \`yarn dedupe\` / \`pnpm dedupe\`), then re-run \`npx react-native spm update\`.`,
795
+ ` Run \`npm ls ${packageName}\` (or \`yarn why\` / \`pnpm why\`) to find what pulls in the second copy, deduplicate it with \`npm dedupe\` (or \`yarn dedupe\` / \`pnpm dedupe\`), then re-run \`${spmUpdateCommand()}\`.`,
715
796
  ].join('\n')
716
797
  )
717
798
  .join('\n\n');
@@ -793,6 +874,28 @@ function renderExtraPodsWarning(pods) {
793
874
  ].join('\n');
794
875
  }
795
876
 
877
+ /**
878
+ * Modules a buildFromSource pattern matched that are linked precompiled, because Swift
879
+ * Package Manager cannot build them from source.
880
+ *
881
+ * @param fallbacks `{ podName, packageName, entry }` per module, `entry` being the pattern.
882
+ */
883
+ function renderBuildFromSourceFallbackWarning(fallbacks) {
884
+ if (!fallbacks.length) return '';
885
+ const one = fallbacks.length === 1;
886
+ const them = one ? 'it' : 'them';
887
+ const entries = [...new Set(fallbacks.map((f) => f.entry))];
888
+ const modules = fallbacks
889
+ .map(({ podName, packageName, entry }) => `${podName} (${packageName}, matched by "${entry}")`)
890
+ .join(', ');
891
+ return [
892
+ `warning: buildFromSource matches ${fallbacks.length} Expo ${one ? 'module' : 'modules'} that Swift Package Manager cannot build from source, so ${one ? 'it is' : 'they are'} linked precompiled instead: ${modules}.`,
893
+ 'A buildFromSource pattern links a module precompiled when Swift Package Manager cannot build that module from source; an entry that names a module exactly fails the sync instead.',
894
+ `To see what blocks a module's source build, list it by its exact pod or npm package name in ${BUILD_FROM_SOURCE_OPTION}: the sync then fails and names the cause.`,
895
+ `To keep ${them} precompiled without this warning, narrow ${entries.map((e) => `"${e}"`).join(', ')} so that no entry matches ${one ? 'this module' : 'these modules'}. ${rerunSpmUpdate()}`,
896
+ ].join(' ');
897
+ }
898
+
796
899
  /** Print the report and return the error to throw, or null when nothing is uncovered. */
797
900
  function reportUnsupported(entries) {
798
901
  if (!entries.length) return null;
@@ -802,6 +905,8 @@ function reportUnsupported(entries) {
802
905
 
803
906
  module.exports = {
804
907
  pluginError,
908
+ BUILD_FROM_SOURCE_OPTION,
909
+ rerunSpmUpdate,
805
910
  UnsupportedModulesError,
806
911
  COVERED_POD_PREFIXES,
807
912
  UNMAPPED_POD_ALLOWLIST,
@@ -817,5 +922,6 @@ module.exports = {
817
922
  renderRootConflictWarning,
818
923
  renderPartlyProvidedPackageWarning,
819
924
  renderExtraPodsWarning,
925
+ renderBuildFromSourceFallbackWarning,
820
926
  reportUnsupported,
821
927
  };
@@ -0,0 +1,215 @@
1
+ /**
2
+ * Links a module whose checked-in Package.swift depends on the ExpoModulesCoreHeaders
3
+ * product through that manifest instead of a generated one. It names its Expo dependencies by
4
+ * paths relative to `<outDir>/direct/<package>`, so this writes those neighbours:
5
+ *
6
+ * direct/<package> → relative symlink to the module root
7
+ * direct/ExpoModulesCoreHeaders → compile-only ExpoModulesCore: a relative symlink to its
8
+ * prebuilt headers xcframework, plus a dependency on the
9
+ * ExpoModulesJSI headers package the plugin emits
10
+ * $BUILD_DIR/ExpoModulesMacros → relative symlink to the prebuilt macro plugin; the
11
+ * manifest names it as `${BUILD_DIR}/ExpoModulesMacros`
12
+ */
13
+
14
+ 'use strict';
15
+
16
+ const fs = require('fs');
17
+ const path = require('path');
18
+
19
+ const { runDumpPackage } = require('./cli');
20
+ const { pluginError, rerunSpmUpdate } = require('./diagnostics');
21
+
22
+ const CORE_HEADERS = 'ExpoModulesCoreHeaders';
23
+ const JSI_HEADERS = 'ExpoModulesJSIHeaders';
24
+ // A binary target cannot have dependencies, so this source target carries the JSI one.
25
+ const CORE_HEADERS_DEPENDENCIES = 'ExpoModulesCoreHeadersDependencies';
26
+ // Written into the package by an earlier generator; nothing reads it now.
27
+ const LEGACY_STUBS_DIR = '.stubs';
28
+
29
+ /**
30
+ * Whether a dumped manifest compiles against ExpoModulesCoreHeaders, which only a manifest
31
+ * written to be built as it stands can name. A `byName` dependency counts: SwiftPM resolves
32
+ * it to that product when no target of the package has the name.
33
+ */
34
+ function dependsOnCoreHeaders(manifest) {
35
+ return (manifest.targets ?? []).some((target) =>
36
+ (target.dependencies ?? []).some(
37
+ (dependency) => (dependency.product ?? dependency.byName)?.[0] === CORE_HEADERS
38
+ )
39
+ );
40
+ }
41
+
42
+ /**
43
+ * Module manifests depend on the product, so it keeps the package's name. ExpoModulesCore's
44
+ * interface re-exports ExpoModulesJSI, so the product brings the JSI headers package along;
45
+ * it must not declare a JSI headers target of its own, because SwiftPM rejects two targets
46
+ * of one name in a graph.
47
+ */
48
+ function coreHeadersManifest(jsiHeadersPkgRelativePath) {
49
+ return `// swift-tools-version: 6.0
50
+ // AUTO-GENERATED by expo/scripts/spm/direct.js — do not edit.
51
+ // Compile-only ExpoModulesCore. The runtime framework is linked and embedded by React
52
+ // Native outside SwiftPM.
53
+ import PackageDescription
54
+
55
+ let package = Package(
56
+ name: "${CORE_HEADERS}",
57
+ products: [
58
+ .library(name: "${CORE_HEADERS}", targets: ["${CORE_HEADERS}", "${CORE_HEADERS_DEPENDENCIES}"]),
59
+ ],
60
+ dependencies: [
61
+ .package(name: "${JSI_HEADERS}", path: "${jsiHeadersPkgRelativePath}"),
62
+ ],
63
+ targets: [
64
+ .binaryTarget(name: "${CORE_HEADERS}", path: "${CORE_HEADERS}.xcframework"),
65
+ .target(
66
+ name: "${CORE_HEADERS_DEPENDENCIES}",
67
+ dependencies: [.product(name: "${JSI_HEADERS}", package: "${JSI_HEADERS}")],
68
+ path: "${CORE_HEADERS_DEPENDENCIES}"
69
+ ),
70
+ ]
71
+ )
72
+ `;
73
+ }
74
+
75
+ function relativeSymlink(target, link) {
76
+ const relative = path.relative(path.dirname(link), target);
77
+ try {
78
+ if (fs.readlinkSync(link) === relative) return;
79
+ } catch {}
80
+ fs.rmSync(link, { recursive: true, force: true });
81
+ fs.symlinkSync(relative, link);
82
+ }
83
+
84
+ function writeIfChanged(file, contents) {
85
+ if (fs.existsSync(file) && fs.readFileSync(file, 'utf8') === contents) return;
86
+ fs.mkdirSync(path.dirname(file), { recursive: true });
87
+ fs.writeFileSync(file, contents);
88
+ }
89
+
90
+ function emitCoreHeadersPackage(directDir, coreHeadersXCFramework, jsiHeadersPkgPath) {
91
+ const pkgDir = path.join(directDir, CORE_HEADERS);
92
+ fs.mkdirSync(pkgDir, { recursive: true });
93
+ fs.rmSync(path.join(pkgDir, LEGACY_STUBS_DIR), { recursive: true, force: true });
94
+ relativeSymlink(coreHeadersXCFramework, path.join(pkgDir, `${CORE_HEADERS}.xcframework`));
95
+ writeIfChanged(
96
+ path.join(pkgDir, CORE_HEADERS_DEPENDENCIES, `${CORE_HEADERS_DEPENDENCIES}.swift`),
97
+ ''
98
+ );
99
+ writeIfChanged(
100
+ path.join(pkgDir, 'Package.swift'),
101
+ coreHeadersManifest(path.relative(pkgDir, jsiHeadersPkgPath))
102
+ );
103
+ }
104
+
105
+ /**
106
+ * Wire one module through its own checked-in manifest. Returns the emission shape
107
+ * `manifests.js#emitPackage` returns, so the plugin links it like any manifest package.
108
+ *
109
+ * @param jsiHeadersPkgPath the ExpoModulesJSI headers package the plugin emits, or null when
110
+ * expo-modules-jsi is not autolinked.
111
+ * @param manifest the module's manifest, as `dumpModuleManifest` parsed it.
112
+ */
113
+ function emitDirectPackage({
114
+ moduleRoot,
115
+ packageName,
116
+ outDir,
117
+ coreHeadersXCFramework,
118
+ jsiHeadersPkgPath,
119
+ macroTool,
120
+ manifest,
121
+ }) {
122
+ if (jsiHeadersPkgPath == null) {
123
+ throw pluginError({
124
+ what: `${packageName} is built from its own Package.swift and needs the ExpoModulesJSI headers, but expo-modules-jsi is not autolinked.`,
125
+ why: 'The ExpoModulesCore headers it compiles against re-export ExpoModulesJSI.',
126
+ how: `expo-modules-core depends on expo-modules-jsi, so reinstall your JavaScript dependencies, and remove expo-modules-jsi from \`"expo": { "autolinking": { "exclude": [...] } }\` in your package.json if it is listed there. ${rerunSpmUpdate()}`,
127
+ });
128
+ }
129
+ const directDir = path.join(outDir, 'direct');
130
+ fs.mkdirSync(directDir, { recursive: true });
131
+ emitCoreHeadersPackage(directDir, coreHeadersXCFramework, jsiHeadersPkgPath);
132
+ const macroLink = macroPluginLink();
133
+ if (macroLink) {
134
+ fs.mkdirSync(path.dirname(macroLink), { recursive: true });
135
+ relativeSymlink(macroTool, macroLink);
136
+ }
137
+ const link = path.join(directDir, packageName);
138
+ fs.mkdirSync(path.dirname(link), { recursive: true });
139
+ relativeSymlink(moduleRoot, link);
140
+ fs.rmSync(path.join(outDir, 'expo-source', manifest.name), { recursive: true, force: true });
141
+
142
+ return {
143
+ ok: {
144
+ packageDep: { name: manifest.name, path: link },
145
+ productDeps: manifest.products.map((p) => ({ name: p.name, package: manifest.name })),
146
+ spmProductNames: [],
147
+ partlyProvidedPackages: [],
148
+ },
149
+ };
150
+ }
151
+
152
+ /**
153
+ * `swift package dump-package` of the checked-in manifest at `moduleRoot`: the JSON the
154
+ * tool printed, and its parse.
155
+ */
156
+ function dumpModuleManifest(moduleRoot, packageName) {
157
+ try {
158
+ const json = runDumpPackage(moduleRoot);
159
+ return { json, manifest: JSON.parse(json) };
160
+ } catch (error) {
161
+ throw pluginError(
162
+ {
163
+ what: `${packageName}'s Package.swift could not be evaluated: ${dumpFailureDetail(error)}.`,
164
+ why: `${packageName} is built from source, so the plugin reads its manifest with \`swift package dump-package\` to decide how to build it and to find the products it exports.`,
165
+ how: `Fix the Package.swift in ${moduleRoot}; run \`swift package dump-package\` in that folder to see the full error. If the swift command is missing, install Xcode and select its command line tools with \`sudo xcode-select --switch /Applications/Xcode.app\`. ${rerunSpmUpdate()}`,
166
+ },
167
+ { cause: error }
168
+ );
169
+ }
170
+ }
171
+
172
+ function dumpFailureDetail(error) {
173
+ if (error.code === 'ENOENT') return 'the swift command was not found';
174
+ const output =
175
+ typeof error.stderr === 'string' && error.stderr.trim() ? error.stderr : error.message;
176
+ return output.trim().split('\n')[0];
177
+ }
178
+
179
+ function macroPluginLink() {
180
+ return process.env.BUILD_DIR ? path.join(process.env.BUILD_DIR, 'ExpoModulesMacros') : null;
181
+ }
182
+
183
+ // Far enough ahead that every later sync stamp is older.
184
+ const PENDING_MARKER_MTIME = new Date('2100-01-01T00:00:00Z');
185
+
186
+ /**
187
+ * Only a sync inside a build knows BUILD_DIR, so only it can create the macro plugin link.
188
+ * RN re-syncs in the build when a watched path has vanished or is newer than its stamp,
189
+ * and drops watched paths that do not exist.
190
+ * - In a build: watch the link, since Clean Build Folder deletes it but keeps the stamp.
191
+ * - Outside a build: the link cannot be made, yet the stamp is fresh. Watch a marker
192
+ * dated in the future, so the next build always re-syncs; that sync removes it.
193
+ */
194
+ function prepareDirectWatchPaths(directPackages, outDir) {
195
+ const marker = path.join(outDir, 'direct', '.macro-plugin-link-pending');
196
+ const macroLink = macroPluginLink();
197
+ const hasDirect = directPackages.length > 0;
198
+ if (!hasDirect || macroLink) {
199
+ fs.rmSync(marker, { force: true });
200
+ return hasDirect ? [macroLink] : [];
201
+ }
202
+ if (fs.statSync(marker, { throwIfNoEntry: false })?.mtimeMs !== PENDING_MARKER_MTIME.getTime()) {
203
+ fs.mkdirSync(path.dirname(marker), { recursive: true });
204
+ fs.writeFileSync(marker, '');
205
+ fs.utimesSync(marker, PENDING_MARKER_MTIME, PENDING_MARKER_MTIME);
206
+ }
207
+ return [marker];
208
+ }
209
+
210
+ module.exports = {
211
+ dependsOnCoreHeaders,
212
+ dumpModuleManifest,
213
+ emitDirectPackage,
214
+ prepareDirectWatchPaths,
215
+ };