timlrx / contentlayer2

Contentlayer turns your content into data - making it super easy to import MD(X) and CMS content in your app
https://contentlayer.dev
MIT License
153 stars 11 forks source link

next 14.2.4 type:module give error #20

Open tianyingchun opened 2 months ago

tianyingchun commented 2 months ago

Generated 13 documents in .contentlayer ✓ Ready in 3.7s ○ Compiling / ... ✓ Compiled / in 4.9s (1255 modules) GET / 200 in 5301ms ✓ Compiled in 340ms (580 modules)

[webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Parsing of /Users/tianyingchun/Documents/hyperse-internal/hyperse-blog/node_modules/@contentlayer2/core/dist/generation/generate-dotpkg.js for build dependencies failed at 'import(URL.pathToFileURL(filePathJoin(generatedPkgPath, 'generated', 'index.mjs')).href)'. Build dependencies behind this expression are ignored and might cause incorrect cache invalidation.
tianyingchun commented 2 months ago

"contentlayer2": "0.4.6", "next-contentlayer2": "0.4.6",

timlrx commented 2 months ago

Sorry, could you elaborate on what causes the error and provide a small reproducible is possible?

tianyingchun commented 2 months ago

okay, i will find time to make a small reproduce repo

yangchristina commented 2 months ago

Am also getting this, npm run dev works fine, but no posts show up on build

Edit: oops, posts do show up, I set draft to true by accident. Despite this error, everything still appears to be running fine.

timlrx commented 2 months ago

Could you include more information on the version of Next and React that you are using as well. I just tested on Next 15 canary and React 19 without issue - https://stackblitz.com/edit/github-ekmxur-ba82kk?file=package.json

tianyingchun commented 2 months ago

see here https://github.com/tianyingchun/tailwind-nextjs-starter-blog-issue

  1. yarn install
  2. yarn dev
  3. see below image
tianyingchun commented 2 months ago

also see latest commit https://github.com/tianyingchun/tailwind-nextjs-starter-blog-issue/commit/4e8b693192f19c539ca465073052e15e7c426b08

timlrx commented 2 months ago

Ah this is the same issue as https://github.com/contentlayerdev/contentlayer/issues/313. It's a Webpack warning that can be ignored: https://github.com/webpack/webpack/pull/15688. Or if you don't use "type": "module", you can avoid this error as well.

tianyingchun commented 2 months ago

yes, i know, but don't know why, i just switch to turbo & webpack in memory cache.

ham-evans commented 1 month ago

I'm getting this too with "contentlayer2": "^0.5.0". Definitely triggered by "type": "module" in package.json but would be awesome if there was a way to remove it.

is proposed solution adding this to next.config under the webpack? (see here)

config.infrastructureLogging = {
      level: "error",
    };