@exodus/stasis-plugins 1.0.0-rc.1 → 1.0.0-rc.2
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/package.json +2 -2
- package/src/metro-native.js +3 -3
- package/src/metro.js +5 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/stasis-plugins",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
4
|
"description": "Bundler plugins (webpack, esbuild, Rollup, Metro) for @exodus/stasis-core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://github.com/PreventiveMeasures/stasis#readme",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@exodus/stasis-core": "1.0.0-rc.
|
|
39
|
+
"@exodus/stasis-core": "1.0.0-rc.2"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/metro-native.js
CHANGED
|
@@ -3,7 +3,7 @@ import { basename, dirname, join, posix, relative, sep } from 'node:path'
|
|
|
3
3
|
|
|
4
4
|
import { readJson } from '@exodus/stasis-core/bundle-util'
|
|
5
5
|
import { diskHost } from '@exodus/stasis-core/host'
|
|
6
|
-
import { CODE_EXTENSIONS, classifyFormat, isAutoExcludedDir, isBinaryPlist, isDotEnvFile, isExcludedNativeFile, isNativeArtifact, nameFormat, pathExt, toPosix, upsert } from '@exodus/stasis-core/util'
|
|
6
|
+
import { CODE_EXTENSIONS, classifyFormat, isAutoExcludedDir, isBinaryPlist, isDotEnvFile, isExcludedNativeFile, isNativeArtifact, metroFormat, nameFormat, pathExt, toPosix, upsert } from '@exodus/stasis-core/util'
|
|
7
7
|
|
|
8
8
|
// The native build inputs of a React Native app's packages, shared by the Metro plugin's capture and `stasis bundle
|
|
9
9
|
// --metro` so the two carry the same files. `fs` is a host: readdir(dir) -> Dirent[] (throws where `dir` isn't one),
|
|
@@ -119,7 +119,7 @@ const isCodegenSpec = (name) => /^(?:Native.+|.+NativeComponent)/u.test(name) &&
|
|
|
119
119
|
|
|
120
120
|
// Each native build input of the package at `root`, walked whole (a podspec may compile `cpp/` beside `ios/`) but
|
|
121
121
|
// build output, prebuilt binaries, an off-platform top-level dir, symlinks and what the shared classifier skips; and
|
|
122
|
-
// its codegen specs, as code
|
|
122
|
+
// its codegen specs, as code Metro's format names. -> yields { file, source, action: 'code' | 'resource', format }
|
|
123
123
|
export function* nativeInputs(root, fs, { resources = new Set(), skip = () => false } = {}) {
|
|
124
124
|
yield* walk(root, true)
|
|
125
125
|
for (const dir of codegenSources(root, fs)) yield* sources(dir)
|
|
@@ -129,7 +129,7 @@ export function* nativeInputs(root, fs, { resources = new Set(), skip = () => fa
|
|
|
129
129
|
if (ent.isSymbolicLink() || ent.name.startsWith('.') || ent.name === 'node_modules' || ent.name.startsWith('__tests')) continue
|
|
130
130
|
const file = join(dir, ent.name)
|
|
131
131
|
if (ent.isDirectory()) yield* sources(file)
|
|
132
|
-
else if (ent.isFile() && isCodegenSpec(ent.name) && !skip(file)) yield { file, source: fs.readFile(file), action: 'code', format:
|
|
132
|
+
else if (ent.isFile() && isCodegenSpec(ent.name) && !skip(file)) yield { file, source: fs.readFile(file), action: 'code', format: metroFormat(file) }
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
function* walk(dir, atRoot) {
|
package/src/metro.js
CHANGED
|
@@ -12,7 +12,7 @@ import { diskHost } from '@exodus/stasis-core/host'
|
|
|
12
12
|
import { State } from '@exodus/stasis-core/state'
|
|
13
13
|
// realReadFileSync throughout: the plugin's own reads, which --fs must not record as the program's.
|
|
14
14
|
import { inScope, realReadFileSync } from '@exodus/stasis-core/state-util'
|
|
15
|
-
import { classifyExtension, classifyFormat, isPathWithin,
|
|
15
|
+
import { classifyExtension, classifyFormat, isPathWithin, metroFormat, splitNodeModulesPath } from '@exodus/stasis-core/util'
|
|
16
16
|
|
|
17
17
|
const require = createRequire(import.meta.url)
|
|
18
18
|
|
|
@@ -272,7 +272,7 @@ export class StasisMetro {
|
|
|
272
272
|
return [...new Set(reached.map((nm) => nm.dir))].filter((root) => looksNative(root, diskHost))
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
// In the format nativeInputs gives (
|
|
275
|
+
// In the format nativeInputs gives (a codegen source's generic, as Metro's code has, so none is inferred).
|
|
276
276
|
#captureNativeTree(root) {
|
|
277
277
|
for (const { file, source, action, format } of nativeInputs(root, diskHost, { resources: this.#resources, skip: (f) => this.#seen.has(f) })) {
|
|
278
278
|
this.#seen.add(file)
|
|
@@ -354,15 +354,15 @@ export class StasisMetro {
|
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
-
// Capture `path` once, as the `kind` classifyExtension gives it: code
|
|
358
|
-
// (
|
|
357
|
+
// Capture `path` once, as the `kind` classifyExtension gives it: code in the format Metro builds it in
|
|
358
|
+
// (metroFormat), as Metro transforms it from source. From disk: addFile re-reads it to assert the bytes.
|
|
359
359
|
// -> whether it was new
|
|
360
360
|
#captureRead(path, kind, isEntry = false) {
|
|
361
361
|
if (this.#seen.has(path)) return false
|
|
362
362
|
this.#seen.add(path)
|
|
363
363
|
const source = realReadFileSync(path)
|
|
364
364
|
if (kind === 'code') assertCodeUtf8('StasisMetro', path, source)
|
|
365
|
-
const format = kind === 'code' ?
|
|
365
|
+
const format = kind === 'code' ? metroFormat(path) : undefined
|
|
366
366
|
const resource = kind === 'resource'
|
|
367
367
|
this.#state.addFile(pathToFileURL(path).toString(), { source, format, isEntry, resource, inferFormat: false, reason: 'metro' })
|
|
368
368
|
return true
|