Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function resolvePartsForPath(basePath) {
return resolveParts({basePath})
}
function resolveStyleImport(moduleId, opts) {
const id = moduleId.replace(/^\.\/(part|all:)/, '$1')
if (!isSanityPart(id)) {
return resolveNodeModule.sync(id, opts)
}
const parts = resolveParts({basePath: opts.root, sync: true})
const loadAll = id.indexOf('all:') === 0
const partName = loadAll ? id.substr(4) : id
const part = parts.implementations[partName]
if (!part) {
throw new Error(`No implementers of part '${partName}'`)
}
const paths = part.map(implementer => implementer.path)
return loadAll ? paths.reverse() : paths[0]
}
const getDocumentComponent = basePath =>
resolveParts({basePath}).then(res => {
const part = res.implementations[docPart]
if (!part) {
throw new Error(
`Part '${docPart}' is not implemented by any plugins, are you missing @sanity/base?`
)
}
return getDefaultModule(requireUncached(part[0].path))
})
function resolveStyleImport(moduleId, opts) {
const id = moduleId.replace(/^\.\/(part|all:)/, '$1')
if (!isSanityPart(id)) {
return resolveNodeModule.sync(id, opts)
}
const parts = resolveParts({basePath: opts.root, sync: true})
const loadAll = id.indexOf('all:') === 0
const partName = loadAll ? id.substr(4) : id
const part = parts.implementations[partName]
if (!part) {
throw new Error(`No implementers of part '${partName}'`)
}
const paths = part.map(implementer => implementer.path)
return loadAll ? paths.reverse() : paths[0]
}
function cacheParts(params) {
const instance = params.compiler || params
instance.sanity = compiler.sanity || {basePath: basePath}
return partResolver.resolveParts({env, basePath, additionalPlugins}).then(parts => {
instance.sanity.parts = parts
})
}
export function callInitializers(config) {
resolveParts({config}).then(res => {
const parts = res.implementations[initPart]
if (!parts) {
return
}
res.implementations[initPart]
.map(part => getDefaultModule(require(part.path)))
.forEach(initializer => initializer(config))
})
}
function sanityCheck(options) {
return resolveParts({
basePath: options.dir,
useCompiledPaths: options.productionMode
}).then(parts => checkImplementations(parts, options))
}