Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unchecked error running contentlayer build without contentDirPath #282

Closed
lachlanjc opened this issue Aug 3, 2022 · 1 comment
Closed
Labels
duplicate This issue or pull request already exists

Comments

@lachlanjc
Copy link

lachlanjc commented Aug 3, 2022

I'm using pnpm without TypeScript with MDX on this project, & discovered that commenting out the contentDirPath line in my config file causes this unchecked error. While I know it's marked required in the docs, especially in the era of Copilot I think giving clearer error messages in these cases is a nice DX win, so consider it a polish item.

This error shouldn't have happened. Please consider opening a GitHub issue with the stack trace below here:
https://github.com/contentlayerdev/contentlayer/issues

An unchecked error was produced.

TypeError: Cannot read properties of undefined (reading 'includes')
    at isPosixFilePathString (file:///Users/lachlanjc/src/lachlanjc/notebook/node_modules/.pnpm/@contentlayer+utils@0.2.6/node_modules/@contentlayer/utils/src/file-paths.ts:14:64)
    at unknownToPosixFilePath (file:///Users/lachlanjc/src/lachlanjc/notebook/node_modules/.pnpm/@contentlayer+utils@0.2.6/node_modules/@contentlayer/utils/src/file-paths.ts:22:7)
    at Object.fetchData (file:///Users/lachlanjc/src/lachlanjc/notebook/node_modules/.pnpm/@contentlayer+source-files@0.2.6/node_modules/@contentlayer/source-files/src/index.ts:112:25)
    at file:///Users/lachlanjc/src/lachlanjc/notebook/node_modules/.pnpm/@contentlayer+core@0.2.6/node_modules/@contentlayer/core/src/generation/generate-dotpkg.ts:93:23
    at onRight (file:///Users/lachlanjc/src/lachlanjc/notebook/node_modules/.pnpm/@contentlayer+utils@0.2.6/node_modules/@contentlayer/utils/src/effect/Stream.ts:77:20)
    at f (file:///Users/lachlanjc/src/lachlanjc/notebook/node_modules/.pnpm/@effect-ts+system@0.55.1/node_modules/@effect-ts/system/_src/Either/core.ts:362:50)
    at f (file:///Users/lachlanjc/src/lachlanjc/notebook/node_modules/.pnpm/@effect-ts+system@0.55.1/node_modules/@effect-ts/system/_src/Experimental/Stream/_internal/api/chain.ts:18:27)
    at Module.map_ (file:///Users/lachlanjc/src/lachlanjc/notebook/node_modules/.pnpm/@effect-ts+system@0.55.1/node_modules/@effect-ts/system/_src/Collections/Immutable/Chunk/core.ts:253:26)
    at Inner.subK (file:///Users/lachlanjc/src/lachlanjc/notebook/node_modules/.pnpm/@effect-ts+system@0.55.1/node_modules/@effect-ts/system/_src/Experimental/Stream/_internal/api/chain.ts:18:12)
    at file:///Users/lachlanjc/src/lachlanjc/notebook/node_modules/.pnpm/@effect-ts+system@0.55.1/node_modules/@effect-ts/system/_src/Experimental/Stream/Channel/_internal/executor.ts:875:25

Fiber: #1 (started at: 2022-08-03T06:23:35.605Z) was supposed to continue to:

  a future continuation at packages/@contentlayer/core/src/generation/generate-dotpkg.ts:60:10
  a future continuation at packages/@contentlayer/cli/src/commands/BuildCommand.ts:27:12
  a future continuation at packages/@contentlayer/core/src/runMain.ts:23:79

Fiber: #1 (started at: 2022-08-03T06:23:35.605Z) Execution trace:

  packages/@contentlayer/core/src/generation/generate-dotpkg.ts:82:13
  packages/@contentlayer/core/src/generation/generate-dotpkg.ts:78:16
  packages/@contentlayer/cli/src/commands/BuildCommand.ts:26:14
  packages/@contentlayer/cli/src/commands/BuildCommand.ts:25:91
  packages/@contentlayer/cli/src/commands/BuildCommand.ts:25:12
  packages/@contentlayer/core/src/getConfig/index.ts:41:18
  packages/@contentlayer/core/src/getConfig/index.ts:40:10
  packages/@contentlayer/core/src/getConfig/esbuild.ts:47:15
  packages/@contentlayer/core/src/getConfig/esbuild.ts:39:26
  packages/@contentlayer/core/src/getConfig/esbuild.ts:37:12
  packages/@contentlayer/core/src/getConfig/esbuild.ts:117:12
  packages/@contentlayer/core/src/getConfig/esbuild.ts:75:36
  packages/@contentlayer/core/src/getConfig/index.ts:197:13
  packages/@contentlayer/core/src/getConfig/index.ts:186:28
  packages/@contentlayer/core/src/getConfig/index.ts:184:44
  packages/@contentlayer/core/src/getConfig/index.ts:171:28
  packages/@contentlayer/core/src/getConfig/index.ts:169:31
  packages/@contentlayer/core/src/getConfig/index.ts:156:28
  packages/@contentlayer/core/src/getConfig/index.ts:154:15
  packages/@contentlayer/core/src/getConfig/index.ts:151:15
  packages/@contentlayer/core/src/getConfig/index.ts:150:15
  packages/@contentlayer/core/src/cwd.ts:24:43
  packages/@contentlayer/core/src/getConfig/index.ts:135:27
  packages/@contentlayer/core/src/getConfig/index.ts:122:10
  packages/@contentlayer/core/src/getConfig/esbuild.ts:118:12

Fiber: #1 (started at: 2022-08-03T06:23:35.605Z) was spawned by: <empty trace>

OS: darwin 21.5.0 (arch: arm64)
Process: /usr/local/bin/node /Users/lachlanjc/src/lachlanjc/notebook/node_modules/contentlayer/bin/cli.cjs build
Node version: v16.14.2
Contentlayer version: 0.2.6
@schickling
Copy link
Collaborator

schickling commented Aug 4, 2022

Thanks a lot for opening this issue. While I think Contentlayer could be improved in terms of runtime error handling (which is tracked in #214) for cases like these (usually only happens when developers don't use TypeScript), this actual reported error is due to unintended usage of Contentlayer.

As described in the docs contentDirPath is a required property.

CleanShot 2022-08-04 at 14 11 03@2x

@schickling schickling added the duplicate This issue or pull request already exists label Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants