MCPcopy Create free account
hub / github.com/Effect-TS/effect / make

Function make

packages/ui/native/src/node/internal/transformer.ts:49–82  ·  view source on GitHub ↗
(settings: Settings)

Source from the content-addressed store, hash-verified

47/** @internal */
48// oxlint-disable-next-line effect/no-unused-internal -- Metro's file calls it.
49export const make = (settings: Settings) => {
50 let upstream:
51 | {
52 transform: (args: Args) => unknown
53 getCacheKey?: (...args: ReadonlyArray<unknown>) => string
54 }
55 | undefined
56 const load = () => upstream ??= Module.createRequire(import.meta.url)(settings.upstream)
57 return {
58 transform: (args: Args): unknown => {
59 const { dev, platform, projectRoot } = args.options
60 const bundle = platform === null ? undefined : settings.bundles[platform]
61 return load()!.transform(
62 !dev && bundle !== undefined &&
63 isFile(Path.resolve(projectRoot, args.filename), bundle.entry)
64 ? {
65 ...args,
66 src: `module.exports = require(${JSON.stringify(bundle.file)})\n`
67 }
68 : args
69 )
70 },
71 getCacheKey: (...args: ReadonlyArray<unknown>): string =>
72 // Metro hashes only the file that calls this, not this one or the
73 // upstream.
74 [
75 load()!.getCacheKey?.(...args) ?? "",
76 Crypto.createHash("sha1")
77 .update(Fs.readFileSync(fileURLToPath(import.meta.url)))
78 .update(Fs.readFileSync(settings.upstream))
79 .digest("hex")
80 ].join("$")
81 }
82}

Callers

nothing calls this directly

Calls 7

resolveMethod · 0.80
loadFunction · 0.70
isFileFunction · 0.70
transformMethod · 0.65
updateMethod · 0.65
joinMethod · 0.45
digestMethod · 0.45

Tested by

no test coverage detected