MCPcopy
hub / github.com/rollup/rollup / getModuleContext

Function getModuleContext

src/utils/options/normalizeInputOptions.ts:186–202  ·  view source on GitHub ↗
(
	config: InputOptions,
	context: string
)

Source from the content-addressed store, hash-verified

184};
185
186const getModuleContext = (
187 config: InputOptions,
188 context: string
189): NormalizedInputOptions['moduleContext'] => {
190 const configModuleContext = config.moduleContext;
191 if (typeof configModuleContext === 'function') {
192 return id => configModuleContext(id) ?? context;
193 }
194 if (configModuleContext) {
195 const contextByModuleId: Record<string, string> = Object.create(null);
196 for (const [key, moduleContext] of Object.entries(configModuleContext)) {
197 contextByModuleId[resolve(key)] = moduleContext;
198 }
199 return id => contextByModuleId[id] ?? context;
200 }
201 return () => context;
202};
203
204const getTreeshake = (config: InputOptions): NormalizedInputOptions['treeshake'] => {
205 const configTreeshake = config.treeshake;

Callers 1

normalizeInputOptionsFunction · 0.85

Calls 1

resolveFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…