MCPcopy Create free account
hub / github.com/arktypeio/arktype / transform

Function transform

ark/aot/unplugin.ts:905–940  ·  view source on GitHub ↗
(
		code: string,
		id: string,
		mappings: string | undefined,
		program: string | undefined,
		resolve: BundlerResolve | undefined
	)

Source from the content-addressed store, hash-verified

903 transformedFilter.include.test(id) && !transformedFilter.exclude.test(id)
904 // keeps the modules a transformed one writes, for its importers to load
905 const transform = async (
906 code: string,
907 id: string,
908 mappings: string | undefined,
909 program: string | undefined,
910 resolve: BundlerResolve | undefined
911 ) => {
912 const transformed = (await requestResolving(
913 resolve,
914 "transform",
915 code,
916 fileOf(id),
917 mappings,
918 program
919 )) as TransformedModule | undefined
920 if (!transformed) return
921 if (transformed.foldedHelpers.length)
922 foldedHelpersById.set(fileOf(id), transformed.foldedHelpers)
923 else foldedHelpersById.delete(fileOf(id))
924 for (const specifier in transformed.modules) {
925 const virtualId = virtual + specifier
926 // one may be named for what it does, as `invalid` is, which another
927 // build's program writes otherwise, as its errors tier decides
928 if (modules[virtualId] === transformed.modules[specifier]) continue
929 modules[virtualId] = transformed.modules[specifier]
930 importersById[virtualId] = id
931 const dir = storeDirOf()
932 if (dir) {
933 writeFileSync(
934 join(dir, storedNameOf(virtualId)),
935 JSON.stringify([id, modules[virtualId]])
936 )
937 }
938 }
939 return transformed
940 }
941 // each Rollup, Rolldown or Vite build's scan, by its Vite environment
942 const scansByBuild = new WeakMap<object, BundleScan>()
943 // begun as the plugin transforms a module, as only then can it load what another plugin writes

Callers 3

rewrittenInFunction · 0.70
loadEsbuildModulesFunction · 0.70
handlerFunction · 0.70

Calls 7

fileOfFunction · 0.90
requestResolvingFunction · 0.85
storeDirOfFunction · 0.85
joinFunction · 0.85
storedNameOfFunction · 0.85
setMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected