Skip to content

fix(processor): resolve metadata extraction failure on Vercel#179

Open
moshams272 wants to merge 1 commit into
webpack:mainfrom
moshams272:fix/metadata-source-path
Open

fix(processor): resolve metadata extraction failure on Vercel#179
moshams272 wants to merge 1 commit into
webpack:mainfrom
moshams272:fix/metadata-source-path

Conversation

@moshams272

Copy link
Copy Markdown
Contributor

Summary

The Edit this page link works locally well, but in Vercel it doesn't. After debugging, I found in the file plugins/processor/source.mjs that:

export const applySourceMetadata = (
  project,
  { libDir = './webpack/lib' } = {}
) => {
  const absoluteLibDir = resolve(libDir);
  if (!existsSync(absoluteLibDir) || !statSync(absoluteLibDir).isDirectory()) {
    return;
  }
...}

The existsSync function works well locally, as there is a webpack repo in the root path, but we don't have it in vercel.

This PR uses the cached repo instead of that one in the root path.

@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
webpack-doc-kit Ready Ready Preview, Comment Jul 12, 2026 10:05am

Request Review


applyExportEqualsReflections(context.project);
applySourceMetadata(context.project);
applySourceMetadata(context.project, libDir ? { libDir } : {});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit do all this logic inside of applySourceMetadata

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't want to edit this function, but if u see it'll be better, that's my suggestion:

const getWebpackPath = ()=>{
    const versions = JSON.parse(readFileSync('./versions.json'));
    return versions? `./.cache/webpack/${versions[0]}/lib` : `./webpack/lib`
}

const applySourceMetadata = project => {
    const libDir = getWebpackPath();
    ...
}

Make isolated function besides applySourceMetadata, and remove the second option object in function logic as it now like this:

const applySourceMetadata = (project, {libDir = './webpack/lib'} = {}) => {...}

WDUT?!

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

Successfully merging this pull request may close these issues.

2 participants