Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 23 additions & 0 deletions app/pages/blog/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@ useSeoMeta({
ogDescription: () => $t('blog.meta_description'),
twitterDescription: () => $t('blog.meta_description'),
})

useHead({
link: [
{
rel: 'alternate',
title: 'Blog - npmx',
type: 'application/rss+xml',
href: 'https://npmx.dev/rss.xml',
},
{
rel: 'alternate',
title: 'Blog - npmx',
type: 'application/atom+xml',
href: 'https://npmx.dev/atom.xml',
},
{
rel: 'alternate',
title: 'Blog - npmx',
type: 'application/feed+json',
href: 'https://npmx.dev/feed.json',
},
],
})
</script>

<template>
Expand Down
16 changes: 16 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ export default defineNuxtConfig({
'/recharging': { prerender: true },
'/pds': { isr: 86400 }, // revalidate daily
'/blog/**': { prerender: true },
'/rss.xml': {
prerender: true,
headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/rss+xml' },
},
'/atom.xml': {
prerender: true,
headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/atom+xml' },
},
'/feed.json': {
prerender: true,
headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/feed+json' },
},
// proxy for insights
'/_v/script.js': {
proxy: 'https://npmx.dev/_vercel/insights/script.js',
Expand Down Expand Up @@ -231,6 +243,10 @@ export default defineNuxtConfig({
esbuild: {
options: {
target: 'es2024',
// HACK: Excluding node_modules is the default. Here, we exempt
// .cache/nuxt/.nuxt/blog/posts.ts from that so that #blog/posts can be
// imported, parsed and executed as TS in server\utils\feeds.ts by esbuild
exclude: /node_modules\/(?!\.cache\/nuxt\/\.nuxt\/blog\/posts\.ts)/,
},
},
Comment on lines 243 to 251
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm the default buildDir for this project resolves under node_modules
rg -nP "buildDir|\.cache/nuxt" nuxt.config.ts modules/ --type=ts -C2
echo '---'
# Look at how the blog module writes posts.ts and which dir it joins against
rg -nP "addTemplate|buildDir" modules/blog.ts -C3

Repository: npmx-dev/npmx.dev

Length of output: 1546


🏁 Script executed:

#!/bin/bash
# Check if buildDir is explicitly configured in nuxt.config.ts
rg -nP "buildDir\s*[:=]" nuxt.config.ts -A2

# Also check for .cache/nuxt references in config
rg -nP "\.cache" nuxt.config.ts -C2

# Look for any builder or build configuration that might set the path
rg -nP "build\s*[:=]|nitro\s*[:=]" nuxt.config.ts -B1 -A5

Repository: npmx-dev/npmx.dev

Length of output: 1250


🏁 Script executed:

#!/bin/bash
# Get full content of nuxt.config.ts to see complete configuration
wc -l nuxt.config.ts
echo '---'
# Search for buildDir anywhere in config files
find . -maxdepth 2 -name "*.ts" -o -name "*.json" | xargs rg -l "buildDir" 2>/dev/null | head -10
echo '---'
# Check what Nuxt's default buildDir should be
rg -nP "buildDir" . --type=ts --type=json -C1 | grep -E "(buildDir|default)" | head -20

Repository: npmx-dev/npmx.dev

Length of output: 230


🏁 Script executed:

#!/bin/bash
# Read the full nuxt.config.ts file
cat -n nuxt.config.ts | head -100
echo '---'
cat -n nuxt.config.ts | sed -n '200,300p'

Repository: npmx-dev/npmx.dev

Length of output: 6315


🏁 Script executed:

#!/bin/bash
# Check if there are any tests or references to the esbuild config or blog posts
rg -l "blog/posts|esbuild" test/ --type=ts 2>/dev/null | head -5
echo '---'
# Check how the blog posts are actually imported/used
rg -n "#blog/posts" . --type=ts | head -10

Repository: npmx-dev/npmx.dev

Length of output: 441


🏁 Script executed:

#!/bin/bash
# Comprehensive search for buildDir configuration
rg -rn "buildDir\s*[:=]" . --type=ts --type=json 2>/dev/null
echo '---'
# Also search for .cache/nuxt references that might indicate custom buildDir
rg -rn "\.cache/nuxt" . --type=ts --type=json --type=sh 2>/dev/null | grep -v node_modules | head -20

Repository: npmx-dev/npmx.dev

Length of output: 151


The esbuild exclude regex pattern will not match the generated blog posts path — the file will remain excluded and builds will fail.

The pattern expects the path node_modules/.cache/nuxt/.nuxt/blog/posts.ts, but Nuxt's default buildDir is .nuxt at the project root. The generated file will be at .nuxt/blog/posts.ts, which does not match the regex and will still be caught by esbuild's default node_modules exclusion. Since server/utils/feeds.ts imports from #blog/posts, this will cause build failures at runtime.

Two actions needed:

  • Fix the regex pattern to match .nuxt/blog/posts.ts instead, or
  • Add runtime assertion/logging of the resolved buildDir path at build time to catch mismatches immediately.

Also, update the comment's file path to use forward slashes consistently: server/utils/feeds.ts (the regex and actual Linux/macOS paths use /, not Windows-style \).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nuxt.config.ts` around lines 243 - 251, The esbuild exclude regex under the
esbuild options currently targets node_modules/.cache/nuxt/.nuxt/blog/posts.ts
which won't match Nuxt's actual buildDir (e.g. .nuxt/blog/posts.ts); update the
exclude pattern in the esbuild.options.exclude to allow the generated
.nuxt/blog/posts.ts (or otherwise include .nuxt/**/blog/posts.ts) so the
`#blog/posts` import isn't excluded, and add a simple runtime/build-time assertion
or log of the resolved buildDir used by Nuxt (referenced from
server/utils/feeds.ts) to surface mismatches early; also fix the comment path to
use forward slashes (server/utils/feeds.ts) for consistency.

rollupConfig: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"devalue": "5.6.4",
"eslint-plugin-regexp": "3.1.0",
"fast-check": "4.6.0",
"feed": "5.2.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm the feed package is only used behind prerendered routes and nowhere on a runtime path.
rg -nP "from ['\"]feed['\"]|require\(['\"]feed['\"]\)" --type=ts --type=js --type=vue
echo '---'
# Double-check no non-prerendered route imports getFeed
rg -nP -C2 "getFeed\s*\(" --type=ts

Repository: npmx-dev/npmx.dev

Length of output: 992


🏁 Script executed:

# Check where feed is imported in feeds.ts
cat -n server/utils/feeds.ts | head -20

echo '=== Checking nuxt.config.ts for prerender settings ==='
# Search for prerender configurations for the feed routes
rg -nP "atom\.xml|rss\.xml|feed\.json" nuxt.config.ts

echo '=== Current package.json state for feed ==='
# Check where feed is currently placed in package.json
rg -nP -B2 -A2 '"feed":\s*"5\.2\.0"' package.json

echo '=== Searching for any other getFeed or feed imports ==='
# Broader search for any other getFeed invocations
rg -nP "getFeed" --type=ts

Repository: npmx-dev/npmx.dev

Length of output: 1513


🏁 Script executed:

# View the prerender configuration for the feed routes in nuxt.config.ts
sed -n '193,210p' nuxt.config.ts

Repository: npmx-dev/npmx.dev

Length of output: 693


Move feed from devDependencies to dependencies for runtime safety.

feed is imported in server/utils/feeds.ts and used only by three routes (/rss.xml, /atom.xml, /feed.json), all of which have prerender: true in nuxt.config.ts. While this means the dependency is needed only at build time in a fully prerendered deploy, moving it to dependencies is recommended as a safer posture. If any of these routes ever fall back to runtime rendering—such as an ISR fallback, dev preview in production mode, or a prerender failure served on-demand—Nitro's bundled output will reference feed at runtime and it will be missing in a --prod/--production install.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 136, Move the "feed" package from devDependencies to
dependencies in package.json so it is available at runtime; update package.json
by removing "feed": "5.2.0" from devDependencies and adding the same entry under
dependencies. This ensures imports in server/utils/feeds.ts (used by the
/rss.xml, /atom.xml and /feed.json routes with prerender: true) are present in
production builds and prevents runtime errors if those routes are ever rendered
on-demand.

"h3": "1.15.8",
"h3-next": "npm:h3@2.0.1-rc.16",
"knip": "6.0.5",
Expand Down
Loading
Loading