Skip to content

fix: resolve follow-redirects from runtime package #2124

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

Merged
merged 1 commit into from
May 17, 2023

Conversation

Skn0tt
Copy link
Contributor

@Skn0tt Skn0tt commented May 17, 2023

Description

If the Next Runtime is auto-installed, then follow-redirects (which is a dep of next-runtime) won't be resolvable from .next (the publish dir). This results in an error.

To fix this, I'm adding __dirname as a second resolution starting point. __dirname always points to a file within the next-runtime package, so follow-redirects should be resolvable from there.

Previously discussed in https://netlify.slack.com/archives/C02T8ASK2E9/p1684318093610159.

Documentation

Tests

You can test this change yourself like so:

  1. TODO

Relevant links (GitHub issues, etc.) or a picture of cute animal

@Skn0tt Skn0tt requested a review from a team as a code owner May 17, 2023 11:10
@netlify
Copy link

netlify bot commented May 17, 2023

Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!

Name Link
🔨 Latest commit 974ebe2
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/6464b60d7928b300087ee4f4
😎 Deploy Preview https://deploy-preview-2124--netlify-plugin-nextjs-nx-monorepo-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 17, 2023

Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!

Name Link
🔨 Latest commit 974ebe2
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/6464b60da6ea3c000848aeb0
😎 Deploy Preview https://deploy-preview-2124--netlify-plugin-nextjs-static-root-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 17, 2023

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
🔨 Latest commit 974ebe2
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/6464b60d8702980008728b91
😎 Deploy Preview https://deploy-preview-2124--netlify-plugin-nextjs-export-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot added the type: bug code to address defects in shipped code label May 17, 2023
@netlify
Copy link

netlify bot commented May 17, 2023

Deploy Preview for nextjs-plugin-custom-routes-demo ready!

Name Link
🔨 Latest commit 974ebe2
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/6464b60d48980b00080d3726
😎 Deploy Preview https://deploy-preview-2124--nextjs-plugin-custom-routes-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 17, 2023

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
🔨 Latest commit 974ebe2
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/6464b60dd0846a00087e07ce
😎 Deploy Preview https://deploy-preview-2124--netlify-plugin-nextjs-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 17, 2023

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
🔨 Latest commit 974ebe2
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/6464b60d1883fd00070d62df
😎 Deploy Preview https://deploy-preview-2124--netlify-plugin-nextjs-next-auth-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 17, 2023

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit 974ebe2
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/6464b60dbe59ed000890bc90
😎 Deploy Preview https://deploy-preview-2124--next-i18next-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 17, 2023

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
🔨 Latest commit 974ebe2
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/6464b60d378f21000800e208
😎 Deploy Preview https://deploy-preview-2124--next-plugin-edge-middleware.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 17, 2023

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit 974ebe2
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/6464b60d57934a0008bda9d6
😎 Deploy Preview https://deploy-preview-2124--next-plugin-canary.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@@ -269,7 +269,7 @@ const traceNextServer = async (publish: string): Promise<string[]> => {

export const traceNPMPackage = async (packageName: string, publish: string) => {
try {
return await glob(join(dirname(require.resolve(packageName, { paths: [publish] })), '**', '*'), {
return await glob(join(dirname(require.resolve(packageName, { paths: [__dirname, publish] })), '**', '*'), {
Copy link

Choose a reason for hiding this comment

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

Are we sure this file is exectued as commonjs and not ESM? because __dirname is only available in commonjs.

Copy link

Choose a reason for hiding this comment

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

Okay I see that __dirname is also used on other locations in this file.

Copy link
Member

Choose a reason for hiding this comment

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

It better be, because require.resolve is also absent from ESM.

@Skn0tt Skn0tt merged commit 49ada27 into main May 17, 2023
@Skn0tt Skn0tt deleted the fix-resolve-follow-redirects-autoinstall branch May 17, 2023 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants