Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
build: unserialized plugin throwing
  • Loading branch information
tstelzer committed Jul 8, 2022
commit fbd13b3af471ee8f0f8fd142b88e08240fc94841
26 changes: 13 additions & 13 deletions examples/gatsbydocs/contentlayer.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import rehypeShiki from '@stefanprobst/rehype-shiki'
import type { FieldDef} from 'contentlayer/source-files';
import { defineDocumentType, defineNestedType,makeSource } from 'contentlayer/source-files'
import type { FieldDef } from 'contentlayer/source-files'
import { defineDocumentType, defineNestedType, makeSource } from 'contentlayer/source-files'
import { createRequire } from 'module'
import * as path from 'path'
import * as shiki from 'shiki'
Expand All @@ -20,7 +20,7 @@ const fields: Record<string, FieldDef> = {
},
jsdoc: {
type: 'list',
of: {type: 'string'},
of: { type: 'string' },
},
tableOfContentsDepth: { type: 'number' },
showTopLevelSignatures: { type: 'boolean' },
Expand Down Expand Up @@ -61,20 +61,20 @@ const Tutorial = defineDocumentType(() => ({
}))

export default makeSource(async () => {
const require = createRequire(import.meta.url)
const shikiPkgPath = (dir: string) => path.join(require.resolve('shiki'), '..', '..', dir, path.sep)
const highlighter = await shiki.getHighlighter({
paths: { languages: shikiPkgPath('languages'), themes: shikiPkgPath('themes') },
theme: 'github-light',
})
// const require = createRequire(import.meta.url)
// const shikiPkgPath = (dir: string) => path.join(require.resolve('shiki'), '..', '..', dir, path.sep)
// const highlighter = await shiki.getHighlighter({
// paths: { languages: shikiPkgPath('languages'), themes: shikiPkgPath('themes') },
// theme: 'github-light',
// })

return {
contentDirPath: 'content',
documentTypes: [Reference, HowTo, Conceptual, Tutorial],
// onUnknownDocuments: 'skip-ignore',
markdown: {
// '@stefanprobst/rehype-shiki', {}
rehypePlugins: [[rehypeShiki, { highlighter }]],
},
// markdown: {
// // '@stefanprobst/rehype-shiki', {}
// rehypePlugins: [[rehypeShiki, { highlighter }]],
// },
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { FetchDataError } from '../errors/index.js'
import type { Flags } from '../index.js'
import type { ContentTypeMap, FilePathPatternMap } from '../types.js'
import { DocumentTypeMap, provideDocumentTypeMapState } from './DocumentTypeMap.js'
import { makeCacheItemFromFilePath as withoutPool } from './makeCacheItemFromFilePath.js'
import { fromWorkerPool } from './makeCacheItemFromFilePath.worker.js'
// import {createPool} from './makeCacheItemFromFilePath.worker.js'

export const fetchAllDocuments = ({
coreSchemaDef,
Expand Down Expand Up @@ -46,10 +46,10 @@ export const fetchAllDocuments = ({
const concurrencyLimit = os.cpus().length

const makeCacheItemFromFilePath = fromWorkerPool()
// const makeCacheItemFromFilePath = withoutPool
const { dataErrors, documents, documentTypeMap } = yield* $(
pipe(
allRelativeFilePaths,
// TODO: parallalize
T.forEachParN(concurrencyLimit, (relativeFilePath) =>
makeCacheItemFromFilePath({
relativeFilePath,
Expand All @@ -74,7 +74,6 @@ export const fetchAllDocuments = ({
}
const res = These.result(a)
if (E.isLeft(res)) {
// FIXME: type
errors = Chunk.append_(errors, FetchDataError.fromSerialized(res.left as unknown as any))
} else {
values = Chunk.append_(values, res.right.tuple[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import yaml from 'yaml'
import { FetchDataError } from '../errors/index.js'
import type { ContentTypeMap, FilePathPatternMap } from '../types.js'
import { makeAndProvideDocumentContext } from './DocumentContext.js'
import type { DocumentTypeName, HasDocumentTypeMapState } from './DocumentTypeMap.js'
import type { DocumentTypeName } from './DocumentTypeMap.js'
import { makeDocument } from './mapping.js'
import type { RawContent, RawContentJSON, RawContentMarkdown, RawContentMDX, RawContentYAML } from './types.js'
import { validateDocumentData } from './validateDocumentData.js'
Expand All @@ -20,6 +20,7 @@ export const makeCacheItemFromFilePath = ({
filePathPatternMap,
coreSchemaDef,
contentDirPath,
// FIXME: This doesn't serialize properly.
options,
previousCache,
contentTypeMap,
Expand Down