MCPcopy
hub / github.com/PlasmoHQ/plasmo / initializeState

Function initializeState

core/parcel-resolver/src/shared.ts:45–91  ·  view source on GitHub ↗
(props: ResolverProps)

Source from the content-addressed store, hash-verified

43}
44
45export const initializeState = async (props: ResolverProps) => {
46 if (state.got === null) {
47 state.got = (await import("got")).default
48 }
49 if (!state.dotPlasmoDirectory) {
50 state.dotPlasmoDirectory = resolve(
51 process.env.PLASMO_PROJECT_DIR,
52 ".plasmo"
53 )
54 }
55 if (!state.remoteCacheDirectory) {
56 state.remoteCacheDirectory = resolve(
57 state.dotPlasmoDirectory,
58 "cache",
59 "remote-code"
60 )
61
62 if (!(await props.options.inputFS.exists(state.remoteCacheDirectory))) {
63 vLog("Reinitializing remote cache directory")
64 await props.options.inputFS.mkdirp(state.remoteCacheDirectory)
65 }
66 }
67
68 if (!state.polyfillMap) {
69 const polyfillsDirectory = join(__dirname, "polyfills")
70
71 const polyfillHandlers = await glob("**/*.js", {
72 cwd: polyfillsDirectory,
73 onlyFiles: true
74 })
75
76 state.polyfillMap = new Map(
77 polyfillHandlers.map((handler) => [
78 toPosix(handler.slice(0, -3)),
79 join(polyfillsDirectory, handler)
80 ])
81 )
82 }
83
84 if (!state.aliasMap) {
85 const packageJson = await readJson(
86 resolve(process.env.PLASMO_PROJECT_DIR, "package.json")
87 )
88
89 state.aliasMap = new Map(Object.entries(packageJson.alias || {}))
90 }
91}
92
93/**
94 * Look for source code file (crawl index)

Callers 1

resolveFunction · 0.90

Calls 1

resolveFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…