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

<w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Parsing of /node_modules/@contentlayer/core/dist/generation/generate-dotpkg.js for build dependencies failed at 'import(filePathJoin(generatedPkgPath, 'generated', 'index.mjs'))'. #667

Open
JamesIves opened this issue Jul 4, 2024 · 6 comments

Comments

@JamesIves
Copy link

JamesIves commented Jul 4, 2024

Been seeing this warning as of late, and I'm unsure what the actual cause is here. Seems to stem from generate-dotpkg.js.

<w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Parsing of node_modules/@contentlayer/core/dist/generation/generate-dotpkg.js for build dependencies failed at 'import(filePathJoin(generatedPkgPath, 'generated', 'index.mjs'))'.
<w> Build dependencies behind this expression are ignored and might cause incorrect cache invalidation.
    [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo]  at file dependencies node_modules/@contentlayer/core/dist/generation/generate-dotpkg.js
     at file node_modules/@contentlayer/core/dist/generation/generate-dotpkg.js
     at resolve esm file ./generation/generate-dotpkg.js
     at file dependencies node_modules/@contentlayer/core/dist/index.js
     at file node_modules/@contentlayer/core/dist/index.js
     at resolve esm file @contentlayer/core
     at file dependencies node_modules/next-contentlayer/dist/plugin.js
     at file node_modules/next-contentlayer/dist/plugin.js
     at resolve esm file ./plugin.js
     at file dependencies node_modules/next-contentlayer/dist/index.js
     at file node_modules/next-contentlayer/dist/index.js
     at resolve esm file next-contentlayer
     at file dependencies next.config.mjs
     at file next.config.mjs
     at resolve commonjs next.config.mjs
    [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] SyntaxError: Unexpected token 'i', "filePathJoi"... is not valid JSON
        at JSON.parse (<anonymous>)
        at parseString (node_modules/next/dist/compiled/webpack/bundle5.js:28:260457)
        at node_modules/next/dist/compiled/webpack/bundle5.js:28:276877
        at node_modules/next/dist/compiled/webpack/bundle5.js:1:268942
        at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3)
        at FSReqCallback.callbackTrampoline (node:internal/async_hooks:130:17)

Versions:

"next": "14.2.4",
"next-contentlayer": "0.3.4",
"contentlayer": "0.3.4",
@abolfazlcodes
Copy link

Did you find anything to solve this issue? Also the package seems to be in beta and installing other packages we should use --legacy-peer-deps.

@abolfazlcodes
Copy link

abolfazlcodes commented Jul 27, 2024

I added this to my package.json and it resolved the logs @JamesIves:

"overrides": {
"next-contentlayer": {
"next": "$next"
}
}

@sunnysingh100
Copy link

did you find the solution of the issue @JamesIves

@JamesIves
Copy link
Author

Nope, error persists. Doesn't cause any problems so I've just ignored it for now.

@sunnysingh100
Copy link

thank you! @abolfazlcodes

@OmarAfet
Copy link

This warning occurs because Webpack is unable to statically analyze a dynamic import() statement with a variable path in the Contentlayer package's generate-dotpkg.js file:

await import(filePathJoin(generatedPkgPath, 'generated', 'index.mjs'));

Webpack relies on static analysis to determine module dependencies during the build process. When it encounters a dynamic import where the module path isn't a static string, it can't resolve the dependencies at build time. This leads to the warning:

Parsing of ... generate-dotpkg.js for build dependencies failed at 'import(filePathJoin(...))'.
Build dependencies behind this expression are ignored and might cause incorrect cache invalidation.

As a result, Webpack warns that it cannot track the dependencies behind this dynamic import, which might lead to incorrect cache invalidation because it doesn't know when to rebuild these dependencies if they change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants