sdorra / content-collections

Transform your content into type-safe data collections
https://content-collections.dev
MIT License
528 stars 23 forks source link

Windows hot reload w/Nextjs #227

Closed i-am-henri closed 3 months ago

i-am-henri commented 3 months ago

The hot reload of Markdown files is not working with Nextjs. This means, you'll have to reload the server manually, everytime you want to change smthg. I think it has something to do with @parcel/watch because this is logged in the console: image And vercel triggers an error when they try to build the project: image

i-am-henri commented 3 months ago

I tried to install @parcel/watcher manually, but this also didn't worked

i-am-henri commented 3 months ago

And the error in the vercel build still occuress.

i-am-henri commented 3 months ago

Is it important to use @parcel/watch? Maybe it is possible to use an other library like chokidar...

i-am-henri commented 3 months ago

When you install @parcel/watcher as an dev dependency, it's working with vercel, but not local

sdorra commented 3 months ago

That is strange, i run a lot of builds with content collections on vercel and none of them need the extra dependency. Which node version and which package manager do you use on vercel?

i-am-henri commented 3 months ago

On vercel it's not a specific package manager I think: image

sdorra commented 3 months ago

Vercel uses your package.json and lock files to use the same package manager as you local use. Can you post a complete build log from vercel (as text)?

i-am-henri commented 3 months ago

In my package.json is npm specified, but I actually use bun as my Package manager on the local project...

i-am-henri commented 3 months ago

These are the Logs, When the build was done with the error:

[22:57:11.371] Running build in Washington, D.C., USA (East) – iad1 [22:57:11.520] Cloning github.com/i-am-henri/henri (Branch: dev, Commit: 8edac07) [22:57:11.898] Cloning completed: 375.267ms [22:57:15.166] Restored build cache [22:57:15.252] Running "vercel build" [22:57:16.754] Vercel CLI 35.1.0 [22:57:17.179] Installing dependencies... [22:57:19.222] [22:57:19.222] added 42 packages, removed 14 packages, and changed 1 package in 2s [22:57:19.222] [22:57:19.223] 248 packages are looking for funding [22:57:19.223] run npm fund for details [22:57:19.235] Detected Next.js version: 14.2.5 [22:57:19.239] Detected package-lock.json generated by npm 7+ [22:57:19.239] Running "npm run build" [22:57:19.373] [22:57:19.374] > henri@0.1.0 build [22:57:19.374] > next build [22:57:19.374] [22:57:20.059] [22:57:20.060] > Build error occurred [22:57:20.061] Error: No prebuild or local build of @parcel/watcher found. Tried @parcel/watcher-linux-x64-glibc. Please ensure it is installed (don't use --no-optional when installing with npm). Otherwise it is possible we don't support your platform yet. If this is the case, please report an issue to https://github.com/parcel-bundler/watcher. [22:57:20.062] at Object. (/vercel/path0/node_modules/@parcel/watcher/index.js:26:13) [22:57:20.062] at Module._compile (node:internal/modules/cjs/loader:1358:14) [22:57:20.062] at Module._extensions..js (node:internal/modules/cjs/loader:1416:10) [22:57:20.062] at Module.load (node:internal/modules/cjs/loader:1208:32) [22:57:20.063] at Module._load (node:internal/modules/cjs/loader:1024:12) [22:57:20.063] at cjsLoader (node:internal/modules/esm/translators:348:17) [22:57:20.063] at ModuleWrap. (node:internal/modules/esm/translators:297:7) [22:57:20.063] at ModuleJob.run (node:internal/modules/esm/module_job:222:25) [22:57:20.063] at async ModuleLoader.import (node:internal/modules/esm/loader:316:24) [22:57:20.063] at async file:///vercel/path0/node_modules/@content-collections/next/dist/index.js:10:33 [22:57:20.081] Error: Command "npm run build" exited with 1 [22:57:20.352]

sdorra commented 3 months ago

I've forked you repository, removed @parcel/watcher dependency and committed the package-lock.json:

https://henri-sooty.vercel.app/

[13:18:02.704] Running build in Washington, D.C., USA (East) – iad1
[13:18:02.900] Cloning github.com/sdorra/henri (Branch: dev, Commit: 2377d05)
[13:18:03.191] Cloning completed: 291.577ms
[13:18:03.289] Previous build cache not available
[13:18:03.505] Running "vercel build"
[13:18:03.953] Vercel CLI 35.1.0
[13:18:04.740] Installing dependencies...
[13:18:08.328] npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
[13:18:09.295] npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
[13:18:10.661] npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
[13:18:10.733] npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
[13:18:10.939] npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
[13:18:18.055] 
[13:18:18.055] added 602 packages in 13s
[13:18:18.056] 
[13:18:18.057] 250 packages are looking for funding
[13:18:18.057]   run `npm fund` for details
[13:18:18.078] Detected Next.js version: 14.2.5
[13:18:18.084] Detected `package-lock.json` generated by npm 7+
[13:18:18.084] Running "npm run build"
[13:18:19.200] 
[13:18:19.200] > henri@0.1.0 build
[13:18:19.201] > next build
[13:18:19.201] 
[13:18:19.893] Starting content-collections content-collections.ts
[13:18:19.943] build started ...
[13:18:20.126] ❇️  success by getting documents: "how-to-markdown"
[13:18:20.126] ... finished build in 183ms
[13:18:20.144] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[13:18:20.145] This information is used to shape Next.js' roadmap and prioritize features.
[13:18:20.145] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[13:18:20.145] https://nextjs.org/telemetry
[13:18:20.145] 
[13:18:20.208]   ▲ Next.js 14.2.5
[13:18:20.209] 
[13:18:20.276]    Creating an optimized production build ...
[13:18:22.296]  ⨯ Failed to find font override values for font `Newsreader`
[13:18:22.299]  ⨯ Failed to find font override values for font `Newsreader`
[13:18:30.318]  ⨯ Failed to find font override values for font `Newsreader`
[13:18:30.320]  ⨯ Failed to find font override values for font `Newsreader`
[13:18:35.060]  ✓ Compiled successfully
[13:18:35.061]    Linting and checking validity of types ...
[13:18:40.263]    Collecting page data ...
[13:18:41.463]    Generating static pages (0/6) ...
[13:18:41.784]    Generating static pages (1/6) 
[13:18:41.785]    Generating static pages (2/6) 
[13:18:41.818] [ 'how-to-markdown.mdx' ]
[13:18:41.819] [ 'how-to-markdown.mdx' ]
[13:18:41.905]    Generating static pages (4/6) 
[13:18:41.967] [ 'How to do Markdown.' ]
[13:18:41.967] [ 'How to do Markdown.' ]
[13:18:41.982]  ✓ Generating static pages (6/6)
[13:18:42.471]    Finalizing page optimization ...
[13:18:42.471]    Collecting build traces ...
[13:18:47.439] 
[13:18:47.449] Route (app)                              Size     First Load JS
[13:18:47.449] ┌ ○ /                                    737 B           122 kB
[13:18:47.450] ├ ○ /_not-found                          141 B          87.2 kB
[13:18:47.450] ├ ○ /blog                                290 B          94.1 kB
[13:18:47.450] ├ ƒ /blog/[id]                           3.72 kB         118 kB
[13:18:47.450] └ ○ /work                                16.9 kB         126 kB
[13:18:47.450] + First Load JS shared by all            87.1 kB
[13:18:47.450]   ├ chunks/23-1523df5da3dfac41.js        31.5 kB
[13:18:47.450]   ├ chunks/fd9d1056-046e85abdd898386.js  53.6 kB
[13:18:47.451]   └ other shared chunks (total)          1.92 kB
[13:18:47.451] 
[13:18:47.451] 
[13:18:47.451] ○  (Static)   prerendered as static content
[13:18:47.451] ƒ  (Dynamic)  server-rendered on demand
[13:18:47.451] 
[13:18:47.537] Traced Next.js server files in: 31.378ms
[13:18:47.664] Created all serverless functions in: 126.025ms
[13:18:47.676] Collected static files (public/, static/, .next/static): 8.3ms
[13:18:47.706] Build Completed in /vercel/output [43s]
[13:18:47.835] Deploying outputs...
[13:18:47.837] Injected Vercel Toolbar into the build output, you can disable this in your project settings.
[13:18:56.265] 
[13:18:56.522] Deployment completed
[13:19:03.117] Uploading build cache [112.45 MB]...
[13:19:04.691] Build cache uploaded: 1.573s
i-am-henri commented 3 months ago

Ok, that's kinda weird. Is maybe bun the problem?

sdorra commented 3 months ago

You should not switch the package manager between dev and production. It is best practice to use npm or bun, but not both at the same time. You should also commit the package lock file, to ensure that all stages are using the same dependency versions.

I don't think that bun is the problem, because vercel has just used npm. You should decide which package manager you want to use. Then commit the lock file so that vercel is able to detect the used one and use the same for the production build.

i-am-henri commented 3 months ago

Ok, I Unterstand. As soon as I'm Home, I'll change it. But the Problem with the local watcher continues, this wasn't the fix for both, right?

sdorra commented 3 months ago

No, that should only fix the build on vercel.

sdorra commented 3 months ago

I was able to reproduce the watcher problem on windows. I will try to fix it, in the next days.

sdorra commented 3 months ago

@i-am-henri the issue should be fixed with version 0.6.4 of @content-collections/core.

i-am-henri commented 3 months ago

Thank you very much. I'll try it as fast as possible